From 40734f27c78b7b426149a162963b04db769bec87 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Wed, 25 Mar 2020 11:17:38 +0100 Subject: [PATCH] fix configs --- pkg/admin/api/api.go | 8 ++++---- pkg/admin/api/grpc/gateway.go | 9 ++------- pkg/admin/api/grpc/server.go | 9 +++++---- pkg/auth/api/api.go | 9 +++++---- pkg/auth/api/grpc/gateway.go | 15 ++++++--------- pkg/auth/api/grpc/server.go | 14 +++++--------- pkg/management/api/api.go | 9 +++++---- pkg/management/api/grpc/gateway.go | 9 ++------- pkg/management/api/grpc/server.go | 14 ++++---------- 9 files changed, 38 insertions(+), 58 deletions(-) diff --git a/pkg/admin/api/api.go b/pkg/admin/api/api.go index 54ba31a3b1..bebc1ce5ab 100644 --- a/pkg/admin/api/api.go +++ b/pkg/admin/api/api.go @@ -2,6 +2,7 @@ package api import ( "context" + grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/pkg/admin/api/grpc" ) @@ -12,14 +13,13 @@ type API struct { } type Config struct { - GRPCServer grpc.Config - Gateway grpc.GatewayConfig + GRPC grpc_util.Config } func Start(ctx context.Context, conf *Config) error { api := &API{ - grpcServer: *grpc.StartServer(conf.GRPCServer), - gateway: *grpc.StartGateway(conf.Gateway), + grpcServer: *grpc.StartServer(conf.GRPC.ToServerConfig()), + gateway: *grpc.StartGateway(conf.GRPC.ToGatewayConfig()), } server.StartServer(ctx, &api.grpcServer) server.StartGateway(ctx, &api.gateway) diff --git a/pkg/admin/api/grpc/gateway.go b/pkg/admin/api/grpc/gateway.go index 833285b5a8..bd88fbbe56 100644 --- a/pkg/admin/api/grpc/gateway.go +++ b/pkg/admin/api/grpc/gateway.go @@ -1,24 +1,19 @@ package grpc import ( + grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server" "github.com/grpc-ecosystem/grpc-gateway/runtime" "strings" ) -type GatewayConfig struct { - Port string - GRPCEndpoint string - CustomHeaders []string -} - type Gateway struct { grpcEndpoint string port string cutomHeaders []string } -func StartGateway(conf GatewayConfig) *Gateway { +func StartGateway(conf *grpc_util.GatewayConfig) *Gateway { return &Gateway{ grpcEndpoint: conf.GRPCEndpoint, port: conf.Port, diff --git a/pkg/admin/api/grpc/server.go b/pkg/admin/api/grpc/server.go index e31a3edd1b..e463dea1d8 100644 --- a/pkg/admin/api/grpc/server.go +++ b/pkg/admin/api/grpc/server.go @@ -1,9 +1,11 @@ package grpc import ( - "github.com/caos/zitadel/internal/api/grpc/server/middleware" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" "google.golang.org/grpc" + + grpc_util "github.com/caos/zitadel/internal/api/grpc" + "github.com/caos/zitadel/internal/api/grpc/server/middleware" ) var _ AdminServiceServer = (*Server)(nil) @@ -18,10 +20,9 @@ type Server struct { searchLimit int } -func StartServer(conf Config) *Server { +func StartServer(conf *grpc_util.ServerConfig) *Server { return &Server{ - port: conf.Port, - searchLimit: conf.SearchLimit, + port: conf.Port, } } diff --git a/pkg/auth/api/api.go b/pkg/auth/api/api.go index bb6db2d066..204b3a331f 100644 --- a/pkg/auth/api/api.go +++ b/pkg/auth/api/api.go @@ -2,6 +2,8 @@ package api import ( "context" + + grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/pkg/auth/api/grpc" ) @@ -12,14 +14,13 @@ type API struct { } type Config struct { - GRPCServer grpc.Config - Gateway grpc.GatewayConfig + GRPC grpc_util.Config } func Start(ctx context.Context, conf *Config) error { api := &API{ - grpcServer: *grpc.StartServer(conf.GRPCServer), - gateway: *grpc.StartGateway(conf.Gateway), + grpcServer: *grpc.StartServer(conf.GRPC.ToServerConfig()), + gateway: *grpc.StartGateway(conf.GRPC.ToGatewayConfig()), } server.StartServer(ctx, &api.grpcServer) server.StartGateway(ctx, &api.gateway) diff --git a/pkg/auth/api/grpc/gateway.go b/pkg/auth/api/grpc/gateway.go index c8b845e6a4..14958b8a7b 100644 --- a/pkg/auth/api/grpc/gateway.go +++ b/pkg/auth/api/grpc/gateway.go @@ -1,16 +1,13 @@ package grpc import ( - "github.com/caos/zitadel/internal/api/grpc/server" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "strings" -) -type GatewayConfig struct { - Port string - GRPCEndpoint string - CustomHeaders []string -} + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + grpc_util "github.com/caos/zitadel/internal/api/grpc" + "github.com/caos/zitadel/internal/api/grpc/server" +) type Gateway struct { grpcEndpoint string @@ -18,7 +15,7 @@ type Gateway struct { cutomHeaders []string } -func StartGateway(conf GatewayConfig) *Gateway { +func StartGateway(conf *grpc_util.GatewayConfig) *Gateway { return &Gateway{ grpcEndpoint: conf.GRPCEndpoint, port: conf.Port, diff --git a/pkg/auth/api/grpc/server.go b/pkg/auth/api/grpc/server.go index 0a60ba96d9..214e4445c9 100644 --- a/pkg/auth/api/grpc/server.go +++ b/pkg/auth/api/grpc/server.go @@ -1,27 +1,23 @@ package grpc import ( - "github.com/caos/zitadel/internal/api/grpc/server/middleware" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" "google.golang.org/grpc" + + grpc_util "github.com/caos/zitadel/internal/api/grpc" + "github.com/caos/zitadel/internal/api/grpc/server/middleware" ) var _ AuthServiceServer = (*Server)(nil) -type Config struct { - Port string - SearchLimit int -} - type Server struct { port string searchLimit int } -func StartServer(conf Config) *Server { +func StartServer(conf *grpc_util.ServerConfig) *Server { return &Server{ - port: conf.Port, - searchLimit: conf.SearchLimit, + port: conf.Port, } } diff --git a/pkg/management/api/api.go b/pkg/management/api/api.go index 9e874b2828..92b494410a 100644 --- a/pkg/management/api/api.go +++ b/pkg/management/api/api.go @@ -2,6 +2,8 @@ package api import ( "context" + + grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/pkg/management/api/grpc" ) @@ -12,14 +14,13 @@ type API struct { } type Config struct { - GRPCServer grpc.Config - Gateway grpc.GatewayConfig + GRPC grpc_util.Config } func Start(ctx context.Context, conf *Config) error { api := &API{ - grpcServer: *grpc.StartServer(conf.GRPCServer), - gateway: *grpc.StartGateway(conf.Gateway), + grpcServer: *grpc.StartServer(conf.GRPC.ToServerConfig()), + gateway: *grpc.StartGateway(conf.GRPC.ToGatewayConfig()), } server.StartServer(ctx, &api.grpcServer) server.StartGateway(ctx, &api.gateway) diff --git a/pkg/management/api/grpc/gateway.go b/pkg/management/api/grpc/gateway.go index 8884d8e5f5..77b5486165 100644 --- a/pkg/management/api/grpc/gateway.go +++ b/pkg/management/api/grpc/gateway.go @@ -1,24 +1,19 @@ package grpc import ( + grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server" "github.com/grpc-ecosystem/grpc-gateway/runtime" "strings" ) -type GatewayConfig struct { - Port string - GRPCEndpoint string - CustomHeaders []string -} - type Gateway struct { grpcEndpoint string port string cutomHeaders []string } -func StartGateway(conf GatewayConfig) *Gateway { +func StartGateway(conf *grpc_util.GatewayConfig) *Gateway { return &Gateway{ grpcEndpoint: conf.GRPCEndpoint, port: conf.Port, diff --git a/pkg/management/api/grpc/server.go b/pkg/management/api/grpc/server.go index 07981551fb..4ed734c79e 100644 --- a/pkg/management/api/grpc/server.go +++ b/pkg/management/api/grpc/server.go @@ -1,6 +1,7 @@ package grpc import ( + grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server/middleware" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" "google.golang.org/grpc" @@ -8,20 +9,13 @@ import ( var _ ManagementServiceServer = (*Server)(nil) -type Config struct { - Port string - SearchLimit int -} - type Server struct { - port string - searchLimit int + port string } -func StartServer(conf Config) *Server { +func StartServer(conf *grpc_util.ServerConfig) *Server { return &Server{ - port: conf.Port, - searchLimit: conf.SearchLimit, + port: conf.Port, } }