Skip to content

score-* patch templates - better document what are the inputs when designing a patch template #193

@mathieu-benoit

Description

@mathieu-benoit

Based on this feedback from the community, https://cloud-native.slack.com/archives/C07DN0D1UCW/p1749831841832469, we need to better explain what are the inputs of a patch template to speed up the process of creating custom patch templates.

Otherwise, users need to hack to understand what are their options:

Create a template like this:

{{ $input := . }}
{{ range $name, $spec := .Workloads }}
{{ $annotations := dig "metadata" "annotations" dict $spec }}
{{ range $cname, $_ := $spec.containers }}
- op: set
  path: services.{{ $name }}-{{ $cname }}.labels.debug
  value: {{ $input | toJson | b64enc }}
{{ end }}
{{ end }}

Now I can grab the base64 input object coming into the template rendering, convert from base64 back to json
Then use https://gotemplate.io/ (which appears to have support for sprig functions) and iterate there on the template

The goal will be to update both pages accordingly:

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions