Skip to content

Commit

Permalink
Add some fixes to allow for registering via consul connect envoy -gat…
Browse files Browse the repository at this point in the history
…eway api (#16219)

* Add some fixes to allow for registering via consul connect envoy -gateway api

* Fix infinite recursion

---------

Co-authored-by: Nathan Coleman <[email protected]>
  • Loading branch information
Andrew Stucki and nathancoleman authored Feb 9, 2023
1 parent ba862ab commit 99cf421
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 40 deletions.
5 changes: 5 additions & 0 deletions api/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
46 changes: 7 additions & 39 deletions api/config_entry_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion command/connect/envoy/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 99cf421

Please sign in to comment.