diff --git a/changelog/unreleased/configure-grpc-in-ocs.md b/changelog/unreleased/configure-grpc-in-ocs.md new file mode 100644 index 00000000000..1b6011ef6c0 --- /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 7c3b6c989b4..0abd76bdbb4 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 c492fc8a52f..1ee40a4c2d9 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 a8796ff24d5..223ccefcb5c 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