Skip to content

Commit

Permalink
Merge pull request #566 from Praqma/issue-565
Browse files Browse the repository at this point in the history
Accept nil targetRelease on executing command, just omit hooks part
  • Loading branch information
luisdavim authored Jan 12, 2021
2 parents 29e2f0f + ef19202 commit 317bf71
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions internal/app/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,47 +135,45 @@ func releaseWithHooks(cmd orderedCommand, storageBackend string, wg *sync.WaitGr
wg.Done()
<-sem
}()
if cmd.targetRelease == nil && !flags.destroy {
err := fmt.Errorf("nil target release")
errors <- err
log.Verbose(err.Error())
return
}
var annotations []string
for _, c := range cmd.beforeCommands {
if err := execOne(c.Command, cmd.targetRelease); err != nil {
errors <- err
if cmd.targetRelease != nil && !flags.destroy {
for _, c := range cmd.beforeCommands {
if err := execOne(c.Command, cmd.targetRelease); err != nil {
errors <- err
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=failed")
}
log.Verbose(err.Error())
return
}
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=failed")
annotations = append(annotations, key+"=ok")
}
log.Verbose(err.Error())
return
}
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=ok")
if !flags.dryRun && !flags.destroy {
defer func() {
cmd.targetRelease.mark(storageBackend)
cmd.targetRelease.annotate(storageBackend, annotations...)
}()
}
}
if !flags.dryRun && !flags.destroy {
defer func() {
cmd.targetRelease.mark(storageBackend)
cmd.targetRelease.annotate(storageBackend, annotations...)
}()
}
if err := execOne(cmd.Command, cmd.targetRelease); err != nil {
errors <- err
log.Verbose(err.Error())
return
}
for _, c := range cmd.afterCommands {
if err := execOne(c.Command, cmd.targetRelease); err != nil {
errors <- err
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=failed")
}
log.Verbose(err.Error())
} else {
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=ok")
if cmd.targetRelease != nil && !flags.destroy {
for _, c := range cmd.afterCommands {
if err := execOne(c.Command, cmd.targetRelease); err != nil {
errors <- err
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=failed")
}
log.Verbose(err.Error())
} else {
if key, err := c.getAnnotationKey(); err != nil {
annotations = append(annotations, key+"=ok")
}
}
}
}
Expand Down

0 comments on commit 317bf71

Please sign in to comment.