crossplane-contrib / crossplane-contrib/function-go-templating

Proposal: Templating in the Style of a RunFunctionResponse

Open
#513 2 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
100
Forks
65
Avg merge
2d 6h
Merged PRs (30d)
9

Description

### What problem are you facing?

When using this function I've been wondering for quite some time now how it would be if we were just writing RunFunctionResponses.
This seems to me like an intuitive pattern, since the Structure must already be learned to effectively use the Variables in the templates.

### How could this Function help solve your problem?

I propose to add a new Field to the Inputs that allows toggling the expected format to the users preference.

I've created a small [PoC](https://github.com/bobh66/function-go-templating/compare/update_v2...avarei:function-go-templating:poc/style-runFunctionResponse) where this composition works and I'm curious to hear your thoughts on this.

Here's an example of how such a composition would look like.

```yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example-runfunctionresponse
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
style: RunFunctionResponse
inline:
template: |
conditions:
- type: Progressing
status: STATUS_CONDITION_TRUE
reason: Testing
message: Hello World
target: TARGET_COMPOSITE
results:
- severity: SEVERITY_NORMAL
reason: norway
message: foo
target: TARGET_COMPOSITE_AND_CLAIM
requirements:
resources:
ns:
apiVersion: v1
kind: Namespace
matchName: foo
desired:
resources:
sa:
resource:
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .observed.composite.resource.metadata.name }}
ready: READY_TRUE
{{- with .observed.resources.sa.resource }}
cm:
resource:
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
data:
serviceAccountName: {{ .metadata.name }}
ready: READY_FALSE
{{- end }}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.