Repository: argoproj-labs/argocd-image-updater

Issue:
Support setting `--interval` via env variable
**Is your feature request related to a problem? Please describe.**
At the moment, setting the check interval requires editing the `spec.containers.args` setting in the Deployment for `argocd-image-updater`. It would be more convenient to be able to update this using the `ConfigMap`

**Describe the solution you'd like**
Many settings are currently settable via environment variables:

https://github.com/argoproj-labs/argocd-image-updater/blob/b2472651c1a75399499d60d9d69e0b05d9f1074c/cmd/run.go#L221-L247

_However_, this particular setting is only available as a command line parameter to the argocd-image-updater binary:

https://github.com/argoproj-labs/argocd-image-updater/blob/b2472651c1a75399499d60d9d69e0b05d9f1074c/cmd/run.go#L228

The reason why it would be good to have this be settable using an environment variable is that we can then use a `ConfigMap` to edit it, like we do with other environment variables: https://github.com/argoproj-labs/argocd-image-updater/blob/master/manifests/install.yaml. This would make it much easier to customize the interval when needed.

**Describe alternatives you've considered**
None than I can think of, apart from editing the deployment manually - perhaps using Kustomize to modify the manifest when installing argocd-image-updater or something?


Hints from issue comments:
@chengfang: This does sound like a great enhancement. Are you interested in contributing the fix and tests? If so feel free to send the PR.@chengfang: @dkarpele please take a look.@perlun: Sorry for the lack of replies from my end @chengfang, great to see that this has now been added. Appreciated! 🎉🙇 

Solution patch:
diff --git a/cmd/run.go b/cmd/run.go
index cd7264b..947a29b 100644
--- a/cmd/run.go
+++ b/cmd/run.go
@@ -225,7 +225,7 @@ func newRunCommand() *cobra.Command {
 	runCmd.Flags().BoolVar(&cfg.ClientOpts.Plaintext, "argocd-plaintext", env.GetBoolVal("ARGOCD_PLAINTEXT", false), "(INSECURE) connect without TLS to ArgoCD server")
 	runCmd.Flags().StringVar(&cfg.ClientOpts.AuthToken, "argocd-auth-token", "", "use token for authenticating to ArgoCD (unsafe - consider setting ARGOCD_TOKEN env var instead)")
 	runCmd.Flags().BoolVar(&cfg.DryRun, "dry-run", false, "run in dry-run mode. If set to true, do not perform any changes")
-	runCmd.Flags().DurationVar(&cfg.CheckInterval, "interval", 2*time.Minute, "interval for how often to check for updates")
+	runCmd.Flags().DurationVar(&cfg.CheckInterval, "interval", env.GetDurationVal("IMAGE_UPDATER_INTERVAL", 2*time.Minute), "interval for how often to check for updates")
 	runCmd.Flags().StringVar(&cfg.LogLevel, "loglevel", env.GetStringVal("IMAGE_UPDATER_LOGLEVEL", "info"), "set the loglevel to one of trace|debug|info|warn|error")
 	runCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "full path to kubernetes client configuration, i.e. ~/.kube/config")
 	runCmd.Flags().IntVar(&cfg.HealthPort, "health-port", 8080, "port to start the health server on, 0 to disable")
diff --git a/docs/install/reference.md b/docs/install/reference.md
index 82952c3..f86491c 100644
--- a/docs/install/reference.md
+++ b/docs/install/reference.md
@@ -94,6 +94,15 @@ is given, milliseconds will be assumed. If set to `0`, ArgoCD Image Updater
 will exit after the first run, effectively disabling the interval. Default
 value is `2m0s`.
 
+Can also be set using the *IMAGE_UPDATER_INTERVAL* environment variable.
+The `--interval` flag takes precedence over the `IMAGE_UPDATER_INTERVAL` environment variable.
+
+The order of precedence for determining the update interval is as follows:
+
+1.  **`--interval` flag:** If the `--interval` command-line flag is provided, its value will be used.
+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.
+3.  **Default value:** If neither the `--interval` flag nor the `IMAGE_UPDATER_INTERVAL` environment variable is set, the default value will be used.
+
 **--kubeconfig *path* **
 
 Specify the Kubernetes client config file to use when running outside a
