Hoist control for exiting script a level up

This commit is contained in:
Frederik Ring
2024-02-07 19:24:05 +01:00
parent d14e826529
commit 749ca85db9
5 changed files with 143 additions and 113 deletions

View File

@@ -188,12 +188,12 @@ func (s *script) withLabeledCommands(step lifecyclePhase, cb func() error) func(
if s.cli == nil {
return cb
}
return func() error {
return func() (ret error) {
if err := s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-pre", step)); err != nil {
return fmt.Errorf("withLabeledCommands: %s: error running pre commands: %w", step, err)
}
defer func() {
s.must(s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-post", step)))
ret = s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-post", step))
}()
return cb()
}