|
| 1 | +package app |
| 2 | + |
| 3 | +import ( |
| 4 | + "time" |
| 5 | + |
| 6 | + "github.com/urfave/cli" |
| 7 | +) |
| 8 | + |
| 9 | +// SetupCliFlags registers flags on the supplied urfave app |
| 10 | +func SetupCliFlags(app *cli.App) { |
| 11 | + app.Flags = []cli.Flag{ |
| 12 | + cli.StringFlag{ |
| 13 | + Name: "host, H", |
| 14 | + Usage: "daemon socket to connect to", |
| 15 | + Value: "unix:///var/run/docker.sock", |
| 16 | + EnvVar: "DOCKER_HOST", |
| 17 | + }, |
| 18 | + cli.IntFlag{ |
| 19 | + Name: "interval, i", |
| 20 | + Usage: "poll interval (in seconds)", |
| 21 | + Value: 300, |
| 22 | + EnvVar: "WATCHTOWER_POLL_INTERVAL", |
| 23 | + }, |
| 24 | + cli.StringFlag{ |
| 25 | + Name: "schedule, s", |
| 26 | + Usage: "the cron expression which defines when to update", |
| 27 | + EnvVar: "WATCHTOWER_SCHEDULE", |
| 28 | + }, |
| 29 | + cli.BoolFlag{ |
| 30 | + Name: "no-pull", |
| 31 | + Usage: "do not pull new images", |
| 32 | + EnvVar: "WATCHTOWER_NO_PULL", |
| 33 | + }, |
| 34 | + cli.BoolFlag{ |
| 35 | + Name: "no-restart", |
| 36 | + Usage: "do not restart containers", |
| 37 | + EnvVar: "WATCHTOWER_NO_RESTART", |
| 38 | + }, |
| 39 | + cli.BoolFlag{ |
| 40 | + Name: "cleanup", |
| 41 | + Usage: "remove old images after updating", |
| 42 | + EnvVar: "WATCHTOWER_CLEANUP", |
| 43 | + }, |
| 44 | + cli.BoolFlag{ |
| 45 | + Name: "tlsverify", |
| 46 | + Usage: "use TLS and verify the remote", |
| 47 | + EnvVar: "DOCKER_TLS_VERIFY", |
| 48 | + }, |
| 49 | + cli.DurationFlag{ |
| 50 | + Name: "stop-timeout", |
| 51 | + Usage: "timeout before container is forcefully stopped", |
| 52 | + Value: time.Second * 10, |
| 53 | + EnvVar: "WATCHTOWER_TIMEOUT", |
| 54 | + }, |
| 55 | + cli.BoolFlag{ |
| 56 | + Name: "label-enable", |
| 57 | + Usage: "watch containers where the com.centurylinklabs.watchtower.enable label is true", |
| 58 | + EnvVar: "WATCHTOWER_LABEL_ENABLE", |
| 59 | + }, |
| 60 | + cli.BoolFlag{ |
| 61 | + Name: "debug", |
| 62 | + Usage: "enable debug mode with verbose logging", |
| 63 | + }, |
| 64 | + cli.StringSliceFlag{ |
| 65 | + Name: "notifications", |
| 66 | + Value: &cli.StringSlice{}, |
| 67 | + Usage: "notification types to send (valid: email, slack, msteams)", |
| 68 | + EnvVar: "WATCHTOWER_NOTIFICATIONS", |
| 69 | + }, |
| 70 | + cli.StringFlag{ |
| 71 | + Name: "notifications-level", |
| 72 | + Usage: "The log level used for sending notifications. Possible values: \"panic\", \"fatal\", \"error\", \"warn\", \"info\" or \"debug\"", |
| 73 | + EnvVar: "WATCHTOWER_NOTIFICATIONS_LEVEL", |
| 74 | + Value: "info", |
| 75 | + }, |
| 76 | + cli.StringFlag{ |
| 77 | + Name: "notification-email-from", |
| 78 | + Usage: "Address to send notification e-mails from", |
| 79 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_FROM", |
| 80 | + }, |
| 81 | + cli.StringFlag{ |
| 82 | + Name: "notification-email-to", |
| 83 | + Usage: "Address to send notification e-mails to", |
| 84 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_TO", |
| 85 | + }, |
| 86 | + cli.StringFlag{ |
| 87 | + Name: "notification-email-server", |
| 88 | + Usage: "SMTP server to send notification e-mails through", |
| 89 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_SERVER", |
| 90 | + }, |
| 91 | + cli.IntFlag{ |
| 92 | + Name: "notification-email-server-port", |
| 93 | + Usage: "SMTP server port to send notification e-mails through", |
| 94 | + Value: 25, |
| 95 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT", |
| 96 | + }, |
| 97 | + cli.BoolFlag{ |
| 98 | + Name: "notification-email-server-tls-skip-verify", |
| 99 | + Usage: "Controls whether watchtower verifies the SMTP server's certificate chain and host name. " + |
| 100 | + "If set, TLS accepts any certificate " + |
| 101 | + "presented by the server and any host name in that certificate. " + |
| 102 | + "In this mode, TLS is susceptible to man-in-the-middle attacks. " + |
| 103 | + "This should be used only for testing.", |
| 104 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_SERVER_TLS_SKIP_VERIFY", |
| 105 | + }, |
| 106 | + cli.StringFlag{ |
| 107 | + Name: "notification-email-server-user", |
| 108 | + Usage: "SMTP server user for sending notifications", |
| 109 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER", |
| 110 | + }, |
| 111 | + cli.StringFlag{ |
| 112 | + Name: "notification-email-server-password", |
| 113 | + Usage: "SMTP server password for sending notifications", |
| 114 | + EnvVar: "WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD", |
| 115 | + }, |
| 116 | + cli.StringFlag{ |
| 117 | + Name: "notification-slack-hook-url", |
| 118 | + Usage: "The Slack Hook URL to send notifications to", |
| 119 | + EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL", |
| 120 | + }, |
| 121 | + cli.StringFlag{ |
| 122 | + Name: "notification-slack-identifier", |
| 123 | + Usage: "A string which will be used to identify the messages coming from this watchtower instance. Default if omitted is \"watchtower\"", |
| 124 | + EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER", |
| 125 | + Value: "watchtower", |
| 126 | + }, |
| 127 | + cli.StringFlag{ |
| 128 | + Name: "notification-slack-channel", |
| 129 | + Usage: "A string which overrides the webhook's default channel. Example: #my-custom-channel", |
| 130 | + EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_CHANNEL", |
| 131 | + }, |
| 132 | + cli.StringFlag{ |
| 133 | + Name: "notification-slack-icon-emoji", |
| 134 | + Usage: "An emoji code string to use in place of the default icon", |
| 135 | + EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_ICON_EMOJI", |
| 136 | + }, |
| 137 | + cli.StringFlag{ |
| 138 | + Name: "notification-slack-icon-url", |
| 139 | + Usage: "An icon image URL string to use in place of the default icon", |
| 140 | + EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_ICON_URL", |
| 141 | + }, |
| 142 | + cli.StringFlag{ |
| 143 | + Name: "notification-msteams-hook", |
| 144 | + Usage: "The MSTeams WebHook URL to send notifications to", |
| 145 | + EnvVar: "WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL", |
| 146 | + }, |
| 147 | + cli.BoolFlag{ |
| 148 | + Name: "notification-msteams-data", |
| 149 | + Usage: "The MSTeams notifier will try to extract log entry fields as MSTeams message facts", |
| 150 | + EnvVar: "WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA", |
| 151 | + }, |
| 152 | + cli.BoolFlag{ |
| 153 | + Name: "monitor-only", |
| 154 | + Usage: "Will only monitor for new images, not update the containers", |
| 155 | + EnvVar: "WATCHTOWER_MONITOR_ONLY", |
| 156 | + }, |
| 157 | + cli.BoolFlag{ |
| 158 | + Name: "run-once", |
| 159 | + Usage: "Run once now and exit", |
| 160 | + }, |
| 161 | + } |
| 162 | +} |
0 commit comments