Skip to content

Commit 21ba0af

Browse files
committed
Add validate gateway logic
1 parent e002b4e commit 21ba0af

File tree

2 files changed

+14
-41
lines changed

2 files changed

+14
-41
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

pkg/k8s/utils.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package k8s
22

33
import (
44
"context"
5+
6+
"github.com/aws/aws-application-networking-k8s/pkg/config"
57
apierrors "k8s.io/apimachinery/pkg/api/errors"
68
"k8s.io/apimachinery/pkg/runtime/schema"
79
"k8s.io/apimachinery/pkg/types"
810
"k8s.io/client-go/discovery"
911
ctrl "sigs.k8s.io/controller-runtime"
12+
1013
"sigs.k8s.io/controller-runtime/pkg/client"
1114
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
1215
)
@@ -53,6 +56,17 @@ func IsGVKSupported(mgr ctrl.Manager, groupVersion string, kind string) (bool, e
5356
return false, nil
5457
}
5558

59+
// validate if the gateway is managed by the lattice gateway controller
60+
func IsManagedGateway(ctx context.Context, c client.Client, gw *gwv1.Gateway) bool {
61+
gwClass := &gwv1.GatewayClass{}
62+
// GatewayClass is cluster-scoped resource, so we don't need to specify namespace
63+
err := c.Get(ctx, client.ObjectKey{Name: string(gw.Spec.GatewayClassName)}, gwClass)
64+
if err != nil {
65+
return false
66+
}
67+
return gwClass.Spec.ControllerName == config.LatticeGatewayControllerName
68+
}
69+
5670
func ObjExists(ctx context.Context, c client.Client, key types.NamespacedName, obj client.Object) (bool, error) {
5771
err := c.Get(ctx, key, obj)
5872
if err != nil {

0 commit comments

Comments
 (0)