provider-kubernetes
provider-kubernetes copied to clipboard
Apply transformation when Patching from Resource
I'm trying to create a k8s secret patching from another secret.
I'm trying to achieve this by applying the following object inside of a composition:
- name: argocd-creds-secret
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
name: cluster-bearer-token
spec:
references:
- patchesFrom:
apiVersion: v1
kind: Secret
name: connection-string
namespace: default
fieldPath: data.kubeconfig
toFieldPath: data.bearer-token
transforms:
- type: string
string:
type: Regexp
regexp:
match: '(?<=token:).*$'
forProvider:
manifest:
apiVersion: v1
kind: Secret
metadata:
namespace: default
data:
sample-key: #to be patched
providerConfigRef:
name: local-kubernetes-provider
It looks like it completely ignores the transformation. Is the transformation taken into account at the current implementation=
@fabioaraujopt yes, transforms
was not implemented intentionally at the beginning when patchesFrom
was introduced as the more we add such at provider level, the more we see the similarity for such feature in Composition at core level. Will see if there are more such requirements from community. @turkenh ?
Thank you for explanation @morningspace. Do you suggest any alternative to this? We are increase a lot the complexity of several compositions because of this issue.
We also have the requirement for transformations, also to e.g. combine multiple different fields into a single string in the target object
We also need this, for example to add a prefix or suffix when patching a value
This would be a nice addition to the provider :)
Would love to see that as well.
Sometimes, you need to do some plumbing, which may not follow xp conventions and then an implemenation like this couple bridge to compositions and enable certain cases which as of today would only (in my understanding) be possible, e.g. with specific composition functions. (Getting secret data, transform it and push it into an Object)
Patch and Transforms can be quite complicated and are provide limitations in some cases (like lack of certain transform features). I would suggest using something more generic and more "common" in the Go and K8s ecosystem, like Go templates. Also there are composition environments in Crossplane though it is still an alpha feature.