File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -1397,16 +1397,23 @@ func (r *PolicyReconciler) hasPolicyTemplateLabel(
13971397 }
13981398
13991399 err := r .Get (ctx , crdName , & crd )
1400- if err != nil {
1401- // If it wasn't found, then it wasn't in the cache and doesn't have the label
1402- if k8serrors .IsNotFound (err ) {
1403- return false , nil
1400+ if err == nil {
1401+ return crd .GetLabels ()[utils .PolicyTypeLabel ] == "template" , nil
1402+ } else if meta .IsNoMatchError (err ) {
1403+ betaCrd := extensionsv1beta1.CustomResourceDefinition {}
1404+
1405+ err = r .Get (ctx , crdName , & betaCrd )
1406+ if err == nil {
1407+ return betaCrd .GetLabels ()[utils .PolicyTypeLabel ] == "template" , nil
14041408 }
1409+ }
14051410
1406- return false , err
1411+ // If it wasn't found, then it wasn't in the cache and doesn't have the label
1412+ if k8serrors .IsNotFound (err ) {
1413+ return false , nil
14071414 }
14081415
1409- return crd . GetLabels ()[ utils . PolicyTypeLabel ] == "template" , nil
1416+ return false , err
14101417}
14111418
14121419// hasClusterwideFinalizer returns a boolean for whether a policy has a clusterwide finalizer,
You can’t perform that action at this time.
0 commit comments