Skip to content

Commit 4069e51

Browse files
committed
vibe coding 1
1 parent e410175 commit 4069e51

File tree

9 files changed

+784
-1088
lines changed

9 files changed

+784
-1088
lines changed

pkg/controller/controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,11 @@ func startCloudControllerManager(ctx context.Context, clusterName string, config
293293

294294
gatewayController, err := gateway.New(
295295
clusterName,
296+
kubeClient,
296297
gwClient,
297298
sharedInformers.Core().V1().Namespaces(),
298299
sharedInformers.Core().V1().Services(),
300+
sharedInformers.Core().V1().Secrets(),
299301
sharedGwInformers.Gateway().V1().Gateways(),
300302
sharedGwInformers.Gateway().V1().HTTPRoutes(),
301303
sharedGwInformers.Gateway().V1().GRPCRoutes(),

pkg/gateway/backendref.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
11
package gateway
2+
3+
import (
4+
"fmt"
5+
6+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
7+
)
8+
9+
// backendRefToClusterName generates a unique Envoy cluster name from a Gateway API BackendRef.
10+
func backendRefToClusterName(defaultNamespace string, backendRef gatewayv1.BackendRef) (string, error) {
11+
if backendRef.Kind != nil && *backendRef.Kind != "Service" {
12+
return "", fmt.Errorf("unsupported backend kind: %s", *backendRef.Kind)
13+
}
14+
if backendRef.Port == nil {
15+
return "", fmt.Errorf("backend port must be specified")
16+
}
17+
18+
namespace := defaultNamespace
19+
if backendRef.Namespace != nil {
20+
namespace = string(*backendRef.Namespace)
21+
}
22+
23+
port := int32(*backendRef.Port)
24+
group := "core"
25+
if backendRef.Group != nil && *backendRef.Group != "" {
26+
group = string(*backendRef.Group)
27+
}
28+
kind := "Service"
29+
if backendRef.Kind != nil && *backendRef.Kind != "" {
30+
kind = string(*backendRef.Kind)
31+
}
32+
33+
// Format: <namespace>_<name>_<group>_<kind>_<port>
34+
return fmt.Sprintf("%s_%s_%s_%s_%d", namespace, backendRef.Name, group, kind, port), nil
35+
}

0 commit comments

Comments
 (0)