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

NK-21: Improved policy type declaration, fixed declaration of patch field, made corresponding changes to applyPolicyRule. Fixed sentense in README.md.

This commit is contained in:
belyshevdenis 2019-02-28 19:04:15 +02:00
parent 68e468a699
commit d0de77f9ce
3 changed files with 8 additions and 12 deletions

View file

@ -13,7 +13,7 @@ A Kubernetes native policy engine
You need to have go and dep utils installed on your machine.
Ensure that GOPATH environment variable is set to desired location.
Code generation for CRD controller uses kubernetes/hack as a dependency, so before use code generation, execute:
Code generation for CRD controller depends on kubernetes/hack, so before use code generation, execute:
`go get k8s.io/kubernetes/hack`

View file

@ -24,16 +24,16 @@ type PolicySpec struct {
// PolicyRule is policy rule that will be applied to resource
type PolicyRule struct {
Resource PolicyResource `json:"resource"`
Patches []PolicyPatch `json:"patches"`
ConfigMapGenerator *PolicyConfigGenerator `json:"configMapGenerator"`
SecretGenerator *PolicyConfigGenerator `json:"secretGenerator"`
Patches []PolicyPatch `json:"patch,omitempty"`
ConfigMapGenerator *PolicyConfigGenerator `json:"configMapGenerator,omitempty"`
SecretGenerator *PolicyConfigGenerator `json:"secretGenerator,omitempty"`
}
// PolicyResource describes the resource rule applied to
type PolicyResource struct {
Kind string `json:"kind"`
Name *string `json:"name"`
Selector *metav1.LabelSelector `json:"selector"`
Kind string `json:"kind"`
Name *string `json:"name"`
Selector metav1.LabelSelector `json:"selector,omitempty"`
}
// PolicyPatch is TODO

View file

@ -81,11 +81,7 @@ func (mw *MutationWebhook) applyPolicyRule(request *v1beta1.AdmissionRequest, ru
return nil, errors.New("The rule is empty!")
}
if rule.Patches != nil {
for _, patch := range rule.Patches {
allPatches = append(allPatches, patch)
}
}
allPatches = append(allPatches, rule.Patches...)
if rule.ConfigMapGenerator != nil {
// TODO: Make patches from configMapGenerator and add them to returned array