Closed marcosQuesada closed 2 months ago
Regarding your first question, since you're using provider-kubernetes
patches-from-resource, you might want to open an issue there, perhaps requesting a "transforms" key similar to what is supported in compositions nowadays. You can refer to this example for context: link to example.
Also, there are plans to add patches-from-secrets feature in both DisposableRequest and Request.
In the meantime, perhaps using compositions (specifically function-go-templating) can help solve your patching problem. Simply create a composition of both requests and patch data from the first request to the second using the following syntax:
token: Bearer {{ (.observed.resources.loginrequest.resource.status.response.body | fromJson).token }}
As for your second question, your implementation looks good and should work fine.
What happened?
I'm implementing a POC with multiple calls, where the first call gets a token, second one uses that token as Authorization Header, I do have doubts about how to handle json responses and patching json body on other requests.
I do have 2 questions:
Glad to hear any indication about how body is intended to be used with JSON data, or if there's any better way of handling authentication or multiple request please let me know.
How can we reproduce it?
In this simple example the DisposableRequest calls an auth endpoint that returns a token as a string, then the token is patched in Authorization header, works perfect. But, how to handle a json response? example: {"token": "ewjhwekjwh..."} .
Example:
What environment did it happen in?
Crossplane version: 1.14.0
Using: