✨ Promote AddOnTemplate API to v1beta1#443
Conversation
WalkthroughThis PR promotes ChangesAddOnTemplate v1beta1 promotion
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/integration/api/addontemplate_test.go (1)
49-103: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winCover the new
Subjectcontract too.The round-trip checks only assert
Spec.AddonName, so they do not exercise theCustomSignerRegistrationConfig.Subjectshape change introduced by the v1beta1 package. Please add one assertion for that nested field so theorganizationUnit→organizationUnitsconversion is covered.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/api/addontemplate_test.go` around lines 49 - 103, The cross-version tests in addOnTemplate compatibility only verify Spec.AddonName and miss the new Subject conversion contract. Update both Ginkgo cases in AddOnTemplate cross-version compatibility to also assert the nested CustomSignerRegistrationConfig.Subject field after create/get, using the AddOnTemplateSpec/Subject types from addonv1alpha1 and addonv1beta1, so the organizationUnit to organizationUnits mapping is exercised in both directions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@addon/v1beta1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml`:
- Around line 6-15: Add CRD conversion support for the AddOnTemplate rename so
the apiserver can translate Subject.organizationUnit and
Subject.organizationUnits across versions. Update the AddOnTemplate CRD manifest
to include a spec.conversion section for the addontemplates resource, and make
sure it points to the conversion mechanism used by the AddOnTemplate API so the
existing Go conversion functions are actually exercised during cross-version
reads and writes.
---
Nitpick comments:
In `@test/integration/api/addontemplate_test.go`:
- Around line 49-103: The cross-version tests in addOnTemplate compatibility
only verify Spec.AddonName and miss the new Subject conversion contract. Update
both Ginkgo cases in AddOnTemplate cross-version compatibility to also assert
the nested CustomSignerRegistrationConfig.Subject field after create/get, using
the AddOnTemplateSpec/Subject types from addonv1alpha1 and addonv1beta1, so the
organizationUnit to organizationUnits mapping is exercised in both directions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1e92fd17-9658-4d46-9540-e066727513df
📒 Files selected for processing (18)
addon/v1beta1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yamladdon/v1beta1/types_addontemplate.goaddon/v1beta1/zz_generated.conversion.goaddon/v1beta1/zz_generated.deepcopy.goaddon/v1beta1/zz_generated.model_name.goaddon/v1beta1/zz_generated.register.goclient/addon/clientset/versioned/typed/addon/v1beta1/addon_client.goclient/addon/clientset/versioned/typed/addon/v1beta1/addontemplate.goclient/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.goclient/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addontemplate.goclient/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.goclient/addon/informers/externalversions/addon/v1beta1/addontemplate.goclient/addon/informers/externalversions/addon/v1beta1/interface.goclient/addon/informers/externalversions/generic.goclient/addon/listers/addon/v1beta1/addontemplate.goclient/addon/listers/addon/v1beta1/expansion_generated.gotest/integration/api/addontemplate_test.gotest/integration/api/suite_test.go
Add a v1beta1 version of AddOnTemplate to the addon API group, following the same versioning pattern already used for AddOnDeploymentConfig, ClusterManagementAddOn, and ManagedClusterAddOn: - v1alpha1 remains the storage version and stays served, for backward compatibility - v1beta1 is added and served; no changes to AddOnTemplate's own schema/fields - Regenerated client, informer, lister, deepcopy, conversion, and the multi-version CRD manifest for v1beta1 - Added integration tests covering v1beta1 creation, v1alpha1<->v1beta1 cross-version compatibility, and a regression test for the CustomSigner subject organizationUnit round-trip (see below) Two adjustments were needed to keep this a true no-shape-change promotion, both scoped entirely to this repo: - Renamed AddOnTemplate's RegistrationType to AddOnTemplateRegistrationType to avoid a Go symbol collision with ManagedClusterAddOn's v1beta1 RegistrationType. Go identifier only, no effect on the JSON/CRD schema. - Gave CustomSignerRegistrationConfig.Subject its own AddOnTemplateSubject type in v1beta1, matching v1alpha1's Subject shape exactly (organizationUnit), instead of reusing ManagedClusterAddOn's v1beta1 Subject type, which already renamed that field to organizationUnits. AddOnTemplate's CRD uses conversion strategy None (like AddOnDeploymentConfig, and unlike ManagedClusterAddOn/ClusterManagementAddOn, which have a real conversion webhook backing their shape changes); reusing the already-renamed Subject type here would have silently dropped this field on cross-version reads with no webhook to catch it. Signed-off-by: Mike Ng <ming@redhat.com>
e008e78 to
b7ff8dd
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/integration/api/addontemplate_test.go (1)
20-184: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNo cleanup of created AddOnTemplate objects between tests.
Each
Itblock creates a cluster-scopedAddOnTemplatebut never deletes it. Names are randomized so collisions are unlikely, but resources accumulate in the shared envtest apiserver for the duration of the suite.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/api/addontemplate_test.go` around lines 20 - 184, The AddOnTemplate integration tests create cluster-scoped objects in each It block but never remove them, so the shared envtest state accumulates resources across the suite. Add test cleanup in this ginkgo.Describe for every successful creation, preferably via ginkgo.DeferCleanup or an AfterEach that deletes addOnTemplateName through both AddonV1beta1().AddOnTemplates() and AddonV1alpha1().AddOnTemplates() as needed, and make sure each test that calls Create registers cleanup using the relevant created object name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/integration/api/addontemplate_test.go`:
- Around line 20-184: The AddOnTemplate integration tests create cluster-scoped
objects in each It block but never remove them, so the shared envtest state
accumulates resources across the suite. Add test cleanup in this ginkgo.Describe
for every successful creation, preferably via ginkgo.DeferCleanup or an
AfterEach that deletes addOnTemplateName through both
AddonV1beta1().AddOnTemplates() and AddonV1alpha1().AddOnTemplates() as needed,
and make sure each test that calls Create registers cleanup using the relevant
created object name.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 04edea2b-a80d-4d98-923a-70683805f3fd
📒 Files selected for processing (18)
addon/v1beta1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yamladdon/v1beta1/types_addontemplate.goaddon/v1beta1/zz_generated.conversion.goaddon/v1beta1/zz_generated.deepcopy.goaddon/v1beta1/zz_generated.model_name.goaddon/v1beta1/zz_generated.register.goclient/addon/clientset/versioned/typed/addon/v1beta1/addon_client.goclient/addon/clientset/versioned/typed/addon/v1beta1/addontemplate.goclient/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.goclient/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addontemplate.goclient/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.goclient/addon/informers/externalversions/addon/v1beta1/addontemplate.goclient/addon/informers/externalversions/addon/v1beta1/interface.goclient/addon/informers/externalversions/generic.goclient/addon/listers/addon/v1beta1/addontemplate.goclient/addon/listers/addon/v1beta1/expansion_generated.gotest/integration/api/addontemplate_test.gotest/integration/api/suite_test.go
✅ Files skipped from review due to trivial changes (9)
- client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addontemplate.go
- addon/v1beta1/zz_generated.register.go
- client/addon/listers/addon/v1beta1/addontemplate.go
- client/addon/clientset/versioned/typed/addon/v1beta1/addontemplate.go
- client/addon/informers/externalversions/addon/v1beta1/addontemplate.go
- client/addon/informers/externalversions/addon/v1beta1/interface.go
- addon/v1beta1/zz_generated.conversion.go
- addon/v1beta1/zz_generated.deepcopy.go
- addon/v1beta1/zz_generated.model_name.go
🚧 Files skipped from review as they are similar to previous changes (7)
- client/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.go
- test/integration/api/suite_test.go
- client/addon/clientset/versioned/typed/addon/v1beta1/addon_client.go
- client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.go
- client/addon/informers/externalversions/generic.go
- addon/v1beta1/types_addontemplate.go
- client/addon/listers/addon/v1beta1/expansion_generated.go
|
/assign @qiujian16 Thanks! |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mikeshng, qiujian16 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
403378b
into
open-cluster-management-io:main
|
@qiujian16 thank you for the review. Do we cut an api release? Or do you want me to import it from ocm as the commit hash? |
|
we use hash for now, we only cut for the next release. |
Summary
Add a v1beta1 version of AddOnTemplate to the addon API group, following the same versioning pattern already used for AddOnDeploymentConfig, ClusterManagementAddOn, and ManagedClusterAddOn
Related issue(s)
open-cluster-management-io/ocm#1616
Summary by CodeRabbit
AddOnTemplatecustom resource with v1beta1 schema validation.AddOnTemplateacross API versions.