flags

package
v0.0.0-...-5840427 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package flags manages command-line flags and environment variables for Watchtower configuration. It configures Docker connections, system behavior, and notifications via Cobra and Viper.

Key components:

  • RegisterDockerFlags: Adds Docker API client flags.
  • RegisterSystemFlags: Adds operational control flags.
  • RegisterNotificationFlags: Adds notification settings.
  • SetupLogging: Configures logrus based on flags.

Usage example:

cmd := &cobra.Command{}
flags.RegisterSystemFlags(cmd)
flags.SetDefaults()
err := flags.SetupLogging(cmd.PersistentFlags())
if err != nil {
    logrus.WithError(err).Fatal("Logging setup failed")
}

The package integrates with Cobra for flag parsing, Viper for environment variable binding, and logrus for logging configuration errors.

Index

Constants

View Source
const DockerAPIMinVersion string = "1.24"

DockerAPIMinVersion sets the minimum Docker API version supported by Watchtower.

Variables

This section is empty.

Functions

func EnvConfig

func EnvConfig(cmd *cobra.Command) error

EnvConfig sets Docker environment variables from flags.

Parameters:

  • cmd: Cobra command with flags.

Returns:

  • error: Non-nil if flag retrieval fails, nil on success.

func GetSecretsFromFiles

func GetSecretsFromFiles(rootCmd *cobra.Command)

GetSecretsFromFiles updates flags with file contents for secrets.

Parameters:

  • rootCmd: Root Cobra command.

func ProcessFlagAliases

func ProcessFlagAliases(flags *pflag.FlagSet)

ProcessFlagAliases syncs flag values based on aliases.

Parameters:

  • flags: Flag set.

func ReadFlags

func ReadFlags(cmd *cobra.Command) (bool, bool, bool, time.Duration)

ReadFlags retrieves key operational flags.

Parameters:

  • cmd: Cobra command with flags.

Returns:

  • bool: Cleanup setting.
  • bool: No-restart setting.
  • bool: Monitor-only setting.
  • time.Duration: Stop timeout.

func RegisterDockerFlags

func RegisterDockerFlags(rootCmd *cobra.Command)

RegisterDockerFlags adds Docker API client flags to the root command.

Parameters:

  • rootCmd: Root Cobra command.

func RegisterNotificationFlags

func RegisterNotificationFlags(rootCmd *cobra.Command)

RegisterNotificationFlags adds notification flags to the root command.

Parameters:

  • rootCmd: Root Cobra command.

func RegisterSystemFlags

func RegisterSystemFlags(rootCmd *cobra.Command)

RegisterSystemFlags adds Watchtower flow control flags to the root command.

Parameters:

  • rootCmd: Root Cobra command.

func SetDefaults

func SetDefaults()

SetDefaults sets default environment variable values.

It configures fallback values for unset flags.

func SetupLogging

func SetupLogging(flags *pflag.FlagSet) error

SetupLogging configures the global logger.

Parameters:

  • flags: Flag set.

Returns:

  • error: Non-nil if config fails, nil on success.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL