From e8fb0cfca665a5961b455dfa792c01d882f651bb Mon Sep 17 00:00:00 2001 From: Eoin McAfee <83226740+eoinmcafee00@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:06:03 +0100 Subject: [PATCH] fix templating reg expression to match if .drone.yml contains --- characters (#3131) * issue with regular expression for templates not picking up --- in drone.yml file --- plugin/converter/template.go | 2 +- plugin/converter/testdata/starlark.template.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/converter/template.go b/plugin/converter/template.go index 5840e9c41..aa72a82d6 100644 --- a/plugin/converter/template.go +++ b/plugin/converter/template.go @@ -36,7 +36,7 @@ import ( var ( // templateFileRE regex to verifying kind is template. - templateFileRE = regexp.MustCompile("^kind:\\s+template+\\n") + templateFileRE = regexp.MustCompilePOSIX("^kind:[[:space:]]+template[[:space:]]?+$") errTemplateNotFound = errors.New("template converter: template name given not found") errTemplateSyntaxErrors = errors.New("template converter: there is a problem with the yaml file provided") errTemplateExtensionInvalid = errors.New("template extension invalid. must be yaml, starlark or jsonnet") diff --git a/plugin/converter/testdata/starlark.template.yml b/plugin/converter/testdata/starlark.template.yml index 2f516fd7f..d11f5b3a3 100644 --- a/plugin/converter/testdata/starlark.template.yml +++ b/plugin/converter/testdata/starlark.template.yml @@ -1,3 +1,4 @@ +--- kind: template load: plugin.starlark data: