@@ -235,7 +235,7 @@ func checkFeatureGates(enabledGates sets.Set[string], annotations map[string]str
235235}
236236
237237// checkMajorVersion validates if manifest should be included based on major version requirements
238- func checkMajorVersion (clusterMajorVersion uint64 , annotations map [string ]string ) error {
238+ func checkMajorVersion (gvk schema. GroupVersionKind , clusterMajorVersion uint64 , annotations map [string ]string ) error {
239239 if annotations == nil {
240240 return nil // No annotations, include by default
241241 }
@@ -244,6 +244,11 @@ func checkMajorVersion(clusterMajorVersion uint64, annotations map[string]string
244244 return nil // No requirements, include by default
245245 }
246246
247+ if ! isFeatureGate (gvk ) && ! isCustomResource (gvk ) {
248+ // Has a requirement, but is not of the expected kind
249+ return fmt .Errorf ("major version filtering is only supported for feature gates and custom resources" )
250+ }
251+
247252 requirements := strings .Split (majorVersionRequirements , "," )
248253 includedVersions := sets .New [uint64 ]()
249254 excludedVersions := sets .New [uint64 ]()
@@ -338,7 +343,7 @@ func (m *Manifest) IncludeAllowUnknownCapabilities(excludeIdentifier *string, re
338343
339344 // Major version filtering
340345 if majorVersion != nil {
341- err := checkMajorVersion (* majorVersion , annotations )
346+ err := checkMajorVersion (m . GVK , * majorVersion , annotations )
342347 if err != nil {
343348 return err
344349 }
@@ -543,3 +548,11 @@ func addIfNotDuplicateResource(manifest Manifest, resourceIds map[resourceId]boo
543548 }
544549 return fmt .Errorf ("duplicate resource: (%s)" , manifest .id )
545550}
551+
552+ func isFeatureGate (gvk schema.GroupVersionKind ) bool {
553+ return gvk .Group == "config.openshift.io" && gvk .Kind == "FeatureGate"
554+ }
555+
556+ func isCustomResource (gvk schema.GroupVersionKind ) bool {
557+ return gvk .Group == "apiextensions.k8s.io" && gvk .Kind == "CustomResourceDefinition"
558+ }
0 commit comments