Skip to content

Commit c7fd793

Browse files
committed
update: modify config validation checks, add logging
1 parent ccd0faf commit c7fd793

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pkg/v1/cfg/config.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,12 @@ type ReleaseConfig struct {
224224
func (c *ReleaseConfig) validate() error {
225225
collector := errs.NewCollector()
226226

227-
// FIXME (etd): Should this check only be run if there is a strategy specified?
228-
// otherwise, it feels like this should default to "default".
229-
if _, err := strategies.UpdateStrategyFromString(c.Strategy); err != nil {
230-
collector.Add(fmt.Errorf("invalid release strategy '%v', should be one of: %v", c.Strategy, strategies.ListUpdateStrategies()))
227+
// Only validate the strategy if one is set. If not set, this will use
228+
// the "default" strategy once the update pipeline is run.
229+
if c.Strategy != "" {
230+
if _, err := strategies.UpdateStrategyFromString(c.Strategy); err != nil {
231+
collector.Add(fmt.Errorf("invalid release strategy '%v', should be one of: %v", c.Strategy, strategies.ListUpdateStrategies()))
232+
}
231233
}
232234

233235
if collector.HasErrors() {
@@ -301,6 +303,8 @@ func (c *ExtrasConfig) validate() error {
301303

302304
if c.Path != "" && len(c.Updates) == 0 {
303305
collector.Add(fmt.Errorf("extras config specifies path but no options for search/replace updates"))
306+
} else if c.Path == "" && len(c.Updates) != 0 {
307+
collector.Add(fmt.Errorf("extras config specifies search/replace options, but no file path"))
304308
}
305309

306310
for _, u := range c.Updates {

pkg/v1/stages/extras/extras.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func (Stage) Run(ctx *context.Context) error {
3838
RepoName: ctx.Repository.Name,
3939
RepoOwner: ctx.Repository.Owner,
4040
}
41+
log.WithFields(log.Fields{
42+
"path": extra.Path,
43+
"repoName": ctx.Repository.Name,
44+
"repoOwner": ctx.Repository.Owner,
45+
}).Debug("getting file contents")
4146

4247
contents, err := ctx.Client.GetFile(ctx.Context, opts, extra.Path)
4348
if err != nil {

0 commit comments

Comments
 (0)