diff --git a/ocis/pkg/command/appprovider.go b/ocis/pkg/command/appprovider.go new file mode 100644 index 00000000000..f43a491e679 --- /dev/null +++ b/ocis/pkg/command/appprovider.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" +) + +// AppProviderCommand is the entrypoint for the reva-gateway command. +func AppProviderCommand(cfg *config.Config) *cli.Command { + return &cli.Command{ + Name: "app-provider", + Usage: "Start appprovider for providing apps", + Category: "Extensions", + Flags: flagset.AppProviderWithConfig(cfg.Storage), + Action: func(c *cli.Context) error { + origCmd := command.AppProvider(configureAppProvider(cfg)) + return handleOriginalAction(c, origCmd) + }, + } +} + +func configureAppProvider(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(AppProviderCommand) +} diff --git a/storage/pkg/command/appprovider.go b/storage/pkg/command/appprovider.go index 5532bc804fe..ef4eb3ccbda 100644 --- a/storage/pkg/command/appprovider.go +++ b/storage/pkg/command/appprovider.go @@ -5,7 +5,6 @@ import ( "flag" "os" "path" - "path/filepath" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" @@ -38,13 +37,6 @@ func AppProvider(cfg *config.Config) *cli.Command { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - // pre-create folders - if cfg.Reva.AuthProvider.Driver == "json" && cfg.Reva.AuthProvider.JSON != "" { - if err := os.MkdirAll(filepath.Dir(cfg.Reva.AuthProvider.JSON), os.FileMode(0700)); err != nil { - return err - } - } - uuid := uuid.Must(uuid.NewV4()) pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") @@ -78,7 +70,7 @@ func AppProvider(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Reva.StorageMetadata.Supervised { + if !cfg.Reva.AppProvider.Supervised { sync.Trap(&gr, cancel) } @@ -107,6 +99,8 @@ func appProviderConfigFromStruct(c *cli.Context, cfg *config.Config) map[string] "services": map[string]interface{}{ "appprovider": map[string]interface{}{ "driver": cfg.Reva.AppProvider.Driver, + "demo": map[string]interface{}{}, + "wopiinsecure": cfg.Reva.AppProvider.WopiInsecure, "iopsecret": cfg.Reva.AppProvider.IopSecret, "wopiurl": cfg.Reva.AppProvider.WopiUrl, "wopibridgeurl": cfg.Reva.AppProvider.WopiBridgeUrl, diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index 935f23e200c..e63753c7802 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -160,6 +160,15 @@ func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logg }, }, }, + "appregistry": map[string]interface{}{ + "driver": "static", + "static": map[string]interface{}{ + "rules": map[string]interface{}{ + //TODO: add types configuration + "application/vnd.oasis.opendocument.text": cfg.Reva.AppProvider.Endpoint, + }, + }, + }, "storageregistry": map[string]interface{}{ "driver": cfg.Reva.StorageRegistry.Driver, "drivers": map[string]interface{}{ diff --git a/storage/pkg/command/root.go b/storage/pkg/command/root.go index eb20e0f8df6..1c99f2aad0d 100644 --- a/storage/pkg/command/root.go +++ b/storage/pkg/command/root.go @@ -76,6 +76,7 @@ func Execute(cfg *config.Config) error { Gateway(cfg), Users(cfg), Groups(cfg), + AppProvider(cfg), AuthBasic(cfg), AuthBearer(cfg), Sharing(cfg), diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 0713fb66944..d7e7f7449bf 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -44,6 +44,7 @@ type AppProvider struct { Port Driver string IopSecret string + WopiInsecure bool WopiUrl string WopiBridgeUrl string } diff --git a/storage/pkg/flagset/appprovider.go b/storage/pkg/flagset/appprovider.go index 3caf5fd20c6..2a839b176a6 100644 --- a/storage/pkg/flagset/appprovider.go +++ b/storage/pkg/flagset/appprovider.go @@ -59,6 +59,13 @@ func AppProviderWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"APP_PROVIDER_IOP_SECRET"}, Destination: &cfg.Reva.AppProvider.IopSecret, }, + &cli.BoolFlag{ + Name: "wopiinsecure", + Value: flags.OverrideDefaultBool(cfg.Reva.AppProvider.WopiInsecure, false), + Usage: "Disable SSL certificate verification of WOPI server and WOPI bridge", + EnvVars: []string{"APP_PROVIDER_WOPI_INSECURE"}, + Destination: &cfg.Reva.AppProvider.WopiInsecure, + }, &cli.StringFlag{ Name: "wopiurl", Value: flags.OverrideDefaultString(cfg.Reva.AppProvider.WopiUrl, ""), diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index ce45fbbb41a..ba0585996b7 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -62,7 +62,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringSliceFlag{ Name: "service", - Value: cli.NewStringSlice("gateway", "authregistry", "storageregistry"), // TODO appregistry + Value: cli.NewStringSlice("gateway", "authregistry", "storageregistry", "appregistry"), Usage: "--service gateway [--service authregistry]", EnvVars: []string{"STORAGE_GATEWAY_SERVICES"}, },