Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add support for oneOf/anyOf/allOf/not ClusterClass variable schema constructs #10637

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jimmidyson
Copy link
Member

@jimmidyson jimmidyson commented May 16, 2024

What this PR does / why we need it:
Add support for oneOf/anyOf/allOf/not ClusterClass variable schema constructs

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #10636

/area clusterclass

@k8s-ci-robot k8s-ci-robot added area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 16, 2024
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 16, 2024
@jimmidyson jimmidyson changed the title ✨ Add support for oneOf/anyOf/allOf/not ClusterClass schema constructs ✨ Add support for oneOf/anyOf/allOf/not ClusterClass variable schema constructs May 16, 2024
@jimmidyson
Copy link
Member Author

/cc @sbueringer

@sbueringer
Copy link
Member

Will get back to this directly after the CEL PR merges

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

srm09 commented Aug 8, 2024

@jimmidyson can you rebase this PR and we can queue it up for review, many thanks!

@jimmidyson jimmidyson force-pushed the jimmi/oneof-cc-variable-schema branch from 4bfc44e to 317ff6e Compare August 13, 2024 12:13
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2024
@jimmidyson jimmidyson force-pushed the jimmi/oneof-cc-variable-schema branch from 317ff6e to 4d6512e Compare August 13, 2024 12:14
@jimmidyson
Copy link
Member Author

@srm09 @sbueringer Rebased! Sorry for slow response, but it should be ready now.

@jimmidyson
Copy link
Member Author

@srm09 @sbueringer any chance of a review? 🙏

api/v1beta1/clusterclass_types.go Outdated Show resolved Hide resolved
api/v1beta1/clusterclass_types.go Show resolved Hide resolved
internal/topology/variables/schema.go Outdated Show resolved Hide resolved
internal/topology/variables/schema.go Outdated Show resolved Hide resolved
internal/topology/variables/schema.go Outdated Show resolved Hide resolved
internal/topology/variables/schema_test.go Show resolved Hide resolved
@sbueringer
Copy link
Member

@jimmidyson Thx, looks already pretty good

@sbueringer
Copy link
Member

@jimmidyson Do you have time to address the findings above?

@jimmidyson
Copy link
Member Author

@sbueringer Sorry this slipped off my radar, taking a look now.

@sbueringer
Copy link
Member

@jimmidyson I'll get back to this soon. Just have to finish something else first 😃

@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Sep 26, 2024
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

@jimmidyson Just some smaller findings and a few additional test cases.

Otherwise ready to merge from my side!

@jimmidyson jimmidyson force-pushed the jimmi/oneof-cc-variable-schema branch 3 times, most recently from 66faeda to 47f98f0 Compare September 26, 2024 15:39
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Almost there :)

api/v1beta1/clusterclass_types.go Show resolved Hide resolved
@sbueringer
Copy link
Member

@jimmidyson ^^ last one from my side

@sbueringer
Copy link
Member

+ looks like some regen is needed. If you already did it, maybe you somehow have the wrong controller-gen binary locally, then make clean-bin should help

@jimmidyson
Copy link
Member Author

  • looks like some regen is needed. If you already did it, maybe you somehow have the wrong controller-gen binary locally, then make clean-bin should help

seems to be the right version 🤔

$ hack/tools/bin/controller-gen --version
Version: v0.15.0

No idea why it's different in CI to local though - running make generate results in no changes locally.

@jimmidyson
Copy link
Member Author

Ah need to merge in latest main changes - one sec.

@sbueringer
Copy link
Member

Ah that makes sense :)

@jimmidyson
Copy link
Member Author

@sbueringer Regenerated and all should be good now.

@sbueringer
Copy link
Member

Okay last ask from my side. Can you please rebase on top of main to get rid of the merge commit? (I don't remember the exact details, but I think they potentially lead to some issues)

Feel free to also squash

@jimmidyson
Copy link
Member Author

@sbueringer I set merge method to squash via tide - shouldn't that do the job on merge?

@sbueringer
Copy link
Member

@sbueringer I set merge method to squash via tide - shouldn't that do the job on merge?

It should definitely take care of the squash. I'm not sure what the problem with merge commits might be.

I only know that there is a mergecommitblocker plugin in Prow. But I just checked it doesn't seem to be enabled in the Cluster API repo (https://github.com/kubernetes/test-infra/blob/ba4cf3ddd9f5f570dd7fee899993c99c6a1753d7/config/prow/plugins.yaml#L1242)

@neolit123 Do you maybe know why so many other repositories in the kubernetes ecosystem are blocking merge commits?

@sbueringer
Copy link
Member

Hm, this might be the original issue: kubernetes/test-infra#5376

@sbueringer
Copy link
Member

I would prefer simply getting rid of the merge commit to be honest

@sbueringer
Copy link
Member

sbueringer commented Sep 26, 2024

Here's some guidance in the Kubernetes contributor guide: https://github.com/kubernetes/community/blob/242f468944406e5f5fe0466343cfd4d4fa1f4471/contributors/guide/github-workflow.md#4-keep-your-branch-in-sync

(seems like the GitHub UI does some magic to hide the merge commit, looking at the commit locally it indeed seems pretty messy)

@jimmidyson
Copy link
Member Author

Rebased on main, squashed, and force pushed.

@sbueringer
Copy link
Member

sbueringer commented Sep 27, 2024

Thank you very much!!

Especially for the patience and also implementing int-or-string :)

/lgtm
/approve

/assign @fabriziopandini @chrischdi (just if you want to take a look)
/hold
Just want to give folks a few days to take a look as well

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 27, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 30f916cc831fe4fac85e0dc371efc449d52ba7cd

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 27, 2024
// - type: string
// - ... zero or more
// +optional
XIntOrString bool `json:"x-kubernetes-int-or-string,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this field break the naming convention of camelCase?
why not xIntOrString ?

Copy link
Member

@sbueringer sbueringer Sep 27, 2024

Choose a reason for hiding this comment

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

Our primary goal here is to keep this as consistent as possible with the Kubernetes CRD API type.

So basically that folks who are familiar with Kubernetes CRDs can write ~ the same schema with variables (without having to map keywords)

(That being said, I don't know the reasons why Kubernetes itself chose this format)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

OpenAPI extensions are custom properties prefixed by x- and it seems it is more common to use kebab-case for these extensions in the wild than camelCase for these extensions as opposed to a mix like x-intOrString. I assume the kubernetes part is there to show this is a kubernetes specific openapi extension. More details at https://swagger.io/docs/specification/v3_0/openapi-extensions/.

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. area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support anyOf/oneOf/allOf/not schema constraints for ClusterClass variables
5 participants