Skip to content

Commit aaf77af

Browse files
tomjotomjo
and
tomjo
authored
fix: Use image configured in spec as fallback before default image for repository server workload (#1262)
* fix: Use image configured in spec as fallback before default image for repository server workload Signed-off-by: tomjo <[email protected]> * docs: remove unused ARGOCD_REPOSERVER_IMAGE references and update .spec.repo.version docs with fallback information Signed-off-by: tomjo <[email protected]> * fix: configuration order comment Signed-off-by: tomjo <[email protected]> --------- Signed-off-by: tomjo <[email protected]> Co-authored-by: tomjo <[email protected]>
1 parent c62c712 commit aaf77af

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

common/keys.go

-4
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ const (
121121
// ArgoCDKeyResourceTrackingMethod is the configuration key for resource tracking method
122122
ArgoCDKeyResourceTrackingMethod = "application.resourceTrackingMethod"
123123

124-
// ArgoCDRepoImageEnvName is the environment variable used to get the image
125-
// to used for the Dex container.
126-
ArgoCDRepoImageEnvName = "ARGOCD_REPOSERVER_IMAGE"
127-
128124
// ArgoCDKeyRepositories is the configuration key for repositories.
129125
ArgoCDKeyRepositories = "repositories"
130126

controllers/argocd/util.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -200,27 +200,35 @@ func getArgoContainerImage(cr *argoproj.ArgoCD) string {
200200

201201
// getRepoServerContainerImage will return the container image for the Repo server.
202202
//
203-
// There are three possible options for configuring the image, and this is the
203+
// There are four possible options for configuring the image, and this is the
204204
// order of preference.
205205
//
206206
// 1. from the Spec, the spec.repo field has an image and version to use for
207207
// generating an image reference.
208-
// 2. from the Environment, this looks for the `ARGOCD_REPOSERVER_IMAGE` field and uses
208+
// 2. from the Spec, the spec.version field has an image and version to use for
209+
// generating an image reference
210+
// 3. from the Environment, this looks for the `ARGOCD_IMAGE` field and uses
209211
// that if the spec is not configured.
210-
// 3. the default is configured in common.ArgoCDDefaultRepoServerVersion and
211-
// common.ArgoCDDefaultRepoServerImage.
212+
// 4. the default is configured in common.ArgoCDDefaultArgoVersion and
213+
// common.ArgoCDDefaultArgoImage.
212214
func getRepoServerContainerImage(cr *argoproj.ArgoCD) string {
213215
defaultImg, defaultTag := false, false
214216
img := cr.Spec.Repo.Image
215217
if img == "" {
216-
img = common.ArgoCDDefaultArgoImage
217-
defaultImg = true
218+
img = cr.Spec.Image
219+
if img == "" {
220+
img = common.ArgoCDDefaultArgoImage
221+
defaultImg = true
222+
}
218223
}
219224

220225
tag := cr.Spec.Repo.Version
221226
if tag == "" {
222-
tag = common.ArgoCDDefaultArgoVersion
223-
defaultTag = true
227+
tag = cr.Spec.Version
228+
if tag == "" {
229+
tag = common.ArgoCDDefaultArgoVersion
230+
defaultTag = true
231+
}
224232
}
225233
if e := os.Getenv(common.ArgoCDImageEnvName); e != "" && (defaultTag && defaultImg) {
226234
return e

controllers/argocd/util_test.go

+35-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ import (
2525
)
2626

2727
const (
28-
dexTestImage = "testing/dex:latest"
29-
argoTestImage = "testing/argocd:latest"
30-
redisTestImage = "testing/redis:latest"
31-
redisHATestImage = "testing/redis:latest-ha"
32-
redisHAProxyTestImage = "testing/redis-ha-haproxy:latest-ha"
28+
dexTestImage = "testing/dex:latest"
29+
argoTestImage = "testing/argocd:latest"
30+
argoTestImageOtherVersion = "testing/argocd:test"
31+
redisTestImage = "testing/redis:latest"
32+
redisHATestImage = "testing/redis:latest-ha"
33+
redisHAProxyTestImage = "testing/redis-ha-haproxy:latest-ha"
3334
)
3435

3536
func parallelismLimit(n int32) argoCDOpt {
@@ -111,6 +112,35 @@ var imageTests = []struct {
111112
t.Setenv(common.ArgoCDImageEnvName, argoTestImage)
112113
},
113114
},
115+
{
116+
name: "repo default configuration",
117+
imageFunc: getRepoServerContainerImage,
118+
want: argoutil.CombineImageTag(common.ArgoCDDefaultArgoImage, common.ArgoCDDefaultArgoVersion),
119+
},
120+
{
121+
name: "repo spec configuration",
122+
imageFunc: getRepoServerContainerImage,
123+
want: argoTestImage, opts: []argoCDOpt{func(a *argoproj.ArgoCD) {
124+
a.Spec.Repo.Image = "testing/argocd"
125+
a.Spec.Repo.Version = "latest"
126+
}},
127+
},
128+
{
129+
name: "repo configuration fallback spec",
130+
imageFunc: getRepoServerContainerImage,
131+
want: argoTestImageOtherVersion, opts: []argoCDOpt{func(a *argoproj.ArgoCD) {
132+
a.Spec.Image = "testing/argocd"
133+
a.Spec.Version = "test"
134+
}},
135+
},
136+
{
137+
name: "argo env configuration",
138+
imageFunc: getRepoServerContainerImage,
139+
want: argoTestImage,
140+
pre: func(t *testing.T) {
141+
t.Setenv(common.ArgoCDImageEnvName, argoTestImage)
142+
},
143+
},
114144
{
115145
name: "redis default configuration",
116146
imageFunc: getRedisContainerImage,

docs/reference/argocd.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,8 @@ MountSAToken | false | Whether the ServiceAccount token should be mounted to the
840840
ServiceAccount | "" | The name of the ServiceAccount to use with the repo-server pod.
841841
VerifyTLS | false | Whether to enforce strict TLS checking on all components when communicating with repo server
842842
AutoTLS | "" | Provider to use for setting up TLS the repo-server's gRPC TLS certificate (one of: `openshift`). Currently only available for OpenShift.
843-
Image | `argoproj/argocd` | The container image for ArgoCD Repo Server. This overrides the `ARGOCD_REPOSERVER_IMAGE` environment variable.
844-
Version | same as `.spec.Version` | The tag to use with the ArgoCD Repo Server.
843+
Image | `argoproj/argocd` | The container image for ArgoCD Repo Server. This overrides the `ARGOCD_IMAGE` environment variable for the repo server.
844+
Version | same as `.spec.Version` | The tag to use with the ArgoCD Repo Server. Fallsback to `.spec.Version` and the default image version in that order if not specified.
845845
LogLevel | info | The log level to be used by the ArgoCD Repo Server. Valid options are debug, info, error, and warn.
846846
LogFormat | text | The log format to be used by the ArgoCD Repo Server. Valid options are text or json.
847847
ExecTimeout | 180 | Execution timeout in seconds for rendering tools (e.g. Helm, Kustomize)

docs/usage/environment_variables.md

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ The following default value of images could be overridden by setting the environ
3232
| Environment Variable | Default Value |
3333
| --- | --- |
3434
| `ARGOCD_IMAGE` | [quay.io/argoproj/argocd](quay.io/argoproj/argocd) |
35-
| `ARGOCD_REPOSERVER_IMAGE` | [quay.io/argoproj/argocd](quay.io/argoproj/argocd) |
3635
| `ARGOCD_DEX_IMAGE` | [ghcr.io/dexidp/dex](ghcr.io/dexidp/dex) |
3736
| `ARGOCD_KEYCLOAK_IMAGE` | [quay.io/keycloak/keycloak](quay.io/keycloak/keycloak) |
3837
| `ARGOCD_REDIS_IMAGE` | redis |

0 commit comments

Comments
 (0)