-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use XRC/claim values in DisposableRequest body #66
Comments
Yes, the body is a string because CRDs don’t support an Alternatively, you could use patches and transforms, as described in Crossplane’s patch and transform guide. For example: - type: FromCompositeFieldPath
fromFieldPath: spec.clusterName
toFieldPath: spec.forProvider.tags
transforms:
- type: string
string:
type: Format
fmt: '{"kubernetes.io/cluster/%s": "true"}' Since this issue is about general Crossplane composition patterns rather than the specific provider, I’ll go ahead and close it. Let me know if this helps or if you have further questions! |
Hi again, I've checked out your examples but not been able to substitute the string body. I'll also add that I'm not super-experienced with Crossplane. It would be very valuable if you could provide an example. (I am also assuming that this would be of value for other than me, as one often wants to dynamically provide the values of a post body) |
Hi there, apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: my-composition
spec:
resources:
- name: http-request
base:
apiVersion: http.crossplane.io/v1alpha2
kind: DisposableRequest
spec:
providerConfigRef:
name: http-test-config
deletionPolicy: Orphan
forProvider:
headers:
Authorization:
- "Basic {{ my-secret-external:crossplane-system:authorization }}"
Content-Type:
- application/json
insecureSkipTLSVerify: true
method: POST
url: https://mytestdomain.com/testme/pipeline/execute
patches:
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: spec.TestFlag
- fromFieldPath: spec.TestValue
strategy: string
string:
fmt: |
{
"jsonParams": {
"TestFlag": "%s",
"TestValue": "%s"
}
}
toFieldPath: spec.forProvider.body This is untested, but it should give you an idea of how to use For more guidance, I recommend looking at the CombineFromComposite documentation and reaching out to the Crossplane Slack community—they’re very helpful, and this type of composition question is right in line with what they handle best. Let me know if this points you in the right direction! |
Many thanks @arielsepton ! Now I got it to work! :) |
As someone with intermediate experience in Crossplane but just learning provider-http, this ticket is a super valuable find. I hope that tickets like this can be structured into the documentation. This provider is super useful and I think it will get a lot more attention as it becomes easier to use. Thanks and happy new year!! |
What problem are you facing?
I'm uncertain how I can get values supplied in my XRC(claim) substituted in the body of a DisposableRequest.
Here's an example of my 3 files.
The XRD:
My XRC (claim)
And my composition (using provider-http, DisposableRequest)
I see that the request is sent, but no substitution happens of the values supplied in the body.
I've tried various syntax too.
How could Crossplane help solve your problem?
Maybe you could add some examples of how this is done? (I looked at the examples provided and couldn't find any, it seems that the examples uses values hardcoded in the body).
It is not clear to me how I could use crossplane patches because the
body
type is a string.The text was updated successfully, but these errors were encountered: