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:
parent
68e468a699
commit
d0de77f9ce
3 changed files with 8 additions and 12 deletions
|
@ -13,7 +13,7 @@ A Kubernetes native policy engine
|
||||||
|
|
||||||
You need to have go and dep utils installed on your machine.
|
You need to have go and dep utils installed on your machine.
|
||||||
Ensure that GOPATH environment variable is set to desired location.
|
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`
|
`go get k8s.io/kubernetes/hack`
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,16 @@ type PolicySpec struct {
|
||||||
// PolicyRule is policy rule that will be applied to resource
|
// PolicyRule is policy rule that will be applied to resource
|
||||||
type PolicyRule struct {
|
type PolicyRule struct {
|
||||||
Resource PolicyResource `json:"resource"`
|
Resource PolicyResource `json:"resource"`
|
||||||
Patches []PolicyPatch `json:"patches"`
|
Patches []PolicyPatch `json:"patch,omitempty"`
|
||||||
ConfigMapGenerator *PolicyConfigGenerator `json:"configMapGenerator"`
|
ConfigMapGenerator *PolicyConfigGenerator `json:"configMapGenerator,omitempty"`
|
||||||
SecretGenerator *PolicyConfigGenerator `json:"secretGenerator"`
|
SecretGenerator *PolicyConfigGenerator `json:"secretGenerator,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PolicyResource describes the resource rule applied to
|
// PolicyResource describes the resource rule applied to
|
||||||
type PolicyResource struct {
|
type PolicyResource struct {
|
||||||
Kind string `json:"kind"`
|
Kind string `json:"kind"`
|
||||||
Name *string `json:"name"`
|
Name *string `json:"name"`
|
||||||
Selector *metav1.LabelSelector `json:"selector"`
|
Selector metav1.LabelSelector `json:"selector,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PolicyPatch is TODO
|
// PolicyPatch is TODO
|
||||||
|
|
|
@ -81,11 +81,7 @@ func (mw *MutationWebhook) applyPolicyRule(request *v1beta1.AdmissionRequest, ru
|
||||||
return nil, errors.New("The rule is empty!")
|
return nil, errors.New("The rule is empty!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if rule.Patches != nil {
|
allPatches = append(allPatches, rule.Patches...)
|
||||||
for _, patch := range rule.Patches {
|
|
||||||
allPatches = append(allPatches, patch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if rule.ConfigMapGenerator != nil {
|
if rule.ConfigMapGenerator != nil {
|
||||||
// TODO: Make patches from configMapGenerator and add them to returned array
|
// TODO: Make patches from configMapGenerator and add them to returned array
|
||||||
|
|
Loading…
Reference in a new issue