From 0c928411f63bcd0840818e67f16d8f1d3ecc27bb Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Fri, 12 Apr 2019 11:59:34 +0200 Subject: [PATCH] Fix automated legacy matrix convert We got to move the envsubst call behind the legacy convert, otherwise the matrix convert gets broken because it fails to replace the matrix variables as they don't exist anymore. --- go.sum | 2 ++ operator/runner/runner.go | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/go.sum b/go.sum index aeb73f5b4..aa6b01485 100644 --- a/go.sum +++ b/go.sum @@ -114,6 +114,8 @@ github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6 h1:qCv4319q2q7XKn0MQbi8p37hsJ+9Xo8e6yojA73JVxk= github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6/go.mod h1:fXcdFsQoipQa7mwORhKad5jmDCeSy/RCGzWA08PO0lM= +github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/nomad v0.0.0-20190125003214-134391155854 h1:L7WhLZt2ory/kQWxqkMwOiBpIoa4BWoadN7yx8LHEtk= diff --git a/operator/runner/runner.go b/operator/runner/runner.go index ca7ff7b28..10ca9f6cf 100644 --- a/operator/runner/runner.go +++ b/operator/runner/runner.go @@ -184,7 +184,18 @@ func (r *Runner) Run(ctx context.Context, id int64) error { // TODO mutate the yaml // - y, err := envsubst.Eval(string(m.Config.Data), func(name string) string { + // this code is temporarily in place to detect and convert + // the legacy yaml configuration file to the new format. + y, err := converter.ConvertString(string(m.Config.Data), converter.Metadata{ + Filename: m.Repo.Config, + Ref: m.Build.Ref, + }) + + if err != nil { + return err + } + + y, err = envsubst.Eval(y, func(name string) string { env := environ[name] if strings.Contains(env, "\n") { env = fmt.Sprintf("%q", env) @@ -192,16 +203,6 @@ func (r *Runner) Run(ctx context.Context, id int64) error { return env }) - // this code is temporarily in place to detect and convert - // the legacy yaml configuration file to the new format. - y, err = converter.ConvertString(y, converter.Metadata{ - Filename: m.Repo.Config, - Ref: m.Build.Ref, - }) - if err != nil { - return err - } - manifest, err := yaml.ParseString(y) if err != nil { logger = logger.WithError(err)