Skip to content

kubernetes-ingress: add extraObjects templating#371

Open
hedgieinsocks wants to merge 2 commits into
haproxytech:mainfrom
hedgieinsocks:feature/add-raw-tempating
Open

kubernetes-ingress: add extraObjects templating#371
hedgieinsocks wants to merge 2 commits into
haproxytech:mainfrom
hedgieinsocks:feature/add-raw-tempating

Conversation

@hedgieinsocks

@hedgieinsocks hedgieinsocks commented Jul 11, 2026

Copy link
Copy Markdown

Allow chart consumers to template arbitrary CRs as part of the helm release.

Signed-off-by: Artyom Babiy <artyom.babiy@gmail.com>
@dkorunic dkorunic self-assigned this Jul 13, 2026
@dkorunic dkorunic added the enhancement New feature or request label Jul 13, 2026

@oktalz oktalz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @hedgieinsocks

I added some comments

### Extra Objects

Declare additional arbitrary raw CR manifests to deploy as a part of the helm release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table is missing its header row

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, my bad, added missing table header

{{/*
Render extra raw objects that might contain templates
*/}}
{{- define "kubernetes-ingress.renderExtraObjects" -}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$value is always coerced to a string
(typeIs "string" .value | ternary .value (.value | toYaml)), but the else
branch passes that string straight to merge, which needs a map:

Error: ... executing "kubernetes-ingress.renderExtraObjects" at <$value>:
wrong type for value; expected map[string]interface {}; got string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like

{{- define "kubernetes-ingress.renderExtraObjects" -}}
  {{- $labels := fromYaml (include "kubernetes-ingress.extraRawLabels" .context) -}}
  {{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
  {{- if contains "{{" (toString $value) }}
    {{- $value = tpl $value .context }}
  {{- end }}
  {{- toYaml (merge (fromYaml $value) $labels) }}
{{- end -}}

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I decided to complicate the original design that served as an inspiration https://github.com/CloudPirates-io/helm-charts/blob/aff6783b21ce92155849464eb612551d2e8788d5/charts/common/templates/_helpers.tpl#L231-L241 and botched it a bit, but your suggestion seems to be working, so accepted, thanks!

@@ -0,0 +1,4 @@
{{- range .Values.extraObjects }}
---
{{- include "kubernetes-ingress.renderExtraObjects" (dict "value" . "context" $) }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{- include ...}}

will merge with previous line

{{ include ...}}

is more correct here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants