Skip to content

Commit 61ea007

Browse files
authored
feat: Support setting run --interval via env variable. (#1107)
Signed-off-by: Denis Karpelevich <56302307+dkarpele@users.noreply.github.com>
1 parent 90959eb commit 61ea007

File tree

7 files changed

+30
-8
lines changed

7 files changed

+30
-8
lines changed

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func newRunCommand() *cobra.Command {
225225
runCmd.Flags().BoolVar(&cfg.ClientOpts.Plaintext, "argocd-plaintext", env.GetBoolVal("ARGOCD_PLAINTEXT", false), "(INSECURE) connect without TLS to ArgoCD server")
226226
runCmd.Flags().StringVar(&cfg.ClientOpts.AuthToken, "argocd-auth-token", "", "use token for authenticating to ArgoCD (unsafe - consider setting ARGOCD_TOKEN env var instead)")
227227
runCmd.Flags().BoolVar(&cfg.DryRun, "dry-run", false, "run in dry-run mode. If set to true, do not perform any changes")
228-
runCmd.Flags().DurationVar(&cfg.CheckInterval, "interval", 2*time.Minute, "interval for how often to check for updates")
228+
runCmd.Flags().DurationVar(&cfg.CheckInterval, "interval", env.GetDurationVal("IMAGE_UPDATER_INTERVAL", 2*time.Minute), "interval for how often to check for updates")
229229
runCmd.Flags().StringVar(&cfg.LogLevel, "loglevel", env.GetStringVal("IMAGE_UPDATER_LOGLEVEL", "info"), "set the loglevel to one of trace|debug|info|warn|error")
230230
runCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "full path to kubernetes client configuration, i.e. ~/.kube/config")
231231
runCmd.Flags().IntVar(&cfg.HealthPort, "health-port", 8080, "port to start the health server on, 0 to disable")

cmd/run_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"os"
55
"testing"
6+
"time"
67

78
"github.com/stretchr/testify/assert"
89

@@ -23,7 +24,7 @@ func TestNewRunCommand(t *testing.T) {
2324
asser.Equal(env.GetStringVal("ARGOCD_PLAINTEXT", "false"), runCmd.Flag("argocd-plaintext").Value.String())
2425
asser.Equal("", runCmd.Flag("argocd-auth-token").Value.String())
2526
asser.Equal("false", runCmd.Flag("dry-run").Value.String())
26-
asser.Equal("2m0s", runCmd.Flag("interval").Value.String())
27+
asser.Equal(env.GetDurationVal("IMAGE_UPDATER_INTERVAL", 2*time.Minute).String(), runCmd.Flag("interval").Value.String())
2728
asser.Equal(env.GetStringVal("IMAGE_UPDATER_LOGLEVEL", "info"), runCmd.Flag("loglevel").Value.String())
2829
asser.Equal("", runCmd.Flag("kubeconfig").Value.String())
2930
asser.Equal("8080", runCmd.Flag("health-port").Value.String())

docs/install/reference.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ is given, milliseconds will be assumed. If set to `0`, ArgoCD Image Updater
9494
will exit after the first run, effectively disabling the interval. Default
9595
value is `2m0s`.
9696

97+
Can also be set using the *IMAGE_UPDATER_INTERVAL* environment variable.
98+
The `--interval` flag takes precedence over the `IMAGE_UPDATER_INTERVAL` environment variable.
99+
100+
The order of precedence for determining the update interval is as follows:
101+
102+
1. **`--interval` flag:** If the `--interval` command-line flag is provided, its value will be used.
103+
2. **`IMAGE_UPDATER_INTERVAL` environment variable:** If the `--interval` flag is not set, the value of the `IMAGE_UPDATER_INTERVAL` environment variable will be used.
104+
3. **Default value:** If neither the `--interval` flag nor the `IMAGE_UPDATER_INTERVAL` environment variable is set, the default value will be used.
105+
97106
**--kubeconfig *path* **
98107

99108
Specify the Kubernetes client config file to use when running outside a

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/argoproj-labs/argocd-image-updater
33
go 1.23.5
44

55
require (
6-
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.1.0
6+
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250421211119-90959ebfd519
77
github.com/argoproj/argo-cd/v2 v2.13.6
88
github.com/argoproj/gitops-engine v0.7.1-0.20250129155113-4c6e03c46314
99
github.com/argoproj/pkg v0.13.7-0.20230627120311-a4dd357b057e
@@ -111,7 +111,7 @@ require (
111111
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
112112
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
113113
github.com/opencontainers/go-digest v1.0.0 // indirect
114-
github.com/opencontainers/image-spec v1.1.0 // indirect
114+
github.com/opencontainers/image-spec v1.1.1 // indirect
115115
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
116116
github.com/pjbgf/sha1cd v0.3.2 // indirect
117117
github.com/pkg/errors v0.9.1 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQ
2727
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
2828
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
2929
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
30-
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.1.0 h1:rmDEfeamrRPB/HCah+LQl0OGmkzggUzIPrKMDbiqSPY=
31-
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.1.0/go.mod h1:/WY/g4x5PSJlWeKcIx36LXQ2Ds3wR+KS9zJjtIPH+pk=
30+
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250421211119-90959ebfd519 h1:URnrR3+5zLMkj2o10MbSE0aocgxBAUHtXKQo9cUiAro=
31+
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250421211119-90959ebfd519/go.mod h1:5kPCfISgNKi7q1bKdf35qP7AAJuNy35E8cqA1NeT5AU=
3232
github.com/argoproj/argo-cd/v2 v2.13.6 h1:AoOaNidqkGgnH/prgbLp5PyFxBU0UGJUGdXJw+UDvqM=
3333
github.com/argoproj/argo-cd/v2 v2.13.6/go.mod h1:+PE6B/sg2+vq7/WFMvc+eK3hVRnQNNYcExZKLqfXRyU=
3434
github.com/argoproj/gitops-engine v0.7.1-0.20250129155113-4c6e03c46314 h1:UIM6b4b/eNmWLwnsaJNmLzcm0qjHCuyHTuJKeIq2WeE=
@@ -395,8 +395,8 @@ github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
395395
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
396396
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
397397
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
398-
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
399-
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
398+
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
399+
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
400400
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
401401
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
402402
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=

manifests/base/deployment/argocd-image-updater-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ spec:
5959
name: argocd-image-updater-secret
6060
key: argocd.token
6161
optional: true
62+
- name: IMAGE_UPDATER_INTERVAL
63+
valueFrom:
64+
configMapKeyRef:
65+
key: interval
66+
name: argocd-image-updater-config
67+
optional: true
6268
- name: IMAGE_UPDATER_LOGLEVEL
6369
valueFrom:
6470
configMapKeyRef:

manifests/install.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ spec:
167167
key: argocd.token
168168
name: argocd-image-updater-secret
169169
optional: true
170+
- name: IMAGE_UPDATER_INTERVAL
171+
valueFrom:
172+
configMapKeyRef:
173+
key: interval
174+
name: argocd-image-updater-config
175+
optional: true
170176
- name: IMAGE_UPDATER_LOGLEVEL
171177
valueFrom:
172178
configMapKeyRef:

0 commit comments

Comments
 (0)