Skip to content
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

Apply transformation when Patching from Resource #52

Open
fabioaraujopt opened this issue Aug 8, 2022 · 8 comments
Open

Apply transformation when Patching from Resource #52

fabioaraujopt opened this issue Aug 8, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@fabioaraujopt
Copy link

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 fabioaraujopt added the enhancement New feature or request label Aug 8, 2022
@morningspace
Copy link
Collaborator

@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 ?

@fabioaraujopt
Copy link
Author

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.

@lippertmarkus
Copy link

We also have the requirement for transformations, also to e.g. combine multiple different fields into a single string in the target object

@marianheinsen
Copy link

We also need this, for example to add a prefix or suffix when patching a value

@dariozachow
Copy link

This would be a nice addition to the provider :)

@maximilianbraun
Copy link
Contributor

maximilianbraun commented Jan 5, 2024

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)

@MisterMX
Copy link

MisterMX commented Jan 11, 2024

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.

@ctenberge-oneid
Copy link

Having this would help a lot of use cases that need very little "transformations" not be forced to write and maintain Compositions/Definitions and the whole versioning/releasing of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants