Skip to content

Proposal: Templating in the Style of a RunFunctionResponse #513

@avarei

Description

@avarei

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 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.

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 }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions