You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, when developing a composition that creates several MRs (or multiple compositions, for the case), you'll find yourself creating some helper functions in every definition, leading to having the same helper templates over and over on your compositions.
You could try and create a template and use it in FileSystem mode, but then you'll need a pod running for each different object you want to create.
As you can see, you are defining "labels" everytime.
How could this Function help solve your problem?
Perhaps, by having some kind of mix, where you could include a helpers path in the FS and then using your inline function on top of that, we can have the best of both ways.
Something like this I think could be a nice approach:
- step: render-deployment-1functionRef:
name: function-go-templatinginput:
apiVersion: gotemplating.fn.crossplane.io/v1beta1kind: GoTemplatesource: Inline# load all helpers from this directory (which can be loaded into an image)helpers:
dirPath: /helpersinline:
template: | --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment-1 annotations: gotemplating.fn.crossplane.io/composition-resource-name: test1 labels: {{- include "labels" $vals | nindent 4}} spec: replicas: 3 selector: matchLabels: {{- include "labels" $vals | nindent 6}} [...]
Let me know if this could be interesting and I am happy to put a PR in place to implement it :)
The text was updated successfully, but these errors were encountered:
What problem are you facing?
Sometimes, when developing a composition that creates several MRs (or multiple compositions, for the case), you'll find yourself creating some helper functions in every definition, leading to having the same helper templates over and over on your compositions.
You could try and create a template and use it in
FileSystem
mode, but then you'll need a pod running for each different object you want to create.Imagine, for instance:
As you can see, you are defining "labels" everytime.
How could this Function help solve your problem?
Perhaps, by having some kind of mix, where you could include a
helpers
path in the FS and then using your inline function on top of that, we can have the best of both ways.Something like this I think could be a nice approach:
Let me know if this could be interesting and I am happy to put a PR in place to implement it :)
The text was updated successfully, but these errors were encountered: