-
Notifications
You must be signed in to change notification settings - Fork 182
feat: adding option for creating extra kubernetes resource #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughAdds support for rendering additional Kubernetes objects via Helm. Introduces a new template that processes .Values.extraObjects (strings or objects) into separate YAML documents using tpl. Updates values.yaml to include a new top-level extraObjects array with comments and an example, defaulting to an empty list. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Helm as Helm Renderer
participant Chart as holmes Chart
participant Template as templates/extra-objects.yaml
participant K8s as Kubernetes Manifests
User->>Helm: helm install/upgrade -f values.yaml
Helm->>Chart: Load values (.Values.extraObjects)
Helm->>Template: Render extra-objects.yaml with root context ($)
alt extraObjects item is string
Template->>Template: tpl(itemString, $)
else item is object
Template->>Template: toYaml(item) -> tpl(yamlString, $)
end
Template-->>Helm: Emit '---' delimited YAML docs
Helm-->>K8s: Output combined manifests
note over Template,K8s: Each extra object becomes its own YAML document
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
helm/holmes/values.yaml (1)
58-68: Docs: clarify accepted item formats + add a string-template exampleMention that items can be either fully-rendered YAML objects or string templates rendered via tpl, and add a short string-based example to avoid ambiguity.
Example docs tweak:
- Supports two formats:
- Object: a YAML object (apiVersion/kind/metadata/spec…)
- String: a templated manifest string rendered with tpl and the root context (.)
Example (string):
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "holmes.fullname" . }}-extras
namespace: {{ .Release.Namespace }}
data:
enabled: "{{ .Values.enableTelemetry }}"
helm/holmes/templates/extra-objects.yaml (1)
1-8: Skip empty/nil items to avoid emitting 'null' documentsWithout a guard, toYaml nil yields "null" and produces a bogus document.
Covered by the else-if $obj guard in the diff above.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
helm/holmes/templates/extra-objects.yaml(1 hunks)helm/holmes/values.yaml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
helm/holmes/templates/extra-objects.yaml
[error] 4-4: syntax error: expected '', but found '{'
(syntax)
[warning] 6-6: wrong indentation: expected 0 but found 4
(indentation)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: build (3.12)
- GitHub Check: build (3.10)
- GitHub Check: build (3.11)
- GitHub Check: llm_evals
🔇 Additional comments (1)
helm/holmes/templates/extra-objects.yaml (1)
1-8: Exclude Helm templates from yamllint
Add the following to your.yamllintto ignore Go templating inhelm/**/templates/**:extends: default ignore: | helm/**/templates/**Please verify locally that
helm template ./helm/holmesstill produces valid YAML (e.g. viahelm template … | yq 'split("---") | length').
| {{ range .Values.extraObjects }} | ||
| --- | ||
| {{ if typeIs "string" . }} | ||
| {{- tpl . $ }} | ||
| {{- else }} | ||
| {{- tpl (toYaml .) $ }} | ||
| {{- end }} | ||
| {{ end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation + use kindIs; current output will be invalid YAML
The leading spaces before tpl emitters indent entire documents, breaking top-level YAML. Also, Helm commonly uses kindIs for type checks; typeIs is unreliable across Helm/Sprig versions.
Apply:
-{{ range .Values.extraObjects }}
----
-{{ if typeIs "string" . }}
- {{- tpl . $ }}
-{{- else }}
- {{- tpl (toYaml .) $ }}
-{{- end }}
-{{ end }}
+{{- if .Values.extraObjects }}
+{{- range $i, $obj := .Values.extraObjects }}
+---
+{{- if kindIs "string" $obj }}
+{{ tpl $obj $ }}
+{{- else if $obj }}
+{{ tpl (toYaml $obj) $ }}
+{{- end }}
+{{- end }}
+{{- end }}Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 4-4: syntax error: expected '', but found '{'
(syntax)
[warning] 6-6: wrong indentation: expected 0 but found 4
(indentation)
🤖 Prompt for AI Agents
In helm/holmes/templates/extra-objects.yaml lines 1-8, the current template
inserts leading spaces before the tpl calls which indents entire emitted
documents and breaks top-level YAML, and it uses typeIs which can be unreliable;
change typeIs "string" to kindIs "string" and remove the leading spaces so the
tpl outputs start at column 1 (keep the leading '---' separator at top-level),
calling tpl directly for string values and tpl(toYaml .) for non-strings so
emitted YAML documents are valid and not indented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DMSwimTech Did you see this comment from code rabbit?
Is it a real issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @DMSwimTech
Allowing users to add extra kubernetes resouces without the need to fork the helm chart internally.
Example scenarios: