Skip to content

Add ClusterBundle API validations - #664

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:mainfrom
erikgb:cluster-bundle-validation
Jul 29, 2025
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:mainfrom
erikgb:cluster-bundle-validation

Conversation

@erikgb

@erikgb erikgb commented Jul 22, 2025 •

Copy link
Copy Markdown
Member

This PR adds all API validations for the new CLusterBundle API that I was able to implement without adding a validating webhook. I have added a new "integration" test, based on envtest (simplified control plane), to test these validations. I suggested introducing CEL validations in #475, but the Bundle API wasn't really ready for it, as the expressions became way too complex. But in the new API, I think the CEL expressions are simple enough.....

Label selectors cannot currently be validated using CEL expressions (or OpenAPI schema) and require a webhook for validation. This is probably true for labels/annotations, even if Kubernetes is now providing the format CEL library that might be used for this. I am personally inclined to NOT add a webhook just for this, as it will hopefully be available in CEL later on. And no webhooks implies that trust-manager will not have cert-manager as a prerequisite.

The added tests detected a few minor bugs/improvements in the API:

  • PKCS12 password cannot have an API default to be validated correctly. We document the default value and will use a controller default to implement it.
  • We have to allow empty sources, as the includeDefaultCAs has moved out of the sources array field. (And also the inLineCAs field, which we are planning to deprecate.)
  • The inLineCAs field had the wrong init-case in the JSON serialization marker, which is now fixed.
  • We should set max items for all array fields and max length for string fields to ensure CEL cost estimation doesn't blow up.

@cert-manager-prow cert-manager-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 Jul 22, 2025
@erikgb
erikgb force-pushed the cluster-bundle-validation branch 2 times, most recently from 2137d0c to fea6353 Compare July 23, 2025 09:02
@erikgb erikgb changed the title WIP: Add ClusterBundle API validations Add ClusterBundle API validations Jul 23, 2025
@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 23, 2025
@erikgb
erikgb force-pushed the cluster-bundle-validation branch from fea6353 to ca2ff33 Compare July 23, 2025 10:56
@erikgb
erikgb force-pushed the cluster-bundle-validation branch from ca2ff33 to 3c2cf26 Compare July 24, 2025 10:13

@SgtCoDFish SgtCoDFish 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.

Few questions - I don't see any reason this can't merge but maybe there are some extra tests which would be helpful?

Comment on lines +248 to +249
Entry("when password set", trustmanagerapi.PKCS12{Password: ptr.To("my-password")}),
Entry("when profile set", trustmanagerapi.PKCS12{Profile: trustmanagerapi.Modern2023PKCS12Profile}),

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.

question: are we missing tests for when profile != PKCS12 but "password" is provided? I might be missing something

@erikgb erikgb Jul 29, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch! It was there, but a bit hidden. I have now refactored the test fixture to make it clearer.

@erikgb
erikgb force-pushed the cluster-bundle-validation branch from 3c2cf26 to 7e45a53 Compare July 29, 2025 08:33
Signed-off-by: Erik Godding Boye <[email protected]>
@erikgb
erikgb force-pushed the cluster-bundle-validation branch from 7e45a53 to 91952a7 Compare July 29, 2025 10:44

@SgtCoDFish SgtCoDFish 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.

/lgtm
/approve

Cheers!

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2025
@cert-manager-prow

Copy link
Copy Markdown
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 Jul 29, 2025
@cert-manager-prow
cert-manager-prow Bot merged commit 90dc0ba into cert-manager:main Jul 29, 2025
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.

3 participants