Skip to content

Commit

Permalink
Update CSV Validation
Browse files Browse the repository at this point in the history
This commit updates the CRD validation to only accept CSVs where the
WebhookDefinition type is valid.
  • Loading branch information
awgreene committed May 6, 2020
1 parent 2770864 commit 19a9724
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions crds/operators.coreos.com_clusterserviceversions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8821,6 +8821,9 @@ spec:
description: WebhookAdmissionType is the type of admission webhooks
supported by OLM
type: string
enum:
- ValidatingAdmissionWebhook
- MutatingAdmissionWebhook
webhookPath:
type: string
status:
Expand Down
14 changes: 7 additions & 7 deletions crds/zz_defs.go

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions pkg/operators/v1alpha1/clusterserviceversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ const (
// WebhookDescription provides details to OLM about required webhooks
// +k8s:openapi-gen=true
type WebhookDescription struct {
GenerateName string `json:"generateName"`
GenerateName string `json:"generateName"`
// +kubebuilder:validation:Enum=ValidatingAdmissionWebhook;MutatingAdmissionWebhook
Type WebhookAdmissionType `json:"type"`
DeploymentName string `json:"deploymentName,omitempty"`
ContainerPort int32 `json:"containerPort,omitempty"`
Expand All @@ -180,9 +181,9 @@ type WebhookDescription struct {
}

// GetValidatingWebhook returns a ValidatingWebhook generated from the WebhookDescription
func (w *WebhookDescription) GetValidatingWebhook(name, namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.ValidatingWebhook {
func (w *WebhookDescription) GetValidatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.ValidatingWebhook {
return admissionregistrationv1.ValidatingWebhook{
Name: name,
Name: w.GenerateName,
Rules: w.Rules,
FailurePolicy: w.FailurePolicy,
MatchPolicy: w.MatchPolicy,
Expand All @@ -203,9 +204,9 @@ func (w *WebhookDescription) GetValidatingWebhook(name, namespace string, namesp
}

// GetMutatingWebhook returns a MutatingWebhook generated from the WebhookDescription
func (w *WebhookDescription) GetMutatingWebhook(name, namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.MutatingWebhook {
func (w *WebhookDescription) GetMutatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.MutatingWebhook {
return admissionregistrationv1.MutatingWebhook{
Name: name,
Name: w.GenerateName,
Rules: w.Rules,
FailurePolicy: w.FailurePolicy,
MatchPolicy: w.MatchPolicy,
Expand Down

0 comments on commit 19a9724

Please sign in to comment.