Skip to content

Eliminate use of naked bool (includeDefaultCAs) in ClusterBundle API#855

Merged
cert-manager-prow[bot] merged 1 commit intocert-manager:mainfrom
erikgb:default-cas-refact
Jan 27, 2026
Merged

Eliminate use of naked bool (includeDefaultCAs) in ClusterBundle API#855
cert-manager-prow[bot] merged 1 commit intocert-manager:mainfrom
erikgb:default-cas-refact

Conversation

@erikgb
Copy link
Member

@erikgb erikgb commented Jan 24, 2026

Somehow related to #850, naked booleans are discouraged in Kubernetes APIs because they make the API constrained and hard to extend without breaking changes. Ref. Kube API conventions:

Think twice about bool fields. Many ideas start as boolean but eventually trend towards a small set of mutually exclusive options. Plan for future expansions by describing the policy options explicitly as a string type alias (e.g. TerminationMessagePolicy).

In this PR, I suggest eliminating the only remaining naked boolean in the new ClusterBundle API: includeDefaultCAs, into something I feel is better aligned with the API conventions.

Note that this is a breaking change, but ClusterBundle is not yet user-facing, ref. #702.

@cert-manager-prow cert-manager-prow bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 24, 2026
@erikgb erikgb requested a review from Copilot January 24, 2026 15:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the ClusterBundle API to eliminate the use of a naked boolean field (includeDefaultCAs) and replace it with a structured enum-based field (defaultCAs) that follows Kubernetes API conventions. This change provides better extensibility for future enhancements without requiring breaking API changes.

Changes:

  • Replaced IncludeDefaultCAs *bool with DefaultCAs *DefaultCAsSource struct containing a Provider string field with enum validation
  • Updated conversion logic between v1alpha1 (Bundle) and v1alpha2 (ClusterBundle) to handle the new structured field
  • Added fuzzer for the new DefaultCAsSource type to support roundtrip conversion testing

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/apis/trustmanager/v1alpha2/types_cluster_bundle.go Introduces new DefaultCAsSource struct and replaces boolean field with structured enum-based field
pkg/apis/trustmanager/v1alpha2/zz_generated.deepcopy.go Auto-generated deepcopy methods for the new DefaultCAsSource type
pkg/apis/trust/v1alpha1/conversion.go Updates conversion logic to map between boolean (v1alpha1) and enum (v1alpha2) representations
pkg/apis/trust/v1alpha1/conversion_test.go Adds fuzzer for the new type to support conversion testing
pkg/apis/trust/v1alpha1/zz_generated.conversion.go Auto-generated conversion warning comments updated to reference new field name
pkg/applyconfigurations/trustmanager/v1alpha2/defaultcassource.go Auto-generated apply configuration for the new DefaultCAsSource type
pkg/applyconfigurations/trustmanager/v1alpha2/bundlespec.go Updates apply configuration to use new structured field instead of boolean
deploy/crds/trust-manager.io_clusterbundles.yaml Updates CRD schema with new structured field and enum validation
test/integration/clusterbundle/migration_test.go Updates test to use new structured API field

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@erikgb erikgb force-pushed the default-cas-refact branch from 1062afb to c66f936 Compare January 24, 2026 15:55
@erikgb
Copy link
Member Author

erikgb commented Jan 24, 2026

/cc @SgtCoDFish

@erikgb
Copy link
Member Author

erikgb commented Jan 24, 2026

/test pull-trust-manager-integration

@cert-manager-prow cert-manager-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2026
@erikgb erikgb force-pushed the default-cas-refact branch from c66f936 to edc0c03 Compare January 26, 2026 19:52
@cert-manager-prow cert-manager-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2026
Signed-off-by: Erik Godding Boye <egboye@gmail.com>
@erikgb erikgb force-pushed the default-cas-refact branch from edc0c03 to 052155e Compare January 27, 2026 11:49
Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

I like this; I can see how we could provide other default CA bundles down the road, and this keeps most of the simplicity of the bool while enabling that!

@cert-manager-prow cert-manager-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 27, 2026
@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

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

@cert-manager-prow cert-manager-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2026
@cert-manager-prow cert-manager-prow bot merged commit 357370e into cert-manager:main Jan 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants