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
- func EnvConfig(cmd *cobra.Command) error
- func GetSecretsFromFiles(rootCmd *cobra.Command)
- func ProcessFlagAliases(flags *pflag.FlagSet)
- func ReadFlags(cmd *cobra.Command) (bool, bool, bool, time.Duration)
- func RegisterDockerFlags(rootCmd *cobra.Command)
- func RegisterNotificationFlags(rootCmd *cobra.Command)
- func RegisterSystemFlags(rootCmd *cobra.Command)
- func SetDefaults()
- func SetupLogging(flags *pflag.FlagSet) error
Constants ¶
const DockerAPIMinVersion string = "1.24"
DockerAPIMinVersion sets the minimum Docker API version supported by Watchtower.
Variables ¶
This section is empty.
Functions ¶
func EnvConfig ¶
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 ¶
GetSecretsFromFiles updates flags with file contents for secrets.
Parameters:
- rootCmd: Root Cobra command.
func ProcessFlagAliases ¶
ProcessFlagAliases syncs flag values based on aliases.
Parameters:
- flags: Flag set.
func ReadFlags ¶
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 ¶
RegisterDockerFlags adds Docker API client flags to the root command.
Parameters:
- rootCmd: Root Cobra command.
func RegisterNotificationFlags ¶
RegisterNotificationFlags adds notification flags to the root command.
Parameters:
- rootCmd: Root Cobra command.
func RegisterSystemFlags ¶
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 ¶
SetupLogging configures the global logger.
Parameters:
- flags: Flag set.
Returns:
- error: Non-nil if config fails, nil on success.
Types ¶
This section is empty.