diff --git a/changelog/unreleased/configure-grpc-in-ocs.md b/changelog/unreleased/configure-grpc-in-ocs.md new file mode 100644 index 000000000..1b6011ef6 --- /dev/null +++ b/changelog/unreleased/configure-grpc-in-ocs.md @@ -0,0 +1,5 @@ +Enhancement: Configure GRPC in ocs + +Fixes a panic in ocs when running not in single binary + +https://github.com/owncloud/ocis/pull/6022 diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index 7c3b6c989..0abd76bdb 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -11,6 +11,7 @@ import ( "github.com/owncloud/ocis/v2/services/ocs/pkg/tracing" "github.com/oklog/run" + ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc" "github.com/owncloud/ocis/v2/services/ocs/pkg/config" "github.com/owncloud/ocis/v2/services/ocs/pkg/metrics" "github.com/owncloud/ocis/v2/services/ocs/pkg/server/debug" @@ -34,6 +35,11 @@ func Server(cfg *config.Config) *cli.Command { return err } + err = ogrpc.Configure(ogrpc.GetClientOptions(cfg.GRPCClientTLS)...) + if err != nil { + return err + } + var ( gr = run.Group{} ctx, cancel = func() (context.Context, context.CancelFunc) { diff --git a/services/ocs/pkg/config/config.go b/services/ocs/pkg/config/config.go index c492fc8a5..1ee40a4c2 100644 --- a/services/ocs/pkg/config/config.go +++ b/services/ocs/pkg/config/config.go @@ -19,6 +19,8 @@ type Config struct { HTTP HTTP `yaml:"http"` + GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` + TokenManager *TokenManager `yaml:"token_manager"` Context context.Context `yaml:"-"` diff --git a/services/ocs/pkg/config/defaults/defaultconfig.go b/services/ocs/pkg/config/defaults/defaultconfig.go index a8796ff24..223ccefcb 100644 --- a/services/ocs/pkg/config/defaults/defaultconfig.go +++ b/services/ocs/pkg/config/defaults/defaultconfig.go @@ -3,6 +3,7 @@ package defaults import ( "strings" + "github.com/owncloud/ocis/v2/ocis-pkg/structs" "github.com/owncloud/ocis/v2/services/ocs/pkg/config" ) @@ -86,6 +87,10 @@ func EnsureDefaults(cfg *config.Config) { if cfg.Commons != nil { cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS } + + if cfg.GRPCClientTLS == nil && cfg.Commons != nil { + cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS) + } } // Sanitize sanitizes the configuration