crossplane-contrib / crossplane-contrib/function-patch-and-transform
Patching a resource from a value obtained from function-go-templating
- Vorherrschende Sprache
- Go
- Sterne
- 46
- Forks
- 41
- Ø Merge
- 1 T. 10 Std.
- Gemergte PRs (30 T.)
- 3
Beschreibung
Hi Folks,
I want to patch a resource inside the function-patch-and-transform function using a value that I obtain from the function-go-templating.
I see the other way where we get data from the go template function into the p&t function [here](https://github.com/crossplane-contrib/function-patch-and-transform/blob/main/example/multistep/composition.yaml)
I am attaching my sample composition below.
```yaml
---
# Removed for brevity
pipeline:
- step: castai-ekscluster
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
{{- $environmentConfigs := (index .context "apiextensions.crossplane.io/environment") }}
{{- $accountIdstr := printf "%q" (index $environmentConfigs "accountId") }}
{{- $eksClusterName := printf "%q" (index $environmentConfigs "eksClusterName") }}
{{- $region := (index $environmentConfigs "region") }}
{{- $deletionPolicy := .observed.composite.resource.spec.crossplaneParameters.deletionPolicy }}
{{- $providerConfigRef := "default" }}
---
apiVersion: castai.upbound.io/v1alpha1
kind: EksClusterId
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: EksClusterId
labels:
cast-ai-cluster: {{$eksClusterName}}
spec:
deletionPolicy: {{$deletionPolicy}}
providerConfigRef:
name: {{$providerConfigRef}}
forProvider:
region: {{$region}}
accountId: {{$accountIdstr}}
clusterName: {{$eksClusterName}}
- step: aws-auth-patch
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: awsauthconfigmap
base:
apiVersion: v1
kind: ConfigMap
metadata:
name: ashish-test
namespace: castai-agent
patches:
- type: FromCompositeFieldPath
fromFieldPath: HERE I want the value from the function-go-templating
toFieldPath: "data.mapRoles"
transforms:
- type: string
string:
type: Format
fmt: '[{"rolearn": "%s", "username": "system:node:{{EC2PrivateDNSName}}", "groups": ["system:masters"]}]'
```
tagging @ytsarev as you might already be knowing solution.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit example/multistep/composition.yaml und verfolge, wie von function-go-templating erzeugte Werte späteren Pipeline-Schritten zur Verfügung gestellt werden. Prüfe die Eingaben von function-patch-and-transform und dokumentiere oder demonstriere den unterstützten Weg, diesen Wert in data.mapRoles zu verwenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- go
- Bereich
- infrastructure
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100