mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 02:45:06 +00:00
remove old crd namespacedpolicyviolation
This commit is contained in:
parent
db4d3d2c8c
commit
b5192dc559
2 changed files with 15 additions and 1 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
@ -21,6 +22,7 @@ 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"
|
||||
)
|
||||
|
||||
|
@ -76,6 +78,9 @@ func main() {
|
|||
glog.Fatalf("Error creating kubernetes client: %v\n", err)
|
||||
}
|
||||
|
||||
// TODO(shuting): To be removed for v1.2.0
|
||||
cleanupOldCrd(client)
|
||||
|
||||
// KUBERNETES RESOURCES INFORMER
|
||||
// watches namespace resource
|
||||
// - cache resync time: 10 seconds
|
||||
|
@ -246,3 +251,12 @@ 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.Info("Failed to remove previous CRD namespacedpolicyviolations: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func CRDInstalled(discovery client.IDiscovery) bool {
|
|||
glog.Infof("CRD %s found ", kind)
|
||||
return true
|
||||
}
|
||||
if !check("ClusterPolicy") || !check("ClusterPolicyViolation") {
|
||||
if !check("ClusterPolicy") || !check("ClusterPolicyViolation") || !check("PolicyViolation") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
Loading…
Add table
Reference in a new issue