Skip to content

Commit

Permalink
update: modify config validation checks, add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Jul 7, 2020
1 parent ccd0faf commit c7fd793
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/v1/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions pkg/v1/stages/extras/extras.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c7fd793

Please sign in to comment.