Skip to content

✨ Promote AddOnTemplate API to v1beta1#443

Merged
openshift-merge-bot[bot] merged 1 commit into
open-cluster-management-io:mainfrom
mikeshng:beta-addontemplate
Jul 9, 2026
Merged

✨ Promote AddOnTemplate API to v1beta1#443
openshift-merge-bot[bot] merged 1 commit into
open-cluster-management-io:mainfrom
mikeshng:beta-addontemplate

Conversation

@mikeshng

@mikeshng mikeshng commented Jul 7, 2026

Copy link
Copy Markdown
Member

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

  • New Features
    • Added the AddOnTemplate custom resource with v1beta1 schema validation.
    • Enabled typed CRUD, watch, and list/get access via the client, informer, and lister.
    • Added integration test coverage for creating and reading AddOnTemplate across API versions.
  • Bug Fixes
    • Improved cross-version compatibility, including preserving custom signer subject fields when converting between supported API versions.
    • Added validation test coverage to ensure invalid custom signer configuration is rejected.

@openshift-ci openshift-ci Bot requested review from jnpacker and qiujian16 July 7, 2026 18:30
@openshift-ci openshift-ci Bot added the approved label Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR promotes AddOnTemplate to v1beta1, adding the CRD, API types, generated conversion/deepcopy/model-name/register code, client/informer/lister support, and integration tests for cross-version compatibility and validation.

Changes

AddOnTemplate v1beta1 promotion

Layer / File(s) Summary
CRD schema and API types
addon/v1beta1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml, addon/v1beta1/types_addontemplate.go
Adds the AddOnTemplate CRD and Go types for spec, registration, and binding configs.
Scheme registration and model names
addon/v1beta1/zz_generated.register.go, addon/v1beta1/zz_generated.model_name.go
Registers new types with the scheme and adds OpenAPIModelName() methods.
Generated deepcopy
addon/v1beta1/zz_generated.deepcopy.go
Adds DeepCopyInto/DeepCopy/DeepCopyObject for AddOnTemplate and nested config types.
Generated v1alpha1↔v1beta1 conversions
addon/v1beta1/zz_generated.conversion.go
Registers and implements bidirectional conversion functions for the new types.
Typed clientset and fake clientset
client/addon/clientset/versioned/typed/addon/v1beta1/*
Adds AddOnTemplatesGetter/AddOnTemplateInterface, real and fake implementations, and expansion interface.
Informers, generic factory, and listers
client/addon/informers/externalversions/addon/v1beta1/*, client/addon/informers/externalversions/generic.go, client/addon/listers/addon/v1beta1/*
Adds AddOnTemplateInformer, wires it into the version interface and ForResource, and adds AddOnTemplateLister.
Integration tests and CRD wiring
test/integration/api/addontemplate_test.go, test/integration/api/suite_test.go
Updates envtest CRD paths and adds tests for create, cross-version read, and invalid custom signer name validation.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

Suggested labels: lgtm

Suggested reviewers: deads2k, jnpacker, qiujian16

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: promoting AddOnTemplate API to v1beta1.
Description check ✅ Passed The description includes the required Summary and Related issue(s) sections, though the issue reference is a link instead of a Fixes # entry.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/integration/api/addontemplate_test.go (1)

49-103: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover the new Subject contract too.

The round-trip checks only assert Spec.AddonName, so they do not exercise the CustomSignerRegistrationConfig.Subject shape change introduced by the v1beta1 package. Please add one assertion for that nested field so the organizationUnitorganizationUnits conversion 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1845fd8 and e008e78.

📒 Files selected for processing (18)
  • addon/v1beta1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml
  • addon/v1beta1/types_addontemplate.go
  • addon/v1beta1/zz_generated.conversion.go
  • addon/v1beta1/zz_generated.deepcopy.go
  • addon/v1beta1/zz_generated.model_name.go
  • addon/v1beta1/zz_generated.register.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/addon_client.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/addontemplate.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addontemplate.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.go
  • client/addon/informers/externalversions/addon/v1beta1/addontemplate.go
  • client/addon/informers/externalversions/addon/v1beta1/interface.go
  • client/addon/informers/externalversions/generic.go
  • client/addon/listers/addon/v1beta1/addontemplate.go
  • client/addon/listers/addon/v1beta1/expansion_generated.go
  • test/integration/api/addontemplate_test.go
  • test/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>
@mikeshng mikeshng force-pushed the beta-addontemplate branch from e008e78 to b7ff8dd Compare July 7, 2026 18:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/integration/api/addontemplate_test.go (1)

20-184: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

No cleanup of created AddOnTemplate objects between tests.

Each It block creates a cluster-scoped AddOnTemplate but 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

📥 Commits

Reviewing files that changed from the base of the PR and between e008e78 and b7ff8dd.

📒 Files selected for processing (18)
  • addon/v1beta1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml
  • addon/v1beta1/types_addontemplate.go
  • addon/v1beta1/zz_generated.conversion.go
  • addon/v1beta1/zz_generated.deepcopy.go
  • addon/v1beta1/zz_generated.model_name.go
  • addon/v1beta1/zz_generated.register.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/addon_client.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/addontemplate.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addontemplate.go
  • client/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.go
  • client/addon/informers/externalversions/addon/v1beta1/addontemplate.go
  • client/addon/informers/externalversions/addon/v1beta1/interface.go
  • client/addon/informers/externalversions/generic.go
  • client/addon/listers/addon/v1beta1/addontemplate.go
  • client/addon/listers/addon/v1beta1/expansion_generated.go
  • test/integration/api/addontemplate_test.go
  • test/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

@mikeshng

mikeshng commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

/assign @qiujian16

Thanks!

@qiujian16 qiujian16 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jul 9, 2026
@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot Bot merged commit 403378b into open-cluster-management-io:main Jul 9, 2026
11 checks passed
@mikeshng mikeshng deleted the beta-addontemplate branch July 9, 2026 18:19
@mikeshng

mikeshng commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

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

@qiujian16

Copy link
Copy Markdown
Member

we use hash for now, we only cut for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants