-
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
Prevent secretInjectionConfigs from setting empty value for key that is not present #81
Comments
I see two different solutions to deal with APIs that do not return every field on every request e.g Stripe: Solution 1: If a field is not returned from a request just leave the secret as it is. This is not really backwards compatible though and in most cases it is probably intended behavior to assume if something is not returned it is set to "null". Solution 2: We could add a extra field for the SecretInjectionConfigs to deal with such APIs. That would be backwards compatible. Possible solutions could be:
---
apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: stripe-example
spec:
...
secretInjectionConfigs:
secretRef:
name: example-secret
namespace: example
keyMappings:
- secretKey: secret
responseJQ: ".body.secret"
syncPolicy:
update: true
delete: false
---
apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: stripe-example
spec:
...
secretInjectionConfigs:
secretRef:
name: example-secret
namespace: example
keyMappings:
- secretKey: secret
responseJQ: ".body.secret"
preserveExisting: true I'd be open to implement this behavior if one of the maintainers approves the API change. |
Thanks for the suggestions! @klaudworks I really like the idea behind the first solution, but I think the apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: stripe-example
spec:
...
secretInjectionConfigs:
secretRef:
name: example-secret
namespace: example
keyMappings:
- secretKey: secret
responseJQ: ".body.secret"
preserveOnMissing: true # Preserves the existing value if the field is missing in the response
preserveOnDelete: true # Prevents deletion if the field is no longer returned
I’d be happy to approve this if you’re interested in implementing it! |
@arielsepton Thanks for your input. I see 3 behaviors that we wanna cover for the case secret field exists + response field missing:
There is one problem though: Setting both to true would be ambiguous because do we set the field to null or preserve the value.
This would allow us to cover all the different cases. Happy to change the name of the field if you have a better suggestion. What do you think about the solution? |
I really like this idea! I’m happy to approve this solution! Let me know if you need anything else from my side. |
Is there a way to use
secretInjectionConfigs
in combination withRequest
, but don't have a key in the Secret updated if it's not present in the response anymore?E.g. this API will return a field
secret
only onCREATE
. Afterwards (OBSERVE
) this field is just not in the response at all. Is there any way, to have a resource like this managed byRequest
(notDisposableRequest
) while keeping the response value that was returned on the firstCREATE
request?Or stated differently: if there is a field (e.g.
secret
like in this example) that's seen in the (first) response, but not on subsequent requests, should it be updated at all when it's not even there anymore? At the moment it is, meaning the corresponding key's value in the K8sSecret
is emptied.The text was updated successfully, but these errors were encountered: