Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ type KubernetesContainerSpec struct {
// The default tag will be used.
// This field is mutually exclusive with Image.
//
// +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9._/-]+$')",message="ImageRepository must contain only allowed characters and must not include a tag or any colons."
// +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')",message="ImageRepository must contain only allowed characters and must not include a tag."
// +optional
ImageRepository *string `json:"imageRepository,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down Expand Up @@ -4468,8 +4468,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down Expand Up @@ -4467,8 +4467,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down
7 changes: 7 additions & 0 deletions internal/infrastructure/kubernetes/proxy/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ func TestResolveProxyImage(t *testing.T) {
},
expected: fmt.Sprintf("envoyproxy/envoy:%s", defaultTag),
},
{
name: "imageRepository with port",
container: &egv1a1.KubernetesContainerSpec{
ImageRepository: ptr.To("docker.io:443/envoyproxy/envoy"),
},
expected: fmt.Sprintf("docker.io:443/envoyproxy/envoy:%s", defaultTag),
},
}

for _, tc := range tests {
Expand Down
38 changes: 37 additions & 1 deletion test/cel-validation/envoyproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,43 @@ func TestEnvoyProxyProvider(t *testing.T) {
},
}
},
wantErrors: []string{"ImageRepository must contain only allowed characters and must not include a tag or any colons."},
wantErrors: []string{"ImageRepository must contain only allowed characters and must not include a tag."},
},
{
desc: "valid: imageRepository set with port",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{
Container: &egv1a1.KubernetesContainerSpec{
ImageRepository: ptr.To("docker.io:443/envoyproxy/envoy"),
},
},
},
},
}
},
wantErrors: []string{},
},
{
desc: "invalid: imageRepository set with port and tag",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{
Container: &egv1a1.KubernetesContainerSpec{
ImageRepository: ptr.To("docker.io:443/envoyproxy/envoy:v1.2.3"),
},
},
},
},
}
},
wantErrors: []string{"ImageRepository must contain only allowed characters and must not include a tag."},
},
}

Expand Down
8 changes: 4 additions & 4 deletions test/helm/gateway-crds-helm/all.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24547,8 +24547,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down Expand Up @@ -28392,8 +28392,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down
8 changes: 4 additions & 4 deletions test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7235,8 +7235,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down Expand Up @@ -11080,8 +11080,8 @@ spec:
type: string
x-kubernetes-validations:
- message: ImageRepository must contain only allowed
characters and must not include a tag or any colons.
rule: self.matches('^[a-zA-Z0-9._/-]+$')
characters and must not include a tag.
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
resources:
description: |-
Resources required by this container.
Expand Down