Skip to content

Commit e189d43

Browse files
woodgeararkodg
authored andcommitted
fix: allow imageRepository contains port (envoyproxy#6658)
(cherry picked from commit c988ec5)
1 parent 8d32d0f commit e189d43

File tree

7 files changed

+61
-18
lines changed

7 files changed

+61
-18
lines changed

api/v1alpha1/shared_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ type KubernetesContainerSpec struct {
239239
// The default tag will be used.
240240
// This field is mutually exclusive with Image.
241241
//
242-
// +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."
242+
// +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."
243243
// +optional
244244
ImageRepository *string `json:"imageRepository,omitempty"`
245245

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_envoyproxies.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ spec:
623623
type: string
624624
x-kubernetes-validations:
625625
- message: ImageRepository must contain only allowed
626-
characters and must not include a tag or any colons.
627-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
626+
characters and must not include a tag.
627+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
628628
resources:
629629
description: |-
630630
Resources required by this container.
@@ -4468,8 +4468,8 @@ spec:
44684468
type: string
44694469
x-kubernetes-validations:
44704470
- message: ImageRepository must contain only allowed
4471-
characters and must not include a tag or any colons.
4472-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
4471+
characters and must not include a tag.
4472+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
44734473
resources:
44744474
description: |-
44754475
Resources required by this container.

charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ spec:
622622
type: string
623623
x-kubernetes-validations:
624624
- message: ImageRepository must contain only allowed
625-
characters and must not include a tag or any colons.
626-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
625+
characters and must not include a tag.
626+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
627627
resources:
628628
description: |-
629629
Resources required by this container.
@@ -4467,8 +4467,8 @@ spec:
44674467
type: string
44684468
x-kubernetes-validations:
44694469
- message: ImageRepository must contain only allowed
4470-
characters and must not include a tag or any colons.
4471-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
4470+
characters and must not include a tag.
4471+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
44724472
resources:
44734473
description: |-
44744474
Resources required by this container.

internal/infrastructure/kubernetes/proxy/resource_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ func TestResolveProxyImage(t *testing.T) {
105105
},
106106
expected: fmt.Sprintf("envoyproxy/envoy:%s", defaultTag),
107107
},
108+
{
109+
name: "imageRepository with port",
110+
container: &egv1a1.KubernetesContainerSpec{
111+
ImageRepository: ptr.To("docker.io:443/envoyproxy/envoy"),
112+
},
113+
expected: fmt.Sprintf("docker.io:443/envoyproxy/envoy:%s", defaultTag),
114+
},
108115
}
109116

110117
for _, tc := range tests {

test/cel-validation/envoyproxy_test.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,43 @@ func TestEnvoyProxyProvider(t *testing.T) {
17401740
},
17411741
}
17421742
},
1743-
wantErrors: []string{"ImageRepository must contain only allowed characters and must not include a tag or any colons."},
1743+
wantErrors: []string{"ImageRepository must contain only allowed characters and must not include a tag."},
1744+
},
1745+
{
1746+
desc: "valid: imageRepository set with port",
1747+
mutate: func(envoy *egv1a1.EnvoyProxy) {
1748+
envoy.Spec = egv1a1.EnvoyProxySpec{
1749+
Provider: &egv1a1.EnvoyProxyProvider{
1750+
Type: egv1a1.ProviderTypeKubernetes,
1751+
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
1752+
EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{
1753+
Container: &egv1a1.KubernetesContainerSpec{
1754+
ImageRepository: ptr.To("docker.io:443/envoyproxy/envoy"),
1755+
},
1756+
},
1757+
},
1758+
},
1759+
}
1760+
},
1761+
wantErrors: []string{},
1762+
},
1763+
{
1764+
desc: "invalid: imageRepository set with port and tag",
1765+
mutate: func(envoy *egv1a1.EnvoyProxy) {
1766+
envoy.Spec = egv1a1.EnvoyProxySpec{
1767+
Provider: &egv1a1.EnvoyProxyProvider{
1768+
Type: egv1a1.ProviderTypeKubernetes,
1769+
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
1770+
EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{
1771+
Container: &egv1a1.KubernetesContainerSpec{
1772+
ImageRepository: ptr.To("docker.io:443/envoyproxy/envoy:v1.2.3"),
1773+
},
1774+
},
1775+
},
1776+
},
1777+
}
1778+
},
1779+
wantErrors: []string{"ImageRepository must contain only allowed characters and must not include a tag."},
17441780
},
17451781
}
17461782

test/helm/gateway-crds-helm/all.out.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24547,8 +24547,8 @@ spec:
2454724547
type: string
2454824548
x-kubernetes-validations:
2454924549
- message: ImageRepository must contain only allowed
24550-
characters and must not include a tag or any colons.
24551-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
24550+
characters and must not include a tag.
24551+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
2455224552
resources:
2455324553
description: |-
2455424554
Resources required by this container.
@@ -28392,8 +28392,8 @@ spec:
2839228392
type: string
2839328393
x-kubernetes-validations:
2839428394
- message: ImageRepository must contain only allowed
28395-
characters and must not include a tag or any colons.
28396-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
28395+
characters and must not include a tag.
28396+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
2839728397
resources:
2839828398
description: |-
2839928399
Resources required by this container.

test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7235,8 +7235,8 @@ spec:
72357235
type: string
72367236
x-kubernetes-validations:
72377237
- message: ImageRepository must contain only allowed
7238-
characters and must not include a tag or any colons.
7239-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
7238+
characters and must not include a tag.
7239+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
72407240
resources:
72417241
description: |-
72427242
Resources required by this container.
@@ -11080,8 +11080,8 @@ spec:
1108011080
type: string
1108111081
x-kubernetes-validations:
1108211082
- message: ImageRepository must contain only allowed
11083-
characters and must not include a tag or any colons.
11084-
rule: self.matches('^[a-zA-Z0-9._/-]+$')
11083+
characters and must not include a tag.
11084+
rule: self.matches('^[a-zA-Z0-9._-]+(:[0-9]+)?[a-zA-Z0-9._/-]+$')
1108511085
resources:
1108611086
description: |-
1108711087
Resources required by this container.

0 commit comments

Comments
 (0)