feat(helm/kagent): allow disabling default modelconfig#2142
feat(helm/kagent): allow disabling default modelconfig#2142anthonyhaussman wants to merge 2 commits into
Conversation
49e6d16 to
9491256
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Helm chart’s default ModelConfig and Secret rendering so users can fully disable default model configuration generation by setting .Values.providers to null, and adds unit tests to validate the “render nothing” behavior.
Changes:
- Wrap
modelconfig.yamlandmodelconfig-secret.yamltemplates inif .Values.providersso they render no documents when providers isnull. - Add helm-unittest coverage ensuring both templates render
0documents whenproviders: null. - Minor whitespace cleanup in an existing test assertion value.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| helm/kagent/templates/modelconfig.yaml | Adds conditional guard around default ModelConfig rendering when providers is nil. |
| helm/kagent/templates/modelconfig-secret.yaml | Adds conditional guard around default Secret rendering when providers is nil. |
| helm/kagent/tests/modelconfig_test.yaml | Adds test asserting no documents rendered when providers: null. |
| helm/kagent/tests/modelconfig-secret_test.yaml | Adds test asserting no documents rendered when providers: null (and fixes trailing whitespace). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9491256 to
b006023
Compare
| {{- $defaultProvider := .Values.providers.default | default "openAI" }} | ||
| {{- if hasKey .Values.providers $defaultProvider }} | ||
| {{- $model := index .Values.providers $defaultProvider }} | ||
| {{- if and $model.apiKeySecretRef $model.apiKey }} |
There was a problem hiding this comment.
Won't this line already disable the rendering if these aren't set?
There was a problem hiding this comment.
The problem is that if providers.default points to a missing key, index returns nil.
Setting providers: {} value returns when trying to template:
Error: template: kagent/templates/modelconfig-secret.yaml:2:14: executing "kagent/templates/modelconfig-secret.yaml" at <index $dot.Values.providers $dot.Values.providers.default>: error calling index: value is nil; should be of type string
The check is necessary to prevent Helm from crashing.
b006023 to
6e89047
Compare
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 <anthony.hausman@backmarket.com>
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 <anthony.hausman@backmarket.com>
6e89047 to
9018a71
Compare
Wrap
modelconfigandmodelconfig-secrettemplates 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.