1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00

fixed no_kind error

This commit is contained in:
NoSkillGirl 2020-10-23 18:12:23 +05:30
parent 6e7ae8ec13
commit 2799cf7d52
3 changed files with 7 additions and 5 deletions

View file

@ -27,6 +27,7 @@ import (
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
appsv1 "k8s.io/api/apps/v1"
)
var Scheme = runtime.NewScheme()
@ -36,6 +37,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
kyvernov1.AddToScheme,
kyvernov1alpha1.AddToScheme,
policyv1alpha1.AddToScheme,
appsv1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition

View file

@ -148,7 +148,6 @@ func Command() *cobra.Command {
fmt.Println("------------------------------------------------------------------")
fmt.Println("Got Policies:", len(policies))
if len(resourcePaths) == 0 && !cluster {
return sanitizedError.NewWithError(fmt.Sprintf("resource file(s) or cluster required"), err)
}
@ -193,6 +192,11 @@ func Command() *cobra.Command {
if err != nil {
return sanitizedError.NewWithError("failed to load resources", err)
}
} else {
resources, err = common.GetResources(policies, resourcePaths, dClient, cluster, namespace)
if err != nil {
return sanitizedError.NewWithError("failed to load resources", err)
}
}
} else {
resources, err = common.GetResources(policies, resourcePaths, dClient, cluster, namespace)
@ -207,7 +211,6 @@ func Command() *cobra.Command {
fmt.Println(resource.GetName())
}
fmt.Println("++++++++++++++++++++++++++++++++++++++++++")
fmt.Println("Before Mutate Policy: ", len(policies))
@ -216,7 +219,6 @@ func Command() *cobra.Command {
fmt.Println("++++++++++++++++++++++++++++++++++++++++++")
fmt.Println("Mutate Policy: ", len(mutatedPolicies))
msgPolicies := "1 policy"
if len(mutatedPolicies) > 1 {
msgPolicies = fmt.Sprintf("%d policies", len(policies))

View file

@ -40,7 +40,6 @@ func GetResources(policies []*v1.ClusterPolicy, resourcePaths []string, dClient
resourceTypes = append(resourceTypes, kind)
}
var resourceMap map[string]map[string]*unstructured.Unstructured
if cluster && dClient != nil {
resourceMap, err = getResourcesOfTypeFromCluster(resourceTypes, dClient, namespace)
@ -170,7 +169,6 @@ func getFileBytes(path string) ([]byte, error) {
func convertResourceToUnstructured(resourceYaml []byte) (*unstructured.Unstructured, error) {
decode := scheme.Codecs.UniversalDeserializer().Decode
fmt.Println("--------resourceYaml: ", string(resourceYaml))
resourceObject, metaData, err := decode(resourceYaml, nil, nil)
if err != nil {
return nil, err