Skip to content

Commit aeb7ced

Browse files
committed
Restrict major version annotation to FeatureGate and CustomResourceDefinition
1 parent 4a5bec0 commit aeb7ced

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/manifest/manifest.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ func (m *Manifest) IncludeAllowUnknownCapabilities(excludeIdentifier *string, re
451451

452452
// Major version filtering
453453
if majorVersion != nil {
454+
if !isFeatureGate(m.GVK) && !isCustomResource(m.GVK) {
455+
return fmt.Errorf("major version filtering is only supported for feature gates and custom resources")
456+
}
457+
454458
err := checkMajorVersion(*majorVersion, annotations)
455459
if err != nil {
456460
return err
@@ -656,3 +660,11 @@ func addIfNotDuplicateResource(manifest Manifest, resourceIds map[resourceId]boo
656660
}
657661
return fmt.Errorf("duplicate resource: (%s)", manifest.id)
658662
}
663+
664+
func isFeatureGate(gvk schema.GroupVersionKind) bool {
665+
return gvk.Group == "config.openshift.io" && gvk.Kind == "FeatureGate"
666+
}
667+
668+
func isCustomResource(gvk schema.GroupVersionKind) bool {
669+
return gvk.Group == "apiextensions.k8s.io/" && gvk.Kind == "CustomResourceDefinition"
670+
}

0 commit comments

Comments
 (0)