crossplane-contrib / crossplane-contrib/function-patch-and-transform

Patch existing resources by matching labels, not resource template name

Offen
#20 7 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
46
Forks
41
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
3

Beschreibung

One neat thing about `function-patch-and-transform` is that you can patch composed resources that are produced by another Function, earlier in the pipeline. For example here we P&T some resources produced by `function-go-templates`:

```yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: dynamo-with-bucket
spec:
compositeTypeRef:
apiVersion: database.example.com/v1alpha1
kind: NoSQL
# This pipeliene renders some Go templates, then passes them to P&T
pipeline:
- step: render-go-templates
functionRef:
name: function-go-templates
input: {} # Omitted for brevity :)
- step: patch-and-transform
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
# Notice that my-cool-bucket doesn't have a base template. As long as
# the render-go-templates step above rendered a composed resource with
# this name, this Function will patch it.
- name: my-cool-bucket
patches:
- type: FromCompositeFieldPath
fromFieldPath: "location"
toFieldPath: "spec.forProvider.region"
transforms:
- type: map
map:
EU: "eu-north-1"
US: "us-east-2"
```

One shortcoming with this is that you have to know the names (as in composition template names, not object metadata names) of the composed resources some other function produced in order to patch them.

@vfarcic noted that it would be useful to be able to patch resources without knowing their name in advance. Consider for example a Function that produced an arbitrary number of resources, where the number of resources was derived from an XR field. It wouldn't be possible to know what (or more specifically how many) names that Function would produce.

I think this would be pretty easy to implement if we can find a good API to describe it.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit dem Verhalten der Pipeline function-patch-and-transform im Composition-Beispiel, insbesondere damit, wie der Schritt patch-and-transform Ressourcen abgleicht, die von function-go-templates erzeugt werden. Definiere eine API zur Ressourcenauswahl, die beliebige Ressourcen ohne bekannte Template-Namen unterstützt; der Abschluss sollte eine vereinbarte API und deren Implementierung umfassen, aber im Issue werden keine Dateien oder Tests genannt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go
Bereich
api, backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.