Skip to content

Commit c93246d

Browse files
committed
pass in gateway kind for annotations
1 parent ee7eeae commit c93246d

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

control-plane/controllers/resources/api-gateway-controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r *APIGatewayController) Reconcile(ctx context.Context, req ctrl.Request)
6363
if err := onCreateUpdate(ctx, r.Client, gatewayConfigs{
6464
gcc: gcc,
6565
gatewayConfig: r.GatewayConfig,
66-
}, resource); err != nil {
66+
}, resource, gateways.APIGatewayAnnotationKind); err != nil {
6767
logger.Error(err, "unable to create/update gateway")
6868
return ctrl.Result{}, err
6969
}

control-plane/controllers/resources/gateway_controller_crud.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ type gatewayConfigs struct {
3434
// 3. Service
3535
// 4. Role
3636
// 5. RoleBinding
37-
func onCreateUpdate[T gateways.Gateway](ctx context.Context, k8sClient client.Client, cfg gatewayConfigs, resource T) error {
38-
builder := gateways.NewGatewayBuilder[T](resource, cfg.gatewayConfig, cfg.gcc)
37+
func onCreateUpdate[T gateways.Gateway](ctx context.Context, k8sClient client.Client, cfg gatewayConfigs, resource T, gatewayKind string) error {
38+
builder := gateways.NewGatewayBuilder[T](resource, cfg.gatewayConfig, cfg.gcc, gatewayKind)
3939

4040
// Create ServiceAccount
4141
desiredAccount := builder.ServiceAccount()

control-plane/controllers/resources/mesh_gateway_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (r *MeshGatewayController) Reconcile(ctx context.Context, req ctrl.Request)
6464
if err := onCreateUpdate(ctx, r.Client, gatewayConfigs{
6565
gcc: gcc,
6666
gatewayConfig: r.GatewayConfig,
67-
}, resource); err != nil {
67+
}, resource, gateways.MeshGatewayAnnotationKind); err != nil {
6868
return ctrl.Result{}, err
6969
}
7070
}

control-plane/gateways/builder.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@ type Gateway interface {
2020
// This includes Deployment, Role, Service, and ServiceAccount resources.
2121
// Configuration is combined from the MeshGateway, GatewayConfig, and GatewayClassConfig.
2222
type gatewayBuilder[T Gateway] struct {
23-
gateway T
24-
gcc *meshv2beta1.GatewayClassConfig
25-
config GatewayConfig
23+
gateway T
24+
gcc *meshv2beta1.GatewayClassConfig
25+
config GatewayConfig
26+
gatewayKind string
2627
}
2728

2829
// NewGatewayBuilder returns a new meshGatewayBuilder for the given MeshGateway,
2930
// GatewayConfig, and GatewayClassConfig.
30-
func NewGatewayBuilder[T Gateway](gateway T, gatewayConfig GatewayConfig, gatewayClassConfig *meshv2beta1.GatewayClassConfig) *gatewayBuilder[T] {
31+
func NewGatewayBuilder[T Gateway](gateway T, gatewayConfig GatewayConfig, gatewayClassConfig *meshv2beta1.GatewayClassConfig, gatewayKind string) *gatewayBuilder[T] {
3132
return &gatewayBuilder[T]{
32-
gateway: gateway,
33-
config: gatewayConfig,
34-
gcc: gatewayClassConfig,
33+
gateway: gateway,
34+
config: gatewayConfig,
35+
gcc: gatewayClassConfig,
36+
gatewayKind: gatewayKind,
3537
}
3638
}

control-plane/gateways/deployment.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515

1616
const (
1717
globalDefaultInstances int32 = 1
18-
meshGatewayAnnotationKind = "mesh-gateway"
18+
MeshGatewayAnnotationKind = "mesh-gateway"
19+
APIGatewayAnnotationKind = "api-gateway"
1920
)
2021

2122
func (b *gatewayBuilder[T]) Deployment() (*appsv1.Deployment, error) {
@@ -67,7 +68,7 @@ func (b *gatewayBuilder[T]) deploymentSpec() (*appsv1.DeploymentSpec, error) {
6768
Annotations: map[string]string{
6869
// Indicate that this pod is a mesh gateway pod so that the Pod controller,
6970
// consul-k8s CLI, etc. can key off of it
70-
constants.AnnotationGatewayKind: meshGatewayAnnotationKind,
71+
constants.AnnotationGatewayKind: b.gatewayKind,
7172
// It's not logical to add a proxy sidecar since our workload is itself a proxy
7273
constants.AnnotationMeshInject: "false",
7374
// This functionality only applies when proxy sidecars are used

0 commit comments

Comments
 (0)