Allow running periodic updates with enabled HTTP API (#916)

* Allow running periodic updates with enabled HTTP API

* Add --http-api-periodic-polls to docs
This commit is contained in:
DasSkelett 2021-04-27 22:18:45 +02:00 committed by GitHub
parent e308521a95
commit 6b155a111a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 12 deletions

View file

@ -151,6 +151,11 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
"",
viper.GetString("WATCHTOWER_HTTP_API_TOKEN"),
"Sets an authentication token to HTTP API requests.")
flags.BoolP(
"http-api-periodic-polls",
"",
viper.GetBool("WATCHTOWER_HTTP_API_PERIODIC_POLLS"),
"Also run periodic updates (specified with --interval and --schedule) if HTTP API is enabled")
// https://no-color.org/
flags.BoolP(
"no-color",

View file

@ -79,3 +79,18 @@ func testGetSecretsFromFiles(t *testing.T, flagName string, expected string) {
assert.Equal(t, expected, value)
}
func TestHTTPAPIPeriodicPollsFlag(t *testing.T) {
cmd := new(cobra.Command)
SetDefaults()
RegisterDockerFlags(cmd)
RegisterSystemFlags(cmd)
err := cmd.ParseFlags([]string{"--http-api-periodic-polls"})
require.NoError(t, err)
periodicPolls, err := cmd.PersistentFlags().GetBool("http-api-periodic-polls")
require.NoError(t, err)
assert.Equal(t, true, periodicPolls)
}