@@ -48,6 +48,9 @@ var CRDMarkers = []*definitionWithHelp{
48
48
49
49
must (markers .MakeDefinition ("kubebuilder:unservedversion" , markers .DescribesType , UnservedVersion {})).
50
50
WithHelp (UnservedVersion {}.Help ()),
51
+
52
+ must (markers .MakeDefinition ("kubebuilder:deprecatedversion" , markers .DescribesType , DeprecatedVersion {})).
53
+ WithHelp (DeprecatedVersion {}.Help ()),
51
54
}
52
55
53
56
// TODO: categories and singular used to be annotations types
@@ -316,3 +319,29 @@ func (s UnservedVersion) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, ve
316
319
}
317
320
318
321
// NB(directxman12): singular was historically distinct, so we keep it here for backwards compat
322
+
323
+ // +controllertools:marker:generateHelp:category=CRD
324
+
325
+ // DeprecatedVersion marks this version as deprecated.
326
+ type DeprecatedVersion struct {
327
+ // Warning message to be shown on the deprecated version
328
+ Warning * string `marker:",optional"`
329
+ }
330
+
331
+ func (s DeprecatedVersion ) ApplyToCRD (crd * apiext.CustomResourceDefinitionSpec , version string ) error {
332
+ if version == "" {
333
+ // single-version, do nothing
334
+ return nil
335
+ }
336
+ // multi-version
337
+ for i := range crd .Versions {
338
+ ver := & crd .Versions [i ]
339
+ if ver .Name != version {
340
+ continue
341
+ }
342
+ ver .Deprecated = true
343
+ ver .DeprecationWarning = s .Warning
344
+ break
345
+ }
346
+ return nil
347
+ }
0 commit comments