From c7fd7938d6237d22504c9a93e4f6399ea246af02 Mon Sep 17 00:00:00 2001 From: Erick Daniszewski Date: Tue, 7 Jul 2020 10:37:40 -0400 Subject: [PATCH] update: modify config validation checks, add logging --- pkg/v1/cfg/config.go | 12 ++++++++---- pkg/v1/stages/extras/extras.go | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/v1/cfg/config.go b/pkg/v1/cfg/config.go index db46d11..4eada54 100644 --- a/pkg/v1/cfg/config.go +++ b/pkg/v1/cfg/config.go @@ -224,10 +224,12 @@ type ReleaseConfig struct { func (c *ReleaseConfig) validate() error { collector := errs.NewCollector() - // FIXME (etd): Should this check only be run if there is a strategy specified? - // otherwise, it feels like this should default to "default". - if _, err := strategies.UpdateStrategyFromString(c.Strategy); err != nil { - collector.Add(fmt.Errorf("invalid release strategy '%v', should be one of: %v", c.Strategy, strategies.ListUpdateStrategies())) + // Only validate the strategy if one is set. If not set, this will use + // the "default" strategy once the update pipeline is run. + if c.Strategy != "" { + if _, err := strategies.UpdateStrategyFromString(c.Strategy); err != nil { + collector.Add(fmt.Errorf("invalid release strategy '%v', should be one of: %v", c.Strategy, strategies.ListUpdateStrategies())) + } } if collector.HasErrors() { @@ -301,6 +303,8 @@ func (c *ExtrasConfig) validate() error { if c.Path != "" && len(c.Updates) == 0 { collector.Add(fmt.Errorf("extras config specifies path but no options for search/replace updates")) + } else if c.Path == "" && len(c.Updates) != 0 { + collector.Add(fmt.Errorf("extras config specifies search/replace options, but no file path")) } for _, u := range c.Updates { diff --git a/pkg/v1/stages/extras/extras.go b/pkg/v1/stages/extras/extras.go index 661489a..7250737 100644 --- a/pkg/v1/stages/extras/extras.go +++ b/pkg/v1/stages/extras/extras.go @@ -38,6 +38,11 @@ func (Stage) Run(ctx *context.Context) error { RepoName: ctx.Repository.Name, RepoOwner: ctx.Repository.Owner, } + log.WithFields(log.Fields{ + "path": extra.Path, + "repoName": ctx.Repository.Name, + "repoOwner": ctx.Repository.Owner, + }).Debug("getting file contents") contents, err := ctx.Client.GetFile(ctx.Context, opts, extra.Path) if err != nil {