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 @@ -231,7 +231,7 @@ type KubernetesContainerSpec struct {
// Image specifies the EnvoyProxy container image to be used including a tag, instead of the default image.
// This field is mutually exclusive with ImageRepository.
//
// +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')",message="Image must include a tag and allowed characters only (e.g., 'repo:tag')."
// +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')",message="Image must include a tag and allowed characters only (e.g., 'repo:tag')."
// +optional
Image *string `json:"image,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down Expand Up @@ -4459,7 +4459,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down Expand Up @@ -4458,7 +4458,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down
52 changes: 44 additions & 8 deletions test/cel-validation/envoyproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1616,15 +1616,15 @@ func TestEnvoyProxyProvider(t *testing.T) {
wantErrors: []string{},
},
{
desc: "valid: imageRepository set without tag, image not set",
desc: "valid: image set with digest, imageRepository not set",
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("envoyproxy/envoy"),
Image: ptr.To("envoyproxy/envoy:v1.2.3@sha256:da99c47f08546492d19973920dc76334c592f59ad5b732a514320d959db9fa40"),
},
},
},
Expand All @@ -1634,26 +1634,25 @@ func TestEnvoyProxyProvider(t *testing.T) {
wantErrors: []string{},
},
{
desc: "invalid: both image and imageRepository set",
desc: "valid: image with sha256, imageRepository not set",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{
Container: &egv1a1.KubernetesContainerSpec{
Image: ptr.To("envoyproxy/envoy:v1.2.3"),
ImageRepository: ptr.To("envoyproxy/envoy"),
Image: ptr.To("envoyproxy/envoy@sha256:da99c47f08546492d19973920dc76334c592f59ad5b732a514320d959db9fa40"),
},
},
},
},
}
},
wantErrors: []string{"Either image or imageRepository can be set."},
wantErrors: []string{},
},
{
desc: "invalid: image set without tag",
desc: "valid: image set without tag",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Expand All @@ -1668,7 +1667,44 @@ func TestEnvoyProxyProvider(t *testing.T) {
},
}
},
wantErrors: []string{"Image must include a tag and allowed characters only (e.g., 'repo:tag')."},
wantErrors: []string{},
},
{
desc: "valid: imageRepository set without tag, image not set",
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("envoyproxy/envoy"),
},
},
},
},
}
},
wantErrors: []string{},
},
{
desc: "invalid: both image and imageRepository set",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{
Container: &egv1a1.KubernetesContainerSpec{
Image: ptr.To("envoyproxy/envoy:v1.2.3"),
ImageRepository: ptr.To("envoyproxy/envoy"),
},
},
},
},
}
},
wantErrors: []string{"Either image or imageRepository can be set."},
},
{
desc: "invalid: image ends with colon",
Expand Down
4 changes: 2 additions & 2 deletions test/helm/gateway-crds-helm/all.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24547,7 +24547,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down Expand Up @@ -28392,7 +28392,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down
4 changes: 2 additions & 2 deletions test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7235,7 +7235,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down Expand Up @@ -11080,7 +11080,7 @@ spec:
x-kubernetes-validations:
- message: Image must include a tag and allowed characters
only (e.g., 'repo:tag').
rule: self.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$')
rule: self.matches('^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+)?(@sha256:[a-z0-9]+)?$')
imageRepository:
description: |-
ImageRepository specifies the container image repository to be used without specifying a tag.
Expand Down