Skip to content

Commit

Permalink
fix(gateway): MeshGateway tags validation consistent with MeshRoute t…
Browse files Browse the repository at this point in the history
…ags validation

Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com>
  • Loading branch information
Automaat committed Oct 21, 2024
1 parent 7e9382e commit 57cf529
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/core/resources/apis/mesh/gateway_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (g *MeshGatewayResource) Validate() error {

// The top-level selector is used to bind the gateway to a set
// of dataplanes, so the service tag must not be used here.
err.Add(ValidateSelector(
err.Add(ValidateTags(
validators.RootedAt("tags"),
g.Spec.GetTags(),
ValidateTagsOpts{
Expand Down
20 changes: 20 additions & 0 deletions pkg/core/resources/apis/mesh/gateway_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ conf:
tags:
name: https
`),
ErrorCase("has tag with invalid characters",
validators.Violation{
Field: `tags["port"]`,
Message: `tag value must consist of alphanumeric characters, dots, dashes and underscores`,
}, `
type: MeshGateway
name: gateway
mesh: default
selectors:
- match:
kuma.io/service: gateway
tags:
port: http/443
conf:
listeners:
- port: 443
protocol: HTTP
tags:
name: https
`),

ErrorCase("doesn't have a configuration spec",
validators.Violation{
Expand Down

0 comments on commit 57cf529

Please sign in to comment.