1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

NK-10: Fixed group name in crd.yaml and register.go.

Fixed crash in controller, removed name checking in the root of admission request.
This commit is contained in:
belyshevdenis 2019-02-28 14:25:47 +02:00
parent eb5c486ae1
commit ae952f73ab
4 changed files with 12 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package controller
import (
"log"
"os"
"time"
"k8s.io/apimachinery/pkg/labels"
@ -23,6 +24,10 @@ type PolicyController struct {
// NewPolicyController from cmd args
func NewPolicyController(masterURL, kubeconfigPath string, logger *log.Logger) (*PolicyController, error) {
if logger == nil {
logger = log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile)
}
cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
logger.Printf("Error building kubeconfig: %v\n", err)
@ -41,6 +46,7 @@ func NewPolicyController(masterURL, kubeconfigPath string, logger *log.Logger) (
controller := &PolicyController{
policyInformerFactory: policyInformerFactory,
policyLister: policyInformer.Lister(),
logger: logger,
}
policyInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
@ -54,7 +60,7 @@ func NewPolicyController(masterURL, kubeconfigPath string, logger *log.Logger) (
// Run is main controller thread
func (c *PolicyController) Run(stopCh <-chan struct{}) {
//c.policyInformerFactory.Start(stopCh)
c.policyInformerFactory.Start(stopCh)
}
// GetPolicies retrieves all policy resources

View file

@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: policies.nirmata.io
name: policies.policy.nirmata.io
spec:
group: nirmata.io
group: policy.nirmata.io
versions:
- name: v1alpha1
served: true

View file

@ -1,5 +1,5 @@
package policy
const (
GroupName = "nirmata.io"
GroupName = "policy.nirmata.io"
)

View file

@ -48,8 +48,7 @@ func IsRuleResourceFitsRequest(resource types.PolicyResource, request *v1beta1.A
if resource.Kind != request.Kind.Kind {
return false
}
if resource.Name != nil && *resource.Name != request.Name {
return false
}
// TODO: resource.Name must be equal to request.Object.Raw -> /metadata/name
return true
}