mirror of
https://github.com/offen/docker-volume-backup.git
synced 2025-12-06 01:28:03 +01:00
Lay out control flow for spawning container
This commit is contained in:
@@ -36,8 +36,15 @@ func (c *command) runAsCommand() error {
|
||||
}
|
||||
|
||||
for _, config := range configurations {
|
||||
if err := runScript(config); err != nil {
|
||||
return errwrap.Wrap(err, "error running script")
|
||||
switch config.ExecutionMode {
|
||||
case "process":
|
||||
if err := runScript(config); err != nil {
|
||||
return errwrap.Wrap(err, "error running script")
|
||||
}
|
||||
case "container":
|
||||
panic("execution mode container not implemented")
|
||||
default:
|
||||
return errwrap.Wrap(nil, fmt.Sprintf("unknown execution mode %s", config.ExecutionMode))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,16 +117,29 @@ func (c *command) schedule(strategy configStrategy) error {
|
||||
),
|
||||
)
|
||||
|
||||
if err := runScript(config); err != nil {
|
||||
switch config.ExecutionMode {
|
||||
case "process":
|
||||
if err := runScript(config); err != nil {
|
||||
c.logger.Error(
|
||||
fmt.Sprintf(
|
||||
"Unexpected error running schedule %s: %v",
|
||||
config.BackupCronExpression,
|
||||
errwrap.Unwrap(err),
|
||||
),
|
||||
"error",
|
||||
err,
|
||||
)
|
||||
}
|
||||
case "container":
|
||||
panic("execution mode container not implemented")
|
||||
default:
|
||||
c.logger.Error(
|
||||
fmt.Sprintf(
|
||||
"Unexpected error running schedule %s: %v",
|
||||
config.BackupCronExpression,
|
||||
errwrap.Unwrap(err),
|
||||
"Unkown execution mode %s, please check your configuration",
|
||||
config.ExecutionMode,
|
||||
),
|
||||
"error",
|
||||
err,
|
||||
)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user