Skip to content

Conversation

@jbw976
Copy link
Member

@jbw976 jbw976 commented Dec 29, 2025

This PR adds support for connection details in Crossplane v2 composite resources.

v2 XRs don't support the classic connection details flow where functions return details via the function response and Crossplane core creates the secret. Instead, for v2 XRs, this function now automatically composes a Secret resource containing the connection details and includes it with the XR's other composed resources.

The README has been updated with some details about how this works and some small snippet examples, I recommend reading that first.

The new connection details composition guide will be updated to include an example for function-patch-and-transform once this PR is merged and a release is published.

Signed-off-by: Jared Watts <jbw976@gmail.com>
A full [connection details guide][docs-connection-details] can be found in the
Crossplane documentation.

### Setting name/namespace

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be helpful to explicitly state that these rules apply only to Crossplane v2-style XRs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, i will add some clarification here, good point!

schema, this function will use that reference. This can be useful for maintaining
consistency with existing XR configurations.

**Default auto generated**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m sceptical about automatically generating a connection Secret. Creating a Secret is a security and lifecycle significant action, and I think it should require explicit user intent via the options above.

Copy link
Member Author

@jbw976 jbw976 Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for bringing this up, I can see some merit to this point. However, I think it's still a good idea to automatically generate a connection secret because:

  • this was already being done in the v1 flow, the XR would automatically get a connection secret created for it named <XR-uuid>
  • i would argue the user has explicitly specified their intent to have a secret by including connectionDetails for at least 1 of their resources in the composition. If they haven't specified any of those, then no secret will be created
  • this hopefully lowers the friction/changes for users migrating from v1 - if they do nothing with their composition for connection details, it "still works" and a secret is still created for them.

what do you think about that perspective?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I can also see the security concern, I agree it makes sense to default to the v1 behavior here 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would argue the user has explicitly specified their intent to have a secret by including connectionDetails for at least 1 of their resources in the composition. If they haven't specified any of those, then no secret will be created

This is a valid point :)

Signed-off-by: Jared Watts <jbw976@gmail.com>
connection.go Outdated
Comment on lines 146 to 150
// 1. input.writeConnectionSecretToRef - if name or namespace is provided
// then the whole ref will be used
// 2. xr.writeConnectionSecretToRef - this is no longer automatically added
// to v2 XR schemas, but the community has been adding it manually, so if
// it's present we will use it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 wouldn't it make sense to flip these? Given that there are many XRs and one input per Composition, I would expect the input's one to be a default, if the XR didn't specify one already.

Copy link
Member Author

@jbw976 jbw976 Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah when i was thinking about the order of precedence, i could have gone either way on it. the reason i didn't put xr.spec.writeConnectionSecretToRef is because it isn't built-in to the schema anymore, so it felt a bit odd making an optional thing that the user has to add themselves be the highest precedence.

but i didn't feel very strong about that, and it does make sense to put an XR instance (many) value at a higher priority than what's in the composition (one), due to the many:one relation you pointed out. I'll make that change! may need to update some docs too 😊

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phisco I pushed 9057ff2 for this, let me know what you think and if there's anything else blocking!

… v2 XR connection details

Signed-off-by: Jared Watts <jbw976@gmail.com>
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.

3 participants