Skip to content

Commit

Permalink
webhook registration: always set side effects
Browse files Browse the repository at this point in the history
  • Loading branch information
ereslibre committed Apr 12, 2021
1 parent c2dd5fc commit e8acfcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion internal/pkg/admission/mutating-webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (r *Reconciler) mutatingWebhookRegistration(
if len(apiVersions) == 0 {
apiVersions = []string{"*"}
}
sideEffects := clusterAdmissionPolicy.Spec.SideEffects
if sideEffects == nil {
noneSideEffects := admissionregistrationv1.SideEffectClassNone
sideEffects = &noneSideEffects
}
return &admissionregistrationv1.MutatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: clusterAdmissionPolicy.Name,
Expand Down Expand Up @@ -75,7 +80,7 @@ func (r *Reconciler) mutatingWebhookRegistration(
MatchPolicy: clusterAdmissionPolicy.Spec.MatchPolicy,
NamespaceSelector: clusterAdmissionPolicy.Spec.NamespaceSelector,
ObjectSelector: clusterAdmissionPolicy.Spec.ObjectSelector,
SideEffects: clusterAdmissionPolicy.Spec.SideEffects,
SideEffects: sideEffects,
TimeoutSeconds: clusterAdmissionPolicy.Spec.TimeoutSeconds,
AdmissionReviewVersions: []string{"v1"},
},
Expand Down
7 changes: 6 additions & 1 deletion internal/pkg/admission/validating-webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (r *Reconciler) validatingWebhookRegistration(
if len(apiVersions) == 0 {
apiVersions = []string{"*"}
}
sideEffects := clusterAdmissionPolicy.Spec.SideEffects
if sideEffects == nil {
noneSideEffects := admissionregistrationv1.SideEffectClassNone
sideEffects = &noneSideEffects
}
return &admissionregistrationv1.ValidatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: clusterAdmissionPolicy.Name,
Expand Down Expand Up @@ -75,7 +80,7 @@ func (r *Reconciler) validatingWebhookRegistration(
MatchPolicy: clusterAdmissionPolicy.Spec.MatchPolicy,
NamespaceSelector: clusterAdmissionPolicy.Spec.NamespaceSelector,
ObjectSelector: clusterAdmissionPolicy.Spec.ObjectSelector,
SideEffects: clusterAdmissionPolicy.Spec.SideEffects,
SideEffects: sideEffects,
TimeoutSeconds: clusterAdmissionPolicy.Spec.TimeoutSeconds,
AdmissionReviewVersions: []string{"v1"},
},
Expand Down

0 comments on commit e8acfcc

Please sign in to comment.