From 99cf421e7bccde3c062bbbade325fb6bab740a49 Mon Sep 17 00:00:00 2001 From: Andrew Stucki Date: Thu, 9 Feb 2023 15:28:04 -0500 Subject: [PATCH] Add some fixes to allow for registering via consul connect envoy -gateway api (#16219) * Add some fixes to allow for registering via consul connect envoy -gateway api * Fix infinite recursion --------- Co-authored-by: Nathan Coleman --- api/agent.go | 5 ++++ api/config_entry_routes.go | 46 ++++++---------------------------- command/connect/envoy/envoy.go | 3 ++- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/api/agent.go b/api/agent.go index 6e2883a411..7904e7b71f 100644 --- a/api/agent.go +++ b/api/agent.go @@ -37,6 +37,11 @@ const ( // This service will ingress connections based of configuration defined in // the ingress-gateway config entry. ServiceKindIngressGateway ServiceKind = "ingress-gateway" + + // ServiceKindAPIGateway is an API Gateway for the Connect feature. + // This service will ingress connections based of configuration defined in + // the api-gateway config entry. + ServiceKindAPIGateway ServiceKind = "api-gateway" ) // UpstreamDestType is the type of upstream discovery mechanism. diff --git a/api/config_entry_routes.go b/api/config_entry_routes.go index 6a945c408f..d074405710 100644 --- a/api/config_entry_routes.go +++ b/api/config_entry_routes.go @@ -38,45 +38,13 @@ type TCPRouteConfigEntry struct { Namespace string `json:",omitempty"` } -func (a *TCPRouteConfigEntry) GetKind() string { - return TCPRoute -} - -func (a *TCPRouteConfigEntry) GetName() string { - if a != nil { - return "" - } - return a.Name -} - -func (a *TCPRouteConfigEntry) GetPartition() string { - if a != nil { - return "" - } - return a.Partition -} - -func (a *TCPRouteConfigEntry) GetNamespace() string { - if a != nil { - return "" - } - return a.GetNamespace() -} - -func (a *TCPRouteConfigEntry) GetMeta() map[string]string { - if a != nil { - return nil - } - return a.GetMeta() -} - -func (a *TCPRouteConfigEntry) GetCreateIndex() uint64 { - return a.CreateIndex -} - -func (a *TCPRouteConfigEntry) GetModifyIndex() uint64 { - return a.ModifyIndex -} +func (a *TCPRouteConfigEntry) GetKind() string { return TCPRoute } +func (a *TCPRouteConfigEntry) GetName() string { return a.Name } +func (a *TCPRouteConfigEntry) GetPartition() string { return a.Partition } +func (a *TCPRouteConfigEntry) GetNamespace() string { return a.Namespace } +func (a *TCPRouteConfigEntry) GetMeta() map[string]string { return a.Meta } +func (a *TCPRouteConfigEntry) GetCreateIndex() uint64 { return a.CreateIndex } +func (a *TCPRouteConfigEntry) GetModifyIndex() uint64 { return a.ModifyIndex } // TCPService is a service reference for a TCPRoute type TCPService struct { diff --git a/command/connect/envoy/envoy.go b/command/connect/envoy/envoy.go index 84f2c71444..c265c0ba9c 100644 --- a/command/connect/envoy/envoy.go +++ b/command/connect/envoy/envoy.go @@ -92,6 +92,7 @@ const meshGatewayVal = "mesh" var defaultEnvoyVersion = xdscommon.EnvoyVersions[0] var supportedGateways = map[string]api.ServiceKind{ + "api": api.ServiceKindAPIGateway, "mesh": api.ServiceKindMeshGateway, "terminating": api.ServiceKindTerminatingGateway, "ingress": api.ServiceKindIngressGateway, @@ -330,7 +331,7 @@ func (c *cmd) run(args []string) int { if c.gateway != "" { kind, ok := supportedGateways[c.gateway] if !ok { - c.UI.Error("Gateway must be one of: terminating, mesh, or ingress") + c.UI.Error("Gateway must be one of: api, terminating, mesh, or ingress") return 1 } c.gatewayKind = kind