crossplane-contrib / function-go-templating

A Go templating composition function
https://crossplane.io
Apache License 2.0
52 stars 33 forks source link

Ability to grab the namespace off the claim #97

Closed silverbp closed 3 weeks ago

silverbp commented 4 months ago

What problem are you facing?

Trying to figure out how I can get the namespace off the claim to be able to provision resources in the provider using the name of the namespace in the name.

How could this Function help solve your problem?

Is there a way to pull metadata properties from the claim, specifically the namespace using go-templating or do I need to take the namespace as a parameter?

jaylevin commented 4 months ago

You can grab the claim namespace from the XR's crossplane.io/claim-namespace label.

Here's an example of creating an EnvironmentConfig resource with a claim_namespace key equal to the namespace the claim was deployed to:

{{ $claimNamespace := index $.observed.composite.resource.metadata.labels "crossplane.io/claim-namespace" }}

---
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: EnvironmentConfig
metadata:
  name: test
data:
  claim_namespace: {{ $claimNamespace }}
---
silverbp commented 4 months ago

AWESOME!

bobh66 commented 4 weeks ago

@silverbp is it ok to close this issue?

silverbp commented 4 weeks ago

Yes, thanks

On Sep 4, 2024, at 8:10 PM, Bob Haddleton @.***> wrote:

@silverbp https://github.com/silverbp is it ok to close this issue?

— Reply to this email directly, view it on GitHub https://github.com/crossplane-contrib/function-go-templating/issues/97#issuecomment-2330407593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADPG2RV3YQBQUIZYD7MDS3ZU6VRTAVCNFSM6AAAAABIAKO2D6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZQGQYDONJZGM. You are receiving this because you were mentioned.