From 9e68d8199cde6a60e58a415802f9508dbaa0187e Mon Sep 17 00:00:00 2001 From: Anthony Hausman Date: Fri, 3 Jul 2026 11:21:16 +0200 Subject: [PATCH 1/2] feat(helm): allow disabling default modelconfig Wrap modelconfig and modelconfig-secret templates in a conditional check for .Values.providers. This allows users to completely disable the default modelconfig generation by setting providers to null. Add tests to verify that no documents are rendered when providers is null. Signed-off-by: Anthony Hausman --- helm/kagent/templates/modelconfig-secret.yaml | 2 ++ helm/kagent/templates/modelconfig.yaml | 2 ++ helm/kagent/tests/modelconfig-secret_test.yaml | 8 +++++++- helm/kagent/tests/modelconfig_test.yaml | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/helm/kagent/templates/modelconfig-secret.yaml b/helm/kagent/templates/modelconfig-secret.yaml index 804c90d6db..35d48159bd 100644 --- a/helm/kagent/templates/modelconfig-secret.yaml +++ b/helm/kagent/templates/modelconfig-secret.yaml @@ -1,3 +1,4 @@ +{{- if .Values.providers }} {{- $dot := . }} {{- $model := index $dot.Values.providers $dot.Values.providers.default }} {{- if and $model.apiKeySecretRef $model.apiKey }} @@ -13,3 +14,4 @@ type: Opaque data: {{ $model.apiKeySecretKey | default (printf "%s_API_KEY" $model.provider | upper) }}: {{ $model.apiKey | b64enc }} {{- end }} +{{- end }} diff --git a/helm/kagent/templates/modelconfig.yaml b/helm/kagent/templates/modelconfig.yaml index fa8edd398a..1f8f3a4184 100644 --- a/helm/kagent/templates/modelconfig.yaml +++ b/helm/kagent/templates/modelconfig.yaml @@ -1,3 +1,4 @@ +{{- if .Values.providers }} {{- $dot := . }} {{- $defaultProvider := .Values.providers.default | default "openAI" }} {{- if hasKey .Values.providers $defaultProvider | not }} @@ -35,3 +36,4 @@ spec: {{- toYaml $model.config | nindent 4 }} {{- end }} {{- end }} +{{- end }} diff --git a/helm/kagent/tests/modelconfig-secret_test.yaml b/helm/kagent/tests/modelconfig-secret_test.yaml index 88db339539..5252c60734 100644 --- a/helm/kagent/tests/modelconfig-secret_test.yaml +++ b/helm/kagent/tests/modelconfig-secret_test.yaml @@ -99,4 +99,10 @@ tests: asserts: - equal: path: metadata.namespace - value: custom-namespace \ No newline at end of file + value: custom-namespace + - it: should not render secret when providers is set to null + set: + providers: null + asserts: + - hasDocuments: + count: 0 diff --git a/helm/kagent/tests/modelconfig_test.yaml b/helm/kagent/tests/modelconfig_test.yaml index c85f28b55e..b3100e4ed2 100644 --- a/helm/kagent/tests/modelconfig_test.yaml +++ b/helm/kagent/tests/modelconfig_test.yaml @@ -137,3 +137,10 @@ tests: - equal: path: metadata.namespace value: custom-namespace + + - it: should not render modelconfig when providers is set to null + set: + providers: null + asserts: + - hasDocuments: + count: 0 From df077f79b63a6ac096df94f91e3e675093efa6aa Mon Sep 17 00:00:00 2001 From: Anthony Hausman Date: Fri, 3 Jul 2026 11:49:09 +0200 Subject: [PATCH 2/2] fix(helm): resolve missing provider key fallbacks in templates Adds fallback validation in modelconfig-secret.yaml to prevent nil pointer errors when providers.default is missing or invalid. Also fixes the config key in modelconfig.yaml to correctly render the defaultProvider string instead of the potentially omitted map key. Signed-off-by: Anthony Hausman --- helm/kagent/templates/modelconfig-secret.yaml | 5 ++++- helm/kagent/templates/modelconfig.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/helm/kagent/templates/modelconfig-secret.yaml b/helm/kagent/templates/modelconfig-secret.yaml index 35d48159bd..fc20bc5c05 100644 --- a/helm/kagent/templates/modelconfig-secret.yaml +++ b/helm/kagent/templates/modelconfig-secret.yaml @@ -1,6 +1,8 @@ {{- if .Values.providers }} {{- $dot := . }} -{{- $model := index $dot.Values.providers $dot.Values.providers.default }} +{{- $defaultProvider := .Values.providers.default | default "openAI" }} +{{- if hasKey .Values.providers $defaultProvider }} +{{- $model := index .Values.providers $defaultProvider }} {{- if and $model.apiKeySecretRef $model.apiKey }} --- apiVersion: v1 @@ -15,3 +17,4 @@ data: {{ $model.apiKeySecretKey | default (printf "%s_API_KEY" $model.provider | upper) }}: {{ $model.apiKey | b64enc }} {{- end }} {{- end }} +{{- end }} diff --git a/helm/kagent/templates/modelconfig.yaml b/helm/kagent/templates/modelconfig.yaml index 1f8f3a4184..472beb7b14 100644 --- a/helm/kagent/templates/modelconfig.yaml +++ b/helm/kagent/templates/modelconfig.yaml @@ -32,7 +32,7 @@ spec: {{- toYaml $model.tls | nindent 4 }} {{- end }} {{- if $model.config }} - {{ $dot.Values.providers.default }}: + {{ $defaultProvider }}: {{- toYaml $model.config | nindent 4 }} {{- end }} {{- end }}