From 3f83378f01653f4df701517225b1934a5235b4ed Mon Sep 17 00:00:00 2001 From: WrenIX <133280015+wrenix@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:56:34 +0200 Subject: [PATCH] fix(chartutil): Create with seperated registry and repository Signed-off-by: WrenIX <133280015+wrenix@users.noreply.github.com> --- pkg/chartutil/create.go | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 30d0556e5..1d78def29 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -108,13 +108,30 @@ const defaultValues = `# Default values for %s. replicaCount: 1 +global: + image: + # if set it will overwrite all registry entries + registry: "" + # if set it will overwrite all pullPolicy + pullPolicy: + image: - repository: nginx + registry: docker.io + repository: library/nginx pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" imagePullSecrets: [] + +testConnection: + enabled: true + image: + registry: docker.io + repository: library/busybox + # default without any tag + tag: "" + nameOverride: "" fullnameOverride: "" @@ -326,8 +343,10 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.image }} + image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ coalesce .Values.global.image.pullPolicy .pullPolicy }} + {{- end }} ports: - name: http containerPort: {{ .Values.service.port }} @@ -518,7 +537,10 @@ Create the name of the service account to use {{- end }} ` -const defaultTestConnection = `apiVersion: v1 +const defaultTestConnection = `{{- with .Values.testConnection }} +{{- if .enabled }} +--- +apiVersion: v1 kind: Pod metadata: name: "{{ include ".fullname" . }}-test-connection" @@ -529,10 +551,15 @@ metadata: spec: containers: - name: wget - image: busybox + {{- with .image }} + image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}{{ if .tag }}{{ printf ":%s" .tag }}{{ end }} + imagePullPolicy: {{ coalesce $.Values.global.pullPolicy .pullPolicy }} + {{- end }} command: ['wget'] - args: ['{{ include ".fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include ".fullname" $ }}:{{ $.Values.service.port }}'] restartPolicy: Never +{{- end }}{{/* end-if enabled */}} +{{- end }}{{/* end-with testConnection*/}} ` // Stderr is an io.Writer to which error messages can be written