mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
move helper to pkg/utils
This commit is contained in:
parent
0c9053d50d
commit
dce1e0555a
2 changed files with 11 additions and 12 deletions
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
@ -22,7 +21,6 @@ import (
|
|||
"github.com/nirmata/kyverno/pkg/version"
|
||||
"github.com/nirmata/kyverno/pkg/webhookconfig"
|
||||
"github.com/nirmata/kyverno/pkg/webhooks"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
kubeinformers "k8s.io/client-go/informers"
|
||||
)
|
||||
|
||||
|
@ -79,7 +77,7 @@ func main() {
|
|||
}
|
||||
|
||||
// TODO(shuting): To be removed for v1.2.0
|
||||
cleanupOldCrd(client)
|
||||
utils.CleanupOldCrd(client)
|
||||
|
||||
// KUBERNETES RESOURCES INFORMER
|
||||
// watches namespace resource
|
||||
|
@ -251,12 +249,3 @@ func init() {
|
|||
config.LogDefaultFlags()
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func cleanupOldCrd(client *dclient.Client) {
|
||||
gvr := client.DiscoveryClient.GetGVRFromKind("NamespacedPolicyViolation")
|
||||
if !reflect.DeepEqual(gvr, (schema.GroupVersionResource{})) {
|
||||
if err := client.DeleteResource("CustomResourceDefinition", "", "namespacedpolicyviolations.kyverno.io", false); err != nil {
|
||||
glog.Infof("Failed to remove previous CRD namespacedpolicyviolations: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
dclient "github.com/nirmata/kyverno/pkg/dclient"
|
||||
)
|
||||
|
||||
//Contains Check if strint is contained in a list of string
|
||||
|
@ -73,3 +74,12 @@ func CRDInstalled(discovery client.IDiscovery) bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func CleanupOldCrd(client *dclient.Client) {
|
||||
gvr := client.DiscoveryClient.GetGVRFromKind("NamespacedPolicyViolation")
|
||||
if !reflect.DeepEqual(gvr, (schema.GroupVersionResource{})) {
|
||||
if err := client.DeleteResource("CustomResourceDefinition", "", "namespacedpolicyviolations.kyverno.io", false); err != nil {
|
||||
glog.Infof("Failed to remove previous CRD namespacedpolicyviolations: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue