From e7d3d58337f0ff5a6037c9c8c19878c16ca8c40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Casta=C3=B1o=20Arteaga?= Date: Tue, 8 Jul 2025 11:08:26 +0200 Subject: [PATCH] Allow setting extra env vars from chart (#4448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergio CastaƱo Arteaga --- charts/artifact-hub/Chart.yaml | 2 +- .../artifact-hub/templates/hub_deployment.yaml | 7 ++++++- .../templates/scanner_cronjob.yaml | 7 ++++++- .../templates/tracker_cronjob.yaml | 7 ++++++- charts/artifact-hub/values-staging.yaml | 3 +++ charts/artifact-hub/values.schema.json | 18 ++++++++++++++++++ charts/artifact-hub/values.yaml | 6 ++++++ 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/charts/artifact-hub/Chart.yaml b/charts/artifact-hub/Chart.yaml index d134cc94..9ac7b839 100644 --- a/charts/artifact-hub/Chart.yaml +++ b/charts/artifact-hub/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: artifact-hub description: Artifact Hub is a web-based application that enables finding, installing, and publishing Cloud Native packages. type: application -version: 1.21.1-0 +version: 1.21.1-1 appVersion: 1.21.0 kubeVersion: ">= 1.19.0-0" home: https://artifacthub.io diff --git a/charts/artifact-hub/templates/hub_deployment.yaml b/charts/artifact-hub/templates/hub_deployment.yaml index e3450164..b2dd2037 100644 --- a/charts/artifact-hub/templates/hub_deployment.yaml +++ b/charts/artifact-hub/templates/hub_deployment.yaml @@ -70,10 +70,15 @@ spec: securityContext: {{- toYaml . | nindent 12 }} {{- end }} - {{- if .Values.hub.server.cacheDir }} + {{- if or .Values.hub.server.cacheDir .Values.hub.deploy.extraEnvVars }} env: + {{- if .Values.hub.server.cacheDir }} - name: XDG_CACHE_HOME value: {{ .Values.hub.server.cacheDir | quote }} + {{- end }} + {{- if .Values.hub.deploy.extraEnvVars }} + {{- include "chart.tplvalues.render" (dict "value" .Values.hub.deploy.extraEnvVars "context" $) | nindent 12 }} + {{- end }} {{- end }} volumeMounts: - name: hub-config diff --git a/charts/artifact-hub/templates/scanner_cronjob.yaml b/charts/artifact-hub/templates/scanner_cronjob.yaml index 13888493..aa7d119e 100644 --- a/charts/artifact-hub/templates/scanner_cronjob.yaml +++ b/charts/artifact-hub/templates/scanner_cronjob.yaml @@ -55,10 +55,15 @@ spec: resources: {{- toYaml . | nindent 16 }} {{- end }} - {{- if .Values.scanner.cacheDir }} + {{- if or .Values.scanner.cacheDir .Values.scanner.cronjob.extraEnvVars }} env: + {{- if .Values.scanner.cacheDir }} - name: TRIVY_CACHE_DIR value: {{ .Values.scanner.cacheDir | quote }} + {{- end }} + {{- if .Values.scanner.cronjob.extraEnvVars }} + {{- include "chart.tplvalues.render" (dict "value" .Values.scanner.cronjob.extraEnvVars "context" $) | nindent 16 }} + {{- end }} {{- end }} volumeMounts: - name: scanner-config diff --git a/charts/artifact-hub/templates/tracker_cronjob.yaml b/charts/artifact-hub/templates/tracker_cronjob.yaml index cd87dda6..df5edd32 100644 --- a/charts/artifact-hub/templates/tracker_cronjob.yaml +++ b/charts/artifact-hub/templates/tracker_cronjob.yaml @@ -54,10 +54,15 @@ spec: resources: {{- toYaml . | nindent 16 }} {{- end }} - {{- if .Values.tracker.cacheDir }} + {{- if or .Values.tracker.cacheDir .Values.tracker.cronjob.extraEnvVars }} env: + {{- if .Values.tracker.cacheDir }} - name: XDG_CACHE_HOME value: {{ .Values.tracker.cacheDir | quote }} + {{- end }} + {{- if .Values.tracker.cronjob.extraEnvVars }} + {{- include "chart.tplvalues.render" (dict "value" .Values.tracker.cronjob.extraEnvVars "context" $) | nindent 16 }} + {{- end }} {{- end }} volumeMounts: - name: tracker-config diff --git a/charts/artifact-hub/values-staging.yaml b/charts/artifact-hub/values-staging.yaml index 7b327dfa..689e257f 100644 --- a/charts/artifact-hub/values-staging.yaml +++ b/charts/artifact-hub/values-staging.yaml @@ -41,6 +41,9 @@ hub: requests: cpu: 1 memory: 1000Mi + extraEnvVars: + - name: KEY1 + value: VALUE1 server: bannersURL: https://cncf.github.io/banners/banners.yml baseURL: https://staging.artifacthub.io diff --git a/charts/artifact-hub/values.schema.json b/charts/artifact-hub/values.schema.json index c434482e..e535d5f7 100644 --- a/charts/artifact-hub/values.schema.json +++ b/charts/artifact-hub/values.schema.json @@ -305,6 +305,12 @@ "type": "array", "default": "[]" }, + "extraEnvVars": { + "title": "Extra environment variables", + "description": "Optionally specify extra list of additional environment variables for the hub container", + "type": "array", + "default": "[]" + }, "image": { "type": "object", "properties": { @@ -1047,6 +1053,12 @@ "type": "array", "default": "[]" }, + "extraEnvVars": { + "title": "Extra environment variables", + "description": "Optionally specify extra list of additional environment variables for the scanner container", + "type": "array", + "default": "[]" + }, "image": { "type": "object", "properties": { @@ -1171,6 +1183,12 @@ "type": "array", "default": "[]" }, + "extraEnvVars": { + "title": "Extra environment variables", + "description": "Optionally specify extra list of additional environment variables for the tracker container", + "type": "array", + "default": "[]" + }, "image": { "type": "object", "properties": { diff --git a/charts/artifact-hub/values.yaml b/charts/artifact-hub/values.yaml index 6268f638..2f6c3acc 100644 --- a/charts/artifact-hub/values.yaml +++ b/charts/artifact-hub/values.yaml @@ -192,6 +192,8 @@ hub: nodeSelector: {} # Optionally specify extra list of additional containers for the hub deployment extraContainers: [] + # Optionally specify extra list of additional environment variables for the hub container + extraEnvVars: [] server: # Allow adding private repositories to the Hub allowPrivateRepositories: false @@ -338,6 +340,8 @@ scanner: extraVolumes: [] # Optionally specify extra list of additional volume mounts for the scanner cronjob extraVolumeMounts: [] + # Optionally specify extra list of additional environment variables for the scanner container + extraEnvVars: [] # Optionally specify a node selector for the scanner cronjob nodeSelector: {} # Number of snapshots to process concurrently @@ -376,6 +380,8 @@ tracker: extraVolumes: [] # Optionally specify extra list of additional volume mounts for the tracker cronjob extraVolumeMounts: [] + # Optionally specify extra list of additional environment variables for the tracker container + extraEnvVars: [] # Optionally specify a node selector for the tracker cronjob nodeSelector: {} # Cache directory path. If set, the cache directory for the Helm client will be explicitly set (otherwise defaults