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 deprecated marker for versions #541

Merged
merged 2 commits into from
Apr 30, 2021

Conversation

dvaldivia
Copy link
Contributor

This PR introduces the marker deprecated which would mark a CRD version as deprecated in the generated output, it supports a deprecation warning message

Example usage:

// +kubebuilder:deprecated:warning="This version is deprecated in favor of other.crd.com/v2"

the result is that the version that has this marker would include the following fields

deprecated: true
deprecatedWarning: "This version is deprecated in favor of other.crd.com/v2"

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 28, 2021
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 28, 2021
@dvaldivia
Copy link
Contributor Author

/assign @pwittrock

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

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

generally looks good, minor feedback

// DeprecatedVersion marks this version as deprecated.
type DeprecatedVersion struct {
// Warning message to be shown on the deprecated version
Warning string
Copy link
Contributor

Choose a reason for hiding this comment

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

is this optional, or is it required in the actual CRD. If optional, you can make it a pointer or do something like

type DeprecatedVersion struct {
   Warning string `marker:",optional"`
}

So that the equivalent field is also optional, meaning either of the following would work:

// +kubebuilder:deprecated
type SomeKind struct {}

// {  deprecated: true }
// +kubebuilder:deprecated:warning="blah"
type SomeKind struct{}

// { deprecated: true, deprecationWarning: "blah" }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's optional, but the CRD for CRD also takes a pointer for the deprecation message, so I added the marker optional and also made it a pointer

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

must(markers.MakeDefinition("kubebuilder:unservedversion", markers.DescribesType, UnservedVersion{})).
WithHelp(UnservedVersion{}.Help()),

must(markers.MakeDefinition("kubebuilder:deprecated", markers.DescribesType, DeprecatedVersion{})).
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be deprecatedversion to match with unservedversion and in case we ever get field-level deprecation, or do we think we can just use the same marker for field-level deprecation if we ever get it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it makes sense to keep them consistent, I changed it to deprecatedversion

dvaldivia and others added 2 commits April 29, 2021 16:58
This adds an integration test entry for the unservedversion and
deprecatedversion markers.
@DirectXMan12
Copy link
Contributor

pushed a test & squashed

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 30, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 30, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12, dvaldivia

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 Apr 30, 2021
@DirectXMan12
Copy link
Contributor

thanks, and sorry for the lag!

@dvaldivia
Copy link
Contributor Author

@DirectXMan12 no problem, any time

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

None yet

4 participants