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.
This commit is contained in:
Thomas Boerger 2019-04-12 11:59:34 +02:00
parent c338fadd4f
commit 0c928411f6
No known key found for this signature in database
GPG key ID: 09745AFF9D63C79B
2 changed files with 14 additions and 11 deletions

2
go.sum
View file

@ -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=

View file

@ -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)