1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-23 21:44:40 +02:00

Refactor handling of runtime configuration to prepare for reloading

This commit is contained in:
Frederik Ring
2024-02-13 19:21:57 +01:00
parent c4e480dcfd
commit 83fa0aae48
14 changed files with 665 additions and 520 deletions

View File

@@ -9,6 +9,7 @@ package main
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"os"
@@ -190,13 +191,12 @@ func (s *script) withLabeledCommands(step lifecyclePhase, cb func() error) func(
}
return func() (err error) {
if err = s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-pre", step)); err != nil {
err = fmt.Errorf("withLabeledCommands: %s: error running pre commands: %w", step, err)
err = fmt.Errorf("(*script).withLabeledCommands: %s: error running pre commands: %w", step, err)
return
}
defer func() {
derr := s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-post", step))
if err == nil && derr != nil {
err = derr
if derr := s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-post", step)); derr != nil {
err = errors.Join(err, fmt.Errorf("(*script).withLabeledCommands: error running %s-post commands: %w", step, derr))
}
}()
err = cb()