From 56d92a3a07a5d85081f5d8943fcc044deed13aa2 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Wed, 23 Jun 2021 13:19:45 +0200 Subject: [PATCH] further hook up app provider --- docs/extensions/storage/ports.md | 2 ++ ocis/pkg/command/storageappprovider.go | 45 ++++++++++++++++++++++++++ ocis/pkg/runtime/service/service.go | 1 + storage/pkg/command/appprovider.go | 1 + storage/pkg/config/config.go | 1 + storage/pkg/flagset/appprovider.go | 13 ++++++-- storage/pkg/flagset/gateway.go | 7 ++++ 7 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 ocis/pkg/command/storageappprovider.go diff --git a/docs/extensions/storage/ports.md b/docs/extensions/storage/ports.md index 83ef871b860..b50b0f6b3b3 100644 --- a/docs/extensions/storage/ports.md +++ b/docs/extensions/storage/ports.md @@ -34,6 +34,8 @@ For now, the storage service uses these ports to preconfigure those services: | 9159 | storage users debug | | 9160 | groups | | 9161 | groups debug | +| 9164 | appprovider | +| 9165 | appprovider debug | | 9178 | storage public link | | 9179 | storage public link data | | 9215 | storage meta grpc | diff --git a/ocis/pkg/command/storageappprovider.go b/ocis/pkg/command/storageappprovider.go new file mode 100644 index 00000000000..883069ab747 --- /dev/null +++ b/ocis/pkg/command/storageappprovider.go @@ -0,0 +1,45 @@ +// +build !simple + +package command + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/owncloud/ocis/ocis/pkg/register" + "github.com/owncloud/ocis/storage/pkg/command" + svcconfig "github.com/owncloud/ocis/storage/pkg/config" + "github.com/owncloud/ocis/storage/pkg/flagset" +) + +// StorageAppProviderCommand is the entrypoint for the reva-app-provider command. +func StorageAppProviderCommand(cfg *config.Config) *cli.Command { + return &cli.Command{ + Name: "storage-app-provider", + Usage: "Start storage app-provider service", + Category: "Extensions", + Flags: flagset.AppProviderWithConfig(cfg.Storage), + Action: func(c *cli.Context) error { + origCmd := command.AppProvider(configureStorageAppProvider(cfg)) + return handleOriginalAction(c, origCmd) + }, + } +} + +func configureStorageAppProvider(cfg *config.Config) *svcconfig.Config { + cfg.Storage.Log.Level = cfg.Log.Level + cfg.Storage.Log.Pretty = cfg.Log.Pretty + cfg.Storage.Log.Color = cfg.Log.Color + + if cfg.Tracing.Enabled { + cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled + cfg.Storage.Tracing.Type = cfg.Tracing.Type + cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint + cfg.Storage.Tracing.Collector = cfg.Tracing.Collector + } + + return cfg.Storage +} + +func init() { + register.AddCommand(StorageAppProviderCommand) +} diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 268d7473fda..71f324107c9 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -102,6 +102,7 @@ func NewService(options ...Option) (*Service, error) { s.ServicesRegistry["storage-home"] = storage.NewStorageHome s.ServicesRegistry["storage-users"] = storage.NewStorageUsers s.ServicesRegistry["storage-public-link"] = storage.NewStoragePublicLink + s.ServicesRegistry["storage-appprovider"] = storage.NewAppProvider // populate delayed services s.Delayed["storage-sharing"] = storage.NewSharing diff --git a/storage/pkg/command/appprovider.go b/storage/pkg/command/appprovider.go index aead70f5735..5532bc804fe 100644 --- a/storage/pkg/command/appprovider.go +++ b/storage/pkg/command/appprovider.go @@ -106,6 +106,7 @@ func appProviderConfigFromStruct(c *cli.Context, cfg *config.Config) map[string] // TODO build services dynamically "services": map[string]interface{}{ "appprovider": map[string]interface{}{ + "driver": cfg.Reva.AppProvider.Driver, "iopsecret": cfg.Reva.AppProvider.IopSecret, "wopiurl": cfg.Reva.AppProvider.WopiUrl, "wopibridgeurl": cfg.Reva.AppProvider.WopiBridgeUrl, diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 99590d12300..0713fb66944 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -42,6 +42,7 @@ type StorageRegistry struct { // AppProvider defines the available app provider configuration type AppProvider struct { Port + Driver string IopSecret string WopiUrl string WopiBridgeUrl string diff --git a/storage/pkg/flagset/appprovider.go b/storage/pkg/flagset/appprovider.go index f057a3fc220..3caf5fd20c6 100644 --- a/storage/pkg/flagset/appprovider.go +++ b/storage/pkg/flagset/appprovider.go @@ -13,7 +13,7 @@ func AppProviderWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.DebugAddr, "0.0.0.0:9147"), + Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.DebugAddr, "0.0.0.0:9165"), Usage: "Address to bind debug server", EnvVars: []string{"APP_PROVIDER_BASIC_DEBUG_ADDR"}, Destination: &cfg.Reva.AppProvider.DebugAddr, @@ -34,7 +34,7 @@ func AppProviderWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "addr", - Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.GRPCAddr, "0.0.0.0:9146"), + Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.GRPCAddr, "0.0.0.0:9164"), Usage: "Address to bind storage service", EnvVars: []string{"APP_PROVIDER_BASIC_GRPC_ADDR"}, Destination: &cfg.Reva.AppProvider.GRPCAddr, @@ -45,10 +45,17 @@ func AppProviderWithConfig(cfg *config.Config) []cli.Flag { Usage: "--service appprovider [--service otherservice]", EnvVars: []string{"APP_PROVIDER_BASIC_SERVICES"}, }, + &cli.StringFlag{ + Name: "driver", + Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.Driver, "demo"), + Usage: "app provider driver", + EnvVars: []string{"APP_PROVIDER_DRIVER"}, + Destination: &cfg.Reva.AppProvider.Driver, + }, &cli.StringFlag{ Name: "iopsecret", Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.IopSecret, ""), - Usage: "Iop Secret", + Usage: "IOP Secret (Shared with WOPI server)", EnvVars: []string{"APP_PROVIDER_IOP_SECRET"}, Destination: &cfg.Reva.AppProvider.IopSecret, }, diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index af603478feb..ce45fbbb41a 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -193,6 +193,13 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_SHARING_ENDPOINT"}, Destination: &cfg.Reva.Sharing.Endpoint, }, + &cli.StringFlag{ + Name: "appprovider-endpoint", + Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.Endpoint, "localhost:9164"), + Usage: "endpoint to use for the app provider", + EnvVars: []string{"STORAGE_APPPROVIDER_ENDPOINT"}, + Destination: &cfg.Reva.AppProvider.Endpoint, + }, // register home storage