Skip to content

Commit

Permalink
Merge pull request #8 from zapier/fix-cleanup
Browse files Browse the repository at this point in the history
Improve error logging and handle unlocked workspaces better
  • Loading branch information
davidwin93 authored Jan 4, 2023
2 parents 002abcd + f7819ea commit 43d7dd9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/tfc_trigger/tfc_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (t *TFCTrigger) TriggerCleanupEvent() error {
var wsNames []string
cfg, err := getProjectConfigFile(t.gl, t)
if err != nil {
log.Debug().Msg("ignoring cleanup trigger for project, missing .tfbuddy.yaml")
return t.handleError(err, "ignoring cleanup trigger for project, missing .tfbuddy.yaml")
}
tag := fmt.Sprintf("%s-%d", tfPrefix, mr.GetInternalID())
for _, cfgWS := range cfg.Workspaces {
Expand All @@ -416,10 +416,10 @@ func (t *TFCTrigger) TriggerCleanupEvent() error {
t.handleError(err, "Error removing locking tag from workspace")
continue
}
wsNames = append(wsNames, cfgWS.Name)
}
// record workspace even if there are not tags since we could have cleared them earlier (same event can be called multiple times)
wsNames = append(wsNames, cfgWS.Name)
}

_, err = t.gl.CreateMergeRequestDiscussion(mr.GetInternalID(),
t.cfg.GetProjectNameWithNamespace(),
fmt.Sprintf("Released locks for workspaces: %s", strings.Join(wsNames, ",")),
Expand Down

0 comments on commit 43d7dd9

Please sign in to comment.