Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ishustava committed Aug 17, 2023
1 parent 130f616 commit 73ee8f0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ func (s *Server) GetEnvoyBootstrapParams(ctx context.Context, req *pbdataplane.G
}
}

var accessLogs []string
if dynamicCfg != nil {
accessLogs = makeAccessLogs(dynamicCfg.GetAccessLogs(), logger)
}
accessLogs := makeAccessLogs(dynamicCfg.GetAccessLogs(), logger)

return &pbdataplane.GetEnvoyBootstrapParamsResponse{
ClusterName: workload.Identity,
Expand Down Expand Up @@ -190,31 +187,12 @@ func (s *Server) GetEnvoyBootstrapParams(ctx context.Context, req *pbdataplane.G
Namespace: svc.EnterpriseMeta.NamespaceOrDefault(),
Config: bootstrapConfig,
Datacenter: s.Datacenter,
ServiceKind: convertToResponseServiceKind(svc.ServiceKind),
NodeName: svc.Node,
NodeId: string(svc.ID),
AccessLogs: accessLogs,
}, nil
}

func convertToResponseServiceKind(serviceKind structs.ServiceKind) (respKind pbdataplane.ServiceKind) {
switch serviceKind {
case structs.ServiceKindConnectProxy:
respKind = pbdataplane.ServiceKind_SERVICE_KIND_CONNECT_PROXY
case structs.ServiceKindMeshGateway:
respKind = pbdataplane.ServiceKind_SERVICE_KIND_MESH_GATEWAY
case structs.ServiceKindTerminatingGateway:
respKind = pbdataplane.ServiceKind_SERVICE_KIND_TERMINATING_GATEWAY
case structs.ServiceKindIngressGateway:
respKind = pbdataplane.ServiceKind_SERVICE_KIND_INGRESS_GATEWAY
case structs.ServiceKindAPIGateway:
respKind = pbdataplane.ServiceKind_SERVICE_KIND_API_GATEWAY
case structs.ServiceKindTypical:
respKind = pbdataplane.ServiceKind_SERVICE_KIND_TYPICAL
}
return
}

func makeAccessLogs(logs structs.AccessLogs, logger hclog.Logger) []string {
var accessLogs []string
if logs.GetEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func TestGetEnvoyBootstrapParams_Success(t *testing.T) {
require.Equal(t, tc.registerReq.EnterpriseMeta.PartitionOrDefault(), resp.Partition)
require.Equal(t, tc.registerReq.EnterpriseMeta.NamespaceOrDefault(), resp.Namespace)
requireConfigField(t, resp, proxyConfigKey, structpb.NewStringValue(proxyConfigValue))
require.Equal(t, convertToResponseServiceKind(tc.registerReq.Service.Kind), resp.ServiceKind)
require.Equal(t, tc.registerReq.Node, resp.NodeName)
require.Equal(t, string(tc.registerReq.ID), resp.NodeId)

Expand Down

0 comments on commit 73ee8f0

Please sign in to comment.