From e3a8cabe8d3e676a9d01cc6be2d91b75ee304a4e Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Fri, 20 Dec 2019 18:51:07 -0800 Subject: [PATCH] add omitempty to types --- pkg/api/kyverno/v1/types.go | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/pkg/api/kyverno/v1/types.go b/pkg/api/kyverno/v1/types.go index 071279134a..91ae2433e9 100644 --- a/pkg/api/kyverno/v1/types.go +++ b/pkg/api/kyverno/v1/types.go @@ -56,13 +56,13 @@ type PolicyViolationList struct { type Policy struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec Spec `json:"spec"` + Spec Spec `json:"spec,omitempty"` Status PolicyStatus `json:"status"` } // Spec describes policy behavior by its rules type Spec struct { - Rules []Rule `json:"rules"` + Rules []Rule `json:"rules,omitempty"` ValidationFailureAction string `json:"validationFailureAction"` } @@ -72,39 +72,39 @@ type Rule struct { Name string `json:"name"` MatchResources MatchResources `json:"match"` ExcludeResources ExcludeResources `json:"exclude,omitempty"` - Mutation Mutation `json:"mutate"` - Validation Validation `json:"validate"` - Generation Generation `json:"generate"` + Mutation Mutation `json:"mutate,omitempty"` + Validation Validation `json:"validate,omitempty"` + Generation Generation `json:"generate,omitempty"` } //MatchResources contains resource description of the resources that the rule is to apply on type MatchResources struct { - Roles []string `json:"roles"` - ClusterRoles []string `json:"clusterRoles"` - Subjects []rbacv1.Subject `json:"subjects"` + Roles []string `json:"roles,omitempty"` + ClusterRoles []string `json:"clusterRoles,omitempty"` + Subjects []rbacv1.Subject `json:"subjects,omitempty"` ResourceDescription `json:"resources"` } //ExcludeResources container resource description of the resources that are to be excluded from the applying the policy rule type ExcludeResources struct { - Roles []string `json:"roles"` - ClusterRoles []string `json:"clusterRoles"` - Subjects []rbacv1.Subject `json:"subjects"` - ResourceDescription `json:"resources"` + Roles []string `json:"roles,omitempty"` + ClusterRoles []string `json:"clusterRoles,omitempty"` + Subjects []rbacv1.Subject `json:"subjects,omitempty"` + ResourceDescription `json:"resources,omitempty"` } // ResourceDescription describes the resource to which the PolicyRule will be applied. type ResourceDescription struct { - Kinds []string `json:"kinds"` - Name string `json:"name"` + Kinds []string `json:"kinds,omitempty"` + Name string `json:"name,omitempty"` Namespaces []string `json:"namespaces,omitempty"` - Selector *metav1.LabelSelector `json:"selector"` + Selector *metav1.LabelSelector `json:"selector,omitempty"` } // Mutation describes the way how Mutating Webhook will react on resource creation type Mutation struct { - Overlay interface{} `json:"overlay"` - Patches []Patch `json:"patches"` + Overlay interface{} `json:"overlay,omitempty"` + Patches []Patch `json:"patches,omitempty"` } // +k8s:deepcopy-gen=false @@ -118,24 +118,24 @@ type Patch struct { // Validation describes the way how Validating Webhook will check the resource on creation type Validation struct { - Message string `json:"message"` - Pattern interface{} `json:"pattern"` - AnyPattern []interface{} `json:"anyPattern"` + Message string `json:"message,omitempty"` + Pattern interface{} `json:"pattern,omitempty"` + AnyPattern []interface{} `json:"anyPattern,omitempty"` } // Generation describes which resources will be created when other resource is created type Generation struct { - Kind string `json:"kind"` - Name string `json:"name"` - Data interface{} `json:"data"` - Clone CloneFrom `json:"clone"` + Kind string `json:"kind,omitempty"` + Name string `json:"name,omitempty"` + Data interface{} `json:"data,omitempty"` + Clone CloneFrom `json:"clone,omitempty"` } // CloneFrom - location of a Secret or a ConfigMap // which will be used as source when applying 'generate' type CloneFrom struct { - Namespace string `json:"namespace"` - Name string `json:"name"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name,omitempty"` } //PolicyStatus provides status for violations