diff --git a/helm/kagent/templates/modelconfig-secret.yaml b/helm/kagent/templates/modelconfig-secret.yaml index 804c90d6d..fc20bc5c0 100644 --- a/helm/kagent/templates/modelconfig-secret.yaml +++ b/helm/kagent/templates/modelconfig-secret.yaml @@ -1,5 +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 @@ -13,3 +16,5 @@ type: Opaque 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 fa8edd398..472beb7b1 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 }} @@ -31,7 +32,8 @@ spec: {{- toYaml $model.tls | nindent 4 }} {{- end }} {{- if $model.config }} - {{ $dot.Values.providers.default }}: + {{ $defaultProvider }}: {{- 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 88db33953..5252c6073 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 c85f28b55..b3100e4ed 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