crossplane-contrib / crossplane-contrib/function-go-templating
Add tpl function to template rendering
- Dominant language
- Go
- Stars
- 100
- Forks
- 65
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 9
Description
### What problem are you facing?
Currently the helm function `tpl` is not available in the function list when rendering a template: https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function
### How to reproduce?
``` yaml
#XR
apiVersion: example.crossplane.io/v1beta1
kind: XR
metadata:
name: example
spec:
labels:
key1: value1
key2: "{{ .val2 }}"
val2: value2
#Template
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example-function-tpl
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1beta1
kind: XR
mode: Pipeline
pipeline:
- step: render-templates
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
{{$vals:= .observed.composite.resource.spec}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: test1
labels:
{{- toYaml (tpl $vals.labels $vals) | nindent 4}}
```
### What environment did it happen in?
Function version: 0.8.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the Go template renderer's function list and compare it with Helm's documented tpl behavior. Reproduce the issue with the provided XR and Composition YAML, then verify that the template renders the label values after tpl is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, helm
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100