From 75def656fbcb67e938ddebfcea83d6d3e577c969 Mon Sep 17 00:00:00 2001 From: Zheng Xi Zhou Date: Mon, 25 Apr 2022 13:58:22 +0800 Subject: [PATCH] Fix: public image registry config could not be created (#3736) Fix #3663 Signed-off-by: Zheng Xi Zhou --- .../config-image-registry.yaml | 29 ++++++++++--------- .../config-image-registry.yaml | 29 ++++++++++--------- .../component/config-image-registry.cue | 11 +++++-- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/charts/vela-core/templates/defwithtemplate/config-image-registry.yaml b/charts/vela-core/templates/defwithtemplate/config-image-registry.yaml index 53cc3a25f..d93687a2a 100644 --- a/charts/vela-core/templates/defwithtemplate/config-image-registry.yaml +++ b/charts/vela-core/templates/defwithtemplate/config-image-registry.yaml @@ -36,20 +36,23 @@ spec: "config.oam.dev/sub-type": "auth" } } - type: "kubernetes.io/dockerconfigjson" - stringData: { - if parameter.auth != _|_ { - ".dockerconfigjson": json.Marshal({ - auths: "\(parameter.registry)": { - username: parameter.auth.username - password: parameter.auth.password - if parameter.auth.email != _|_ { - email: parameter.auth.email - } - auth: base64.Encode(null, (parameter.auth.username + ":" + parameter.auth.password)) + if parameter.auth != _|_ { + type: "kubernetes.io/dockerconfigjson" + } + if parameter.auth == _|_ { + type: "Opaque" + } + if parameter.auth != _|_ { + stringData: ".dockerconfigjson": json.Marshal({ + auths: "\(parameter.registry)": { + username: parameter.auth.username + password: parameter.auth.password + if parameter.auth.email != _|_ { + email: parameter.auth.email } - }) - } + auth: base64.Encode(null, (parameter.auth.username + ":" + parameter.auth.password)) + } + }) } } parameter: { diff --git a/charts/vela-minimal/templates/defwithtemplate/config-image-registry.yaml b/charts/vela-minimal/templates/defwithtemplate/config-image-registry.yaml index 53cc3a25f..d93687a2a 100644 --- a/charts/vela-minimal/templates/defwithtemplate/config-image-registry.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/config-image-registry.yaml @@ -36,20 +36,23 @@ spec: "config.oam.dev/sub-type": "auth" } } - type: "kubernetes.io/dockerconfigjson" - stringData: { - if parameter.auth != _|_ { - ".dockerconfigjson": json.Marshal({ - auths: "\(parameter.registry)": { - username: parameter.auth.username - password: parameter.auth.password - if parameter.auth.email != _|_ { - email: parameter.auth.email - } - auth: base64.Encode(null, (parameter.auth.username + ":" + parameter.auth.password)) + if parameter.auth != _|_ { + type: "kubernetes.io/dockerconfigjson" + } + if parameter.auth == _|_ { + type: "Opaque" + } + if parameter.auth != _|_ { + stringData: ".dockerconfigjson": json.Marshal({ + auths: "\(parameter.registry)": { + username: parameter.auth.username + password: parameter.auth.password + if parameter.auth.email != _|_ { + email: parameter.auth.email } - }) - } + auth: base64.Encode(null, (parameter.auth.username + ":" + parameter.auth.password)) + } + }) } } parameter: { diff --git a/vela-templates/definitions/internal/component/config-image-registry.cue b/vela-templates/definitions/internal/component/config-image-registry.cue index 2133ebdf9..eb2915d5f 100644 --- a/vela-templates/definitions/internal/component/config-image-registry.cue +++ b/vela-templates/definitions/internal/component/config-image-registry.cue @@ -33,9 +33,14 @@ template: { "config.oam.dev/sub-type": "auth" } } - type: "kubernetes.io/dockerconfigjson" - stringData: { - if parameter.auth != _|_ { + if parameter.auth != _|_ { + type: "kubernetes.io/dockerconfigjson" + } + if parameter.auth == _|_ { + type: "Opaque" + } + if parameter.auth != _|_ { + stringData: { ".dockerconfigjson": json.Marshal({ "auths": "\(parameter.registry)": { "username": parameter.auth.username