Skip to content

feat: add unique items validator#48

Open
Sammyjroberts wants to merge 1 commit intokubernetes-sigs:mainfrom
Sammyjroberts:feature/uniqueitems-validator
Open

feat: add unique items validator#48
Sammyjroberts wants to merge 1 commit intokubernetes-sigs:mainfrom
Sammyjroberts:feature/uniqueitems-validator

Conversation

@Sammyjroberts
Copy link

#22

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Sammyjroberts
Once this PR has been reviewed and has the lgtm label, please assign everettraven for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 15, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 15, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

@everettraven learning from KAL, is there anything here that reminds us we need to registry these? Do we want to copy over a similar script as we just added for KAL?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that there is anything that reminds us to register these no.

We can certainly copy a similar script over.

// incompatible changes to the uniqueItems constraints of CRD properties.
// The uniqueItems constraint enforces that lists should only contain unique items.
// Going from non-unique to unique is more restrictive and breaking.
// Going from unique to non-unique is less restrictive and OK.
Copy link
Contributor

Choose a reason for hiding this comment

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

This depends on who you are aiming your compatibility at. Going to non-unique may surprise readers. I think we need to enforce in both directions, but have an option for folks to choose whether they are ok moving to the less restrictive option

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on enforcing in both directions.

Some existing checks don't do this, but this is something I want to start moving towards. For new checks, we should restrict both ways by default but allow configuration based on individual user needs for which direction is best for their compatibility requirements.

var (
// ErrUniqueItemsConstraintAdded represents an error state where a uniqueItems constraint was added to a property.
ErrUniqueItemsConstraintAdded = errors.New("uniqueItems constraint added when there was none previously")
) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, missing final new char line here

}

internaltesting.RunTestcases(t, testcases...)
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, missing final new line char

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

@Sammyjroberts Thanks for the contribution - apologies on the log delay for a review.

Aside from existing comments, would you mind also adding e2e tests for this new validation?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2026
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

4 participants