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

✨ Support api-approved annotation for CRD with k8s group #691

Conversation

FillZpp
Copy link
Contributor

@FillZpp FillZpp commented Jun 13, 2022

Support api-approved annotation for CRD with k8s group

fixes #656

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 13, 2022
@FillZpp FillZpp force-pushed the support-api-approved-annotation-for-CRD branch from 4b63d42 to e8aea0c Compare June 14, 2022 07:48
@FillZpp
Copy link
Contributor Author

FillZpp commented Jun 14, 2022

/retitle ✨ Support api-approved annotation for CRD with k8s group

@k8s-ci-robot k8s-ci-robot changed the title WIP: ✨ Support api-approved annotation for CRD with k8s group ✨ Support api-approved annotation for CRD with k8s group Jun 14, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 14, 2022
@FillZpp
Copy link
Contributor Author

FillZpp commented Jun 14, 2022

/cc @alvaroaleman @joelanford

@@ -51,6 +52,9 @@ var CRDMarkers = []*definitionWithHelp{

must(markers.MakeDefinition("kubebuilder:deprecatedversion", markers.DescribesType, DeprecatedVersion{})).
WithHelp(DeprecatedVersion{}.Help()),

must(markers.MakeDefinition("kubebuilder:apiapprovedk8sgroup", markers.DescribesType, APIApprovedKubernetesGroup{})).
Copy link
Member

Choose a reason for hiding this comment

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

Why thek8sgroup suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Emm, I supposed it to be short name of the annotation key api-approved.kubernetes.io. Do you think k8sgroupapprovedapi would be better?

Comment on lines 357 to 363
type APIApprovedKubernetesGroup struct {
// URL is the value of api-approved.kubernetes.io annotation on CRD,
// it should be a valid URL which contains Scheme and Host and
// should not start with "unapproved".
URL string `marker:"URL"`
}
Copy link
Member

Choose a reason for hiding this comment

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

Any chance we could make this a more generic Annotation struct with Key and Value fields that we parse out of the marker?

I can imagine a few other use cases, for example adding annotation cert-manager.io/inject-ca-from-secret to the CRD when it needs a CA injected for a conversion webhook configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it makes sense. I will update this later.

@FillZpp FillZpp force-pushed the support-api-approved-annotation-for-CRD branch 2 times, most recently from ad92c40 to fde1d19 Compare August 22, 2022 03:26
@FillZpp
Copy link
Contributor Author

FillZpp commented Aug 22, 2022

@joelanford @alvaroaleman I have made it more generic for additional annotations or labels. PTAL :)

@@ -499,6 +499,7 @@ type CronJobStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:resource:singular=mycronjob
// +kubebuilder:storageversion
// +kubebuilder:additionalmetadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/controller-tools";"cert-manager.io/inject-ca-from-secret=cert-manager/cert-manager-webhook-ca"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:additionalmetadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/controller-tools";"cert-manager.io/inject-ca-from-secret=cert-manager/cert-manager-webhook-ca"
// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/controller-tools";"cert-manager.io/inject-ca-from-secret=cert-manager/cert-manager-webhook-ca"

Do we need the additional?
Why not only annotations?
So, if set we add annotations informed
If not set, we add only the default annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Emm.. okey, I will update it to // +kubebuilder:metadata:annotations=...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -51,6 +52,9 @@ var CRDMarkers = []*definitionWithHelp{

must(markers.MakeDefinition("kubebuilder:deprecatedversion", markers.DescribesType, DeprecatedVersion{})).
WithHelp(DeprecatedVersion{}.Help()),

must(markers.MakeDefinition("kubebuilder:additionalmetadata", markers.DescribesType, AdditionalMetadata{})).
WithHelp(AdditionalMetadata{}.Help()),
Copy link
Member

Choose a reason for hiding this comment

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

`Are we not adding annotations only?
What about the name here be kubebuilder:annotations

And we Annotations{}

Copy link
Member

Choose a reason for hiding this comment

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

Ps is possible to add annotations outside of the metadata?
Do we need to use this term here or is that redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it supports to add annotations and labels

// +kubebuilder:metadata:annotations=...
// +kubebuilder:metadata:labels=...

Not sure if there will be some other fields in metadata have to be added there. So we'd better put all of them in kubebuilder:metadata.

@FillZpp FillZpp force-pushed the support-api-approved-annotation-for-CRD branch from fde1d19 to b370e9b Compare November 17, 2022 11:13
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

That seems great for me 🥇
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 22, 2022
@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Nov 22, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, camilamacedo86, FillZpp

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 Nov 22, 2022
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for adding annotations to CRD
5 participants