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

Update to support newest libs and EnvironmentConfig #9

Open
wants to merge 54 commits into
base: main
Choose a base branch
from

Conversation

stevendborrelli
Copy link
Owner

renovate bot and others added 30 commits November 27, 2023 20:04
…vate/actions-setup-go-5.x

chore(deps): update actions/setup-go action to v5
…vate/github.com-crossplane-crossplane-runtime-1.x

fix(deps): update module github.com/crossplane/crossplane-runtime to v1.14.3
…vate/k8s.io-utils-digest

fix(deps): update k8s.io/utils digest to b307cd5
…vate/actions-download-artifact-4.x

chore(deps): update actions/download-artifact action to v4
…vate/kubernetes-go

fix(deps): update kubernetes packages to v0.29.0
add simple guidance for including results from previous functions
…vate/actions-upload-artifact-4.x

chore(deps): update actions/upload-artifact action to v4
These actions require artifact names to be unique across runs. We
achieve this by uploading unique names, then downloading all of them.

Signed-off-by: Nic Cope <[email protected]>
…vate/google.golang.org-protobuf-1.x

fix(deps): update module google.golang.org/protobuf to v1.32.0
Fix for v4 of the upload and download artifacts actions
…vate/k8s.io-utils-digest

fix(deps): update k8s.io/utils digest to e7106e6
GetType returns a default value if p.Type is empty. In upstream c/c CRD
defaulting does this for us, but we can't rely on that here since our
input is not a 'real' API object.

Signed-off-by: Nic Cope <[email protected]>
Using the correct patch types requires changing the order in which xr
and env are passed to ApplyToObjects to the "correct" order (xr, env)
instead of (env, xr). Here env takes over the role of the composed
resource just like in `Apply`.

Signed-off-by: Maximilian Blatt <[email protected]>
…t-correct-patches

fix(environment): Validate against correct patch types
…vate/sigs.k8s.io-controller-tools-0.x

fix(deps): update module sigs.k8s.io/controller-tools to v0.14.0
…vate/kubernetes-go

fix(deps): update kubernetes packages to v0.29.1
This will stop the reconcile. No further patches, resources, or
functions will be processed.

This commit breaks required field paths, in that we'll return a fatal
result if a required field path is missing. This means a set of patches
that could have been eventually consistent now cannot. I intend to
address that in a following commit.

Signed-off-by: Nic Cope <[email protected]>
If we hit a composition error that is likely due to a misconfigured
composition we just return a fatal error. Previously we'd skip the
affected composed resource, which could result in it being deleted if it
already existed.

We'll now only skip rendering a composed resource if a required field
path is not present _and_ the composed resource doesn't exist yet.

Signed-off-by: Nic Cope <[email protected]>
negz and others added 24 commits January 22, 2024 17:56
I think Renovate bumped controller-tools, resulting in most of this
diff.

Signed-off-by: Nic Cope <[email protected]>
This was not actually doing any patching - it was skipping the optional
field path patch and relying on the bucket already having a region set
in its base.

Signed-off-by: Nic Cope <[email protected]>
…vate/github.com-crossplane-crossplane-runtime-1.x

fix(deps): update module github.com/crossplane/crossplane-runtime to v1.14.4
Don't delete composed resources when we hit an error
This function was copied from c/c but isn't needed here.

RenderJSON tried to preserve metadata of the passed object (e.g. name
and namespace), and checked that its GVK didn't change. In practice in
this function the passed object will always be new and empty so we can
just use json.Marshal directly.

Signed-off-by: Nic Cope <[email protected]>
feat(upboundcare): switch to upboundcare
…vate/github.com-crossplane-crossplane-runtime-1.x

fix(deps): update module github.com/crossplane/crossplane-runtime to v1.15.1
…vate/github.com-crossplane-function-sdk-go-0.x

fix(deps): update module github.com/crossplane/function-sdk-go to v0.2.0
…vate/kubernetes-go

fix(deps): update kubernetes packages to v0.29.2
…tions

feat: toFieldPath policies, replacing upstream MergeOptions
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
@milkpirate
Copy link

@stevendborrelli since you have turned off issues, this is the only way, i see, to contact you 😅

Anyway, what I want to ask you is: Is patching possible with this function? From the examples its not really clear. And if not, how can I use this with the official function-patch-and-transform ?

I explored two workflows for patching and (conditional-)rendering:

A

  1. Patch
  2. Conditionally render

which results in problems since I might patch stuff, thats not needed at all and so I would need to make all the patches optional, but I would not want that **if ** (depending on the XR) I want to render (e.g. ProviderConfigs).

B

  1. Conditionally render
  2. Patch

This way, the resources are rendered unpatched and then handed over to the patch/transform function. But I have to explicitly name all resourced to be handed over, but I do not know in advance which were rendered and if unrendered resources are passed by name to the 2nd stage, the framework complains that its not finding these.

So I end up in a situation where I can either patch or render conditionally 😢 But I really would like to do both... Sorry to spam your PR here but I would greatly appreciate your help!

Best regards

@stevendborrelli
Copy link
Owner Author

Hello @milkpirate yes, you can use all the existing patch and transforms with the conditionals with this function. The conditionals are an added feature.

However, given the growth in the XP function ecosystem, I think developing this function is on the back burner for me.

I'd suggest looking at https://github.com/crossplane-contrib/function-cel-filter for filtering resources using CEL.

My personal preference is to ditch Patch&Transform entirely and move to function-go-templating or the KCL function.

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

Successfully merging this pull request may close these issues.

7 participants