Change parameter name from delay-days to defer-days to be clearer to user and align with status reporting

This commit is contained in:
Peter Wilhelm 2024-01-07 17:59:10 -06:00
parent 0d1d7979cb
commit 223358f7a0
4 changed files with 16 additions and 15 deletions

View file

@ -39,7 +39,7 @@ var (
disableContainers []string
notifier t.Notifier
timeout time.Duration
delayDays int
deferDays int
lifecycleHooks bool
rollingRestart bool
scope string
@ -97,7 +97,7 @@ func PreRun(cmd *cobra.Command, _ []string) {
enableLabel, _ = f.GetBool("label-enable")
disableContainers, _ = f.GetStringSlice("disable-containers")
delayDays, _ = f.GetInt("delay-days")
deferDays, _ = f.GetInt("defer-days")
lifecycleHooks, _ = f.GetBool("enable-lifecycle-hooks")
rollingRestart, _ = f.GetBool("rolling-restart")
scope, _ = f.GetString("scope")
@ -290,9 +290,9 @@ func writeStartupMessage(c *cobra.Command, sched time.Time, filtering string) {
until := formatDuration(time.Until(sched))
startupLog.Info("Scheduling first run: " + sched.Format("2006-01-02 15:04:05 -0700 MST"))
startupLog.Info("Note that the first check will be performed in " + until)
delayDays, _ = c.PersistentFlags().GetInt("delay-days")
if delayDays > 0 {
startupLog.Infof("Container updates will be delayed until %d day(s) after image creation.", delayDays)
deferDays, _ = c.PersistentFlags().GetInt("defer-days")
if deferDays > 0 {
startupLog.Infof("Container updates will be deferred until %d day(s) after image creation.", deferDays)
}
} else if runOnce, _ := c.PersistentFlags().GetBool("run-once"); runOnce {
startupLog.Info("Running a one time update.")
@ -370,7 +370,7 @@ func runUpdatesWithNotifications(filter t.Filter) *metrics.Metric {
NoRestart: noRestart,
Timeout: timeout,
MonitorOnly: monitorOnly,
DelayDays: delayDays,
DeferDays: deferDays,
LifecycleHooks: lifecycleHooks,
RollingRestart: rollingRestart,
LabelPrecedence: labelPrecedence,
@ -383,9 +383,10 @@ func runUpdatesWithNotifications(filter t.Filter) *metrics.Metric {
notifier.SendNotification(result)
metricResults := metrics.NewMetric(result)
notifications.LocalLog.WithFields(log.Fields{
"Scanned": metricResults.Scanned,
"Updated": metricResults.Updated,
"Failed": metricResults.Failed,
"Scanned": metricResults.Scanned,
"Updated": metricResults.Updated,
"Deferred": metricResults.Deferred,
"Failed": metricResults.Failed,
}).Info("Session done")
return metricResults
}

View file

@ -381,12 +381,12 @@ Environment Variable: WATCHTOWER_HTTP_API_METRICS
Default: false
```
## Delayed Update
## Deferred Update
Only update container to latest version of image if some number of days have passed since it has been published. This option may be useful for those who wish to avoid updating prior to the new version having some time in the field prior to updating in case there are critical defects found and released in a subsequent version.
```text
Argument: --delay-days
Environment Variable: WATCHTOWER_DELAY_DAYS
Argument: --defer-days
Environment Variable: WATCHTOWER_DEFER_DAYS
Type: Integer
Default: false
```

View file

@ -148,9 +148,9 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
"Enable the execution of commands triggered by pre- and post-update lifecycle hooks")
flags.IntP(
"delay-days",
"defer-days",
"0",
envInt("WATCHTOWER_DELAY_DAYS"),
envInt("WATCHTOWER_DEFER_DAYS"),
"Number of days to wait for new image version to be in place prior to installing it")
flags.BoolP(

View file

@ -12,7 +12,7 @@ type UpdateParams struct {
Timeout time.Duration
MonitorOnly bool
NoPull bool
DelayDays int
DeferDays int
LifecycleHooks bool
RollingRestart bool
LabelPrecedence bool