-
Notifications
You must be signed in to change notification settings - Fork 90
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
Allow Specification of the CRD API Version a Controller Watches & Reconciles #400
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…the specific CR API version the associated controller will watch & reconcile. - For backwards-compatibility, ControllerReconcileVersion defaults to Version if unspecified. Signed-off-by: Alper Rifat Ulucinar <[email protected]>
Signed-off-by: Alper Rifat Ulucinar <[email protected]>
…ersions between the Crossplane & Terraform layers. Signed-off-by: Alper Rifat Ulucinar <[email protected]>
… path prefixes - Previously, it only converted parameters under spec.forProvider - This missed CRD API conversions (of singleton lists) under spec.initProvider & status.atProvider Signed-off-by: Alper Rifat Ulucinar <[email protected]> (cherry picked from commit 08b3f3260ce86457271dda7401dfd9a69a10f656)
…rsion to convert between singleton lists and embedded objects when parameters pass Crossplane and Terraform boundaries. Signed-off-by: Alper Rifat Ulucinar <[email protected]>
ulucinar
requested review from
sergenyalcin,
erhancagirici and
mergenci
as code owners
May 10, 2024 07:30
…mName - TerraformName will automatically handle name & version configurations that will affect the generated cross-resource reference. This is crucial especially if the provider generates multiple versions for its MR APIs. Signed-off-by: Alper Rifat Ulucinar <[email protected]>
This was referenced May 10, 2024
sergenyalcin
approved these changes
May 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ulucinar LGTM!
3 tasks
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of your changes
This PR adds
config.Resource.ControllerReconcileVersion
through which the CRD API version which the associated controller will watch for & reconcile can be specified. This will allow us to set the controller's watch API version to the storage version of the CRD to prevent webhook conversions for multi-versioned CRDs.In order to support this, we also add
config.Resource.TerraformConversions
which accepts a list ofconfig.TerraformConversion
implementations. TheseTerraformConversion
s are responsible for converting data before it's passed down to the Terraform layer from the Crossplane layer and also for converting it back when it's carried up to the Crossplane layer from the Terraform layer. Currently, the only implementation is theconfig.singletonListConversion
, which is responsible for converting between the singleton lists and embedded objects for converted APIs. Previously, this bidirectional conversion logic was hard-coded into the external client. This PR allows us to abstract this conversion logic behind theconfig.TerraformConversion
interface.We also address a bug in this PR discovered by @sergenyalcin in the context of crossplane-contrib/provider-upjet-gcp#508. The singleton list CRD API converter (invoked by the conversion webhook) only handled API list API conversions in
spec.forProvider
, ignoringspec.initProvider
andstatus.atProvider
, where such conversions are still relevant.This PR also deprecates
config.Reference.Type
in favor ofconfig.Reference.TerraformName
. We had introducedconfig.Reference.TerraformName
in #12 and it's a more stable and less error prone API compared toconfig.Reference.Type
because it automatically accounts for the configuration changes affecting the resource kind name, group or version. We've already been discouraging theconfig.Reference.Type
in favor ofconfig.Reference.TerraformName
since it's been introduced.I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Manually tested via provider-upjet-{azuread,gcp} resources. Will also be tested in the uptest runs in crossplane-contrib/provider-upjet-gcp#508.