1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 07:26:55 +00:00

fix: missing/incorrect env variables (#7383)

* fix: panic if an env variable is missing

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-06-02 11:19:18 +02:00 committed by GitHub
parent f540006aa0
commit 5ebb37fd44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View file

@ -98,6 +98,8 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
- name: INIT_CONFIG
value: {{ template "kyverno.config.configMapName" . }}
- name: METRICS_CONFIG
value: {{ template "kyverno.config.metricsConfigMapName" . }}
- name: KYVERNO_NAMESPACE
@ -109,7 +111,9 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: KYVERNO_DEPLOYMENT
value: {{ template "kyverno.fullname" . }}
value: {{ template "kyverno.admission-controller.name" . }}
- name: KYVERNO_SVC
value: {{ template "kyverno.admission-controller.serviceName" . }}
{{- with .Values.admissionController.initContainer.extraEnvVars }}
{{- toYaml . | nindent 10 }}
{{- end }}

View file

@ -37255,6 +37255,8 @@ spec:
seccompProfile:
type: RuntimeDefault
env:
- name: INIT_CONFIG
value: kyverno
- name: METRICS_CONFIG
value: kyverno-metrics
- name: KYVERNO_NAMESPACE
@ -37266,7 +37268,9 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: KYVERNO_DEPLOYMENT
value: kyverno
value: kyverno-admission-controller
- name: KYVERNO_SVC
value: kyverno-svc
containers:
- name: kyverno
image: "ghcr.io/kyverno/kyverno:latest"

View file

@ -1,6 +1,9 @@
package os
import "os"
import (
"fmt"
"os"
)
func GetEnvWithFallback(name, fallback string) string {
if value := os.Getenv(name); value != "" {
@ -8,3 +11,10 @@ func GetEnvWithFallback(name, fallback string) string {
}
return fallback
}
func MustGetEnv(name string) string {
if value := os.Getenv(name); value != "" {
return value
}
panic(fmt.Sprintf("environment variable `%s` is required.", name))
}