diff --git a/go.mod b/go.mod
index 660c7a7..95f038c 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/argoproj-labs/argocd-image-updater
 go 1.23.5
 
 require (
-	github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.1.0
+	github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250421211119-90959ebfd519
 	github.com/argoproj/argo-cd/v2 v2.13.6
 	github.com/argoproj/gitops-engine v0.7.1-0.20250129155113-4c6e03c46314
 	github.com/argoproj/pkg v0.13.7-0.20230627120311-a4dd357b057e
@@ -111,7 +111,7 @@ require (
 	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 	github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
 	github.com/opencontainers/go-digest v1.0.0 // indirect
-	github.com/opencontainers/image-spec v1.1.0 // indirect
+	github.com/opencontainers/image-spec v1.1.1 // indirect
 	github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
 	github.com/pjbgf/sha1cd v0.3.2 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
diff --git a/go.sum b/go.sum
index 58cebfb..55ea33f 100644
--- a/go.sum
+++ b/go.sum
@@ -27,8 +27,8 @@ github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQ
 github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
 github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
 github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
-github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.1.0 h1:rmDEfeamrRPB/HCah+LQl0OGmkzggUzIPrKMDbiqSPY=
-github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.1.0/go.mod h1:/WY/g4x5PSJlWeKcIx36LXQ2Ds3wR+KS9zJjtIPH+pk=
+github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250421211119-90959ebfd519 h1:URnrR3+5zLMkj2o10MbSE0aocgxBAUHtXKQo9cUiAro=
+github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250421211119-90959ebfd519/go.mod h1:5kPCfISgNKi7q1bKdf35qP7AAJuNy35E8cqA1NeT5AU=
 github.com/argoproj/argo-cd/v2 v2.13.6 h1:AoOaNidqkGgnH/prgbLp5PyFxBU0UGJUGdXJw+UDvqM=
 github.com/argoproj/argo-cd/v2 v2.13.6/go.mod h1:+PE6B/sg2+vq7/WFMvc+eK3hVRnQNNYcExZKLqfXRyU=
 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=
 github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
 github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
-github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
-github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
+github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
+github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
 github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
 github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
 github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
diff --git a/manifests/base/deployment/argocd-image-updater-deployment.yaml b/manifests/base/deployment/argocd-image-updater-deployment.yaml
index 842dffb..851795f 100644
--- a/manifests/base/deployment/argocd-image-updater-deployment.yaml
+++ b/manifests/base/deployment/argocd-image-updater-deployment.yaml
@@ -59,6 +59,12 @@ spec:
               name: argocd-image-updater-secret
               key: argocd.token
               optional: true
+        - name: IMAGE_UPDATER_INTERVAL
+          valueFrom:
+            configMapKeyRef:
+              key: interval
+              name: argocd-image-updater-config
+              optional: true
         - name: IMAGE_UPDATER_LOGLEVEL
           valueFrom:
             configMapKeyRef:
diff --git a/manifests/install.yaml b/manifests/install.yaml
index 49b2ce8..170d153 100644
--- a/manifests/install.yaml
+++ b/manifests/install.yaml
@@ -167,6 +167,12 @@ spec:
               key: argocd.token
               name: argocd-image-updater-secret
               optional: true
+        - name: IMAGE_UPDATER_INTERVAL
+          valueFrom:
+            configMapKeyRef:
+              key: interval
+              name: argocd-image-updater-config
+              optional: true
         - name: IMAGE_UPDATER_LOGLEVEL
           valueFrom:
             configMapKeyRef:



Test patch:
diff --git a/cmd/run_test.go b/cmd/run_test.go
index ee8af5a..11aa4ee 100644
--- a/cmd/run_test.go
+++ b/cmd/run_test.go
@@ -3,6 +3,7 @@ package main
 import (
 	"os"
 	"testing"
+	"time"
 
 	"github.com/stretchr/testify/assert"
 
@@ -23,7 +24,7 @@ func TestNewRunCommand(t *testing.T) {
 	asser.Equal(env.GetStringVal("ARGOCD_PLAINTEXT", "false"), runCmd.Flag("argocd-plaintext").Value.String())
 	asser.Equal("", runCmd.Flag("argocd-auth-token").Value.String())
 	asser.Equal("false", runCmd.Flag("dry-run").Value.String())
-	asser.Equal("2m0s", runCmd.Flag("interval").Value.String())
+	asser.Equal(env.GetDurationVal("IMAGE_UPDATER_INTERVAL", 2*time.Minute).String(), runCmd.Flag("interval").Value.String())
 	asser.Equal(env.GetStringVal("IMAGE_UPDATER_LOGLEVEL", "info"), runCmd.Flag("loglevel").Value.String())
 	asser.Equal("", runCmd.Flag("kubeconfig").Value.String())
 	asser.Equal("8080", runCmd.Flag("health-port").Value.String())