Skip to content

Commit 19a9724

Browse files
committedMay 6, 2020
Update CSV Validation
This commit updates the CRD validation to only accept CSVs where the WebhookDefinition type is valid.
1 parent 2770864 commit 19a9724

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed
 

‎crds/operators.coreos.com_clusterserviceversions.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -8821,6 +8821,9 @@ spec:
88218821
description: WebhookAdmissionType is the type of admission webhooks
88228822
supported by OLM
88238823
type: string
8824+
enum:
8825+
- ValidatingAdmissionWebhook
8826+
- MutatingAdmissionWebhook
88248827
webhookPath:
88258828
type: string
88268829
status:

‎crds/zz_defs.go

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/operators/v1alpha1/clusterserviceversion_types.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ const (
164164
// WebhookDescription provides details to OLM about required webhooks
165165
// +k8s:openapi-gen=true
166166
type WebhookDescription struct {
167-
GenerateName string `json:"generateName"`
167+
GenerateName string `json:"generateName"`
168+
// +kubebuilder:validation:Enum=ValidatingAdmissionWebhook;MutatingAdmissionWebhook
168169
Type WebhookAdmissionType `json:"type"`
169170
DeploymentName string `json:"deploymentName,omitempty"`
170171
ContainerPort int32 `json:"containerPort,omitempty"`
@@ -180,9 +181,9 @@ type WebhookDescription struct {
180181
}
181182

182183
// GetValidatingWebhook returns a ValidatingWebhook generated from the WebhookDescription
183-
func (w *WebhookDescription) GetValidatingWebhook(name, namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.ValidatingWebhook {
184+
func (w *WebhookDescription) GetValidatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.ValidatingWebhook {
184185
return admissionregistrationv1.ValidatingWebhook{
185-
Name: name,
186+
Name: w.GenerateName,
186187
Rules: w.Rules,
187188
FailurePolicy: w.FailurePolicy,
188189
MatchPolicy: w.MatchPolicy,
@@ -203,9 +204,9 @@ func (w *WebhookDescription) GetValidatingWebhook(name, namespace string, namesp
203204
}
204205

205206
// GetMutatingWebhook returns a MutatingWebhook generated from the WebhookDescription
206-
func (w *WebhookDescription) GetMutatingWebhook(name, namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.MutatingWebhook {
207+
func (w *WebhookDescription) GetMutatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.MutatingWebhook {
207208
return admissionregistrationv1.MutatingWebhook{
208-
Name: name,
209+
Name: w.GenerateName,
209210
Rules: w.Rules,
210211
FailurePolicy: w.FailurePolicy,
211212
MatchPolicy: w.MatchPolicy,

0 commit comments

Comments
 (0)