Skip to content

Commit 07ad2ea

Browse files
committed
chore: enable strict gw group validation
Signed-off-by: Sergei Lukianov <me@slukjanov.name>
1 parent 978195b commit 07ad2ea

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

api/gateway/v1alpha1/gateway_types.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"context"
88
"errors"
99
"fmt"
10-
"log/slog"
1110
"net"
1211
"net/netip"
1312
"regexp"
@@ -387,9 +386,7 @@ func (gw *Gateway) Validate(ctx context.Context, kube kclient.Reader) error {
387386
}
388387
for _, gwGroup := range gw.Spec.Groups {
389388
if !gwGroups[gwGroup.Name] {
390-
// TODO enable validation back after it's supplied by the fabricator
391-
slog.Warn("Gateway group not found", "gateway", gw.Name, "group", gwGroup.Name)
392-
// return fmt.Errorf("gateway group %s not found: %w", gwGroup.Name, ErrInvalidGW)
389+
return fmt.Errorf("gateway group %s not found: %w", gwGroup.Name, ErrInvalidGW)
393390
}
394391
}
395392
}

api/gateway/v1alpha1/peering_types.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ package v1alpha1
66
import (
77
"context"
88
"fmt"
9-
"log/slog"
109
"maps"
1110
"net/netip"
1211
"slices"
1312
"strconv"
1413
"strings"
1514
"time"
1615

16+
kapierrors "k8s.io/apimachinery/pkg/api/errors"
1717
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1818
kclient "sigs.k8s.io/controller-runtime/pkg/client"
1919
)
@@ -265,13 +265,11 @@ func (p *Peering) Validate(ctx context.Context, kube kclient.Reader) error {
265265
if kube != nil {
266266
gwGroup := &GatewayGroup{}
267267
if err := kube.Get(ctx, kclient.ObjectKey{Name: p.Spec.GatewayGroup, Namespace: p.Namespace}, gwGroup); err != nil {
268-
// TODO enable validation back after it's supplied by the fabricator
269-
slog.Warn("Failed to get Gateway group", "name", p.Spec.GatewayGroup, "error", err.Error())
270-
// if kapierrors.IsNotFound(err) {
271-
// return fmt.Errorf("gateway group %s not found", p.Spec.GatewayGroup) //nolint:err113
272-
// }
268+
if kapierrors.IsNotFound(err) {
269+
return fmt.Errorf("gateway group %s not found", p.Spec.GatewayGroup) //nolint:err113
270+
}
273271

274-
// return fmt.Errorf("failed to get gateway group %s: %w", p.Spec.GatewayGroup, err)
272+
return fmt.Errorf("failed to get gateway group %s: %w", p.Spec.GatewayGroup, err)
275273
}
276274
}
277275

0 commit comments

Comments
 (0)