Skip to content

Commit 69e6f9b

Browse files
authored
Merge pull request #70 from awgreene/webhook-port-values
Bug 1891898: Set min and max values on Webhook Container Port
2 parents 0031546 + 3b25e5d commit 69e6f9b

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

crds/operators.coreos.com_clusterserviceversions.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8704,6 +8704,8 @@ spec:
87048704
containerPort:
87058705
type: integer
87068706
format: int32
8707+
maximum: 65535
8708+
minimum: 1
87078709
conversionCRDs:
87088710
type: array
87098711
items:

crds/zz_defs.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/operators/v1alpha1/clusterserviceversion_types.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ const (
171171
type WebhookDescription struct {
172172
GenerateName string `json:"generateName"`
173173
// +kubebuilder:validation:Enum=ValidatingAdmissionWebhook;MutatingAdmissionWebhook;ConversionWebhook
174-
Type WebhookAdmissionType `json:"type"`
175-
DeploymentName string `json:"deploymentName,omitempty"`
174+
Type WebhookAdmissionType `json:"type"`
175+
DeploymentName string `json:"deploymentName,omitempty"`
176+
// +kubebuilder:validation:Maximum=65535
177+
// +kubebuilder:validation:Minimum=1
176178
ContainerPort int32 `json:"containerPort,omitempty"`
177179
TargetPort *intstr.IntOrString `json:"targetPort,omitempty"`
178180
Rules []admissionregistrationv1.RuleWithOperations `json:"rules,omitempty"`
@@ -189,6 +191,9 @@ type WebhookDescription struct {
189191

190192
// GetValidatingWebhook returns a ValidatingWebhook generated from the WebhookDescription
191193
func (w *WebhookDescription) GetValidatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.ValidatingWebhook {
194+
if w.ContainerPort == 0 {
195+
w.ContainerPort = 443
196+
}
192197
return admissionregistrationv1.ValidatingWebhook{
193198
Name: w.GenerateName,
194199
Rules: w.Rules,
@@ -213,6 +218,9 @@ func (w *WebhookDescription) GetValidatingWebhook(namespace string, namespaceSel
213218

214219
// GetMutatingWebhook returns a MutatingWebhook generated from the WebhookDescription
215220
func (w *WebhookDescription) GetMutatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.MutatingWebhook {
221+
if w.ContainerPort == 0 {
222+
w.ContainerPort = 443
223+
}
216224
return admissionregistrationv1.MutatingWebhook{
217225
Name: w.GenerateName,
218226
Rules: w.Rules,

0 commit comments

Comments
 (0)