mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
panic fix (#1601)
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
This commit is contained in:
parent
596bc9ba6f
commit
33ec907a09
1 changed files with 6 additions and 4 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/go-logr/logr"
|
||||
enginutils "github.com/kyverno/kyverno/pkg/engine/utils"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/client-go/informers"
|
||||
listerv1 "k8s.io/client-go/listers/core/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
|
@ -28,14 +29,14 @@ func GetNamespaceSelectorsFromGenericInformer(kind, namespaceOfResource string,
|
|||
namespaceLabels := make(map[string]string)
|
||||
if kind != "Namespace" {
|
||||
runtimeNamespaceObj, err := nsInformer.Lister().Get(namespaceOfResource)
|
||||
namespaceObj := runtimeNamespaceObj.(*v1.Namespace)
|
||||
|
||||
if err != nil {
|
||||
log.Log.Error(err, "failed to get the namespace", "name", namespaceOfResource)
|
||||
return namespaceLabels
|
||||
}
|
||||
return GetNamespaceLabels(namespaceObj, logger)
|
||||
}
|
||||
|
||||
unstructuredObj := runtimeNamespaceObj.(*unstructured.Unstructured)
|
||||
return unstructuredObj.GetLabels()
|
||||
}
|
||||
return namespaceLabels
|
||||
}
|
||||
|
||||
|
@ -46,6 +47,7 @@ func GetNamespaceSelectorsFromNamespaceLister(kind, namespaceOfResource string,
|
|||
namespaceObj, err := nsLister.Get(namespaceOfResource)
|
||||
if err != nil {
|
||||
log.Log.Error(err, "failed to get the namespace", "name", namespaceOfResource)
|
||||
return namespaceLabels
|
||||
}
|
||||
return GetNamespaceLabels(namespaceObj, logger)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue