mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-29 23:39:35 -05:00
rework PR
This commit is contained in:
@@ -186,7 +186,7 @@ func Frontend(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
},
|
||||
"notifications": map[string]interface{}{
|
||||
"endpoints": []string{"list", "get", "delete"},
|
||||
"endpoints": []string{"disable"},
|
||||
},
|
||||
},
|
||||
"version": map[string]interface{}{
|
||||
|
||||
+17
-12
@@ -104,6 +104,8 @@ func Gateway(cfg *config.Config) *cli.Command {
|
||||
"commit_share_to_storage_grant": cfg.Reva.Gateway.CommitShareToStorageGrant,
|
||||
"commit_share_to_storage_ref": cfg.Reva.Gateway.CommitShareToStorageRef,
|
||||
"share_folder": cfg.Reva.Gateway.ShareFolder, // ShareFolder is the location where to create shares in the recipient's storage provider.
|
||||
// public links
|
||||
"link_grants_file": cfg.Reva.Gateway.LinkGrants,
|
||||
// other
|
||||
"disable_home_creation_on_login": cfg.Reva.Gateway.DisableHomeCreationOnLogin,
|
||||
"datagateway": cfg.Reva.Frontend.URL,
|
||||
@@ -115,8 +117,9 @@ func Gateway(cfg *config.Config) *cli.Command {
|
||||
"drivers": map[string]interface{}{
|
||||
"static": map[string]interface{}{
|
||||
"rules": map[string]interface{}{
|
||||
"basic": cfg.Reva.AuthBasic.URL,
|
||||
"bearer": cfg.Reva.AuthBearer.URL,
|
||||
"basic": cfg.Reva.AuthBasic.URL,
|
||||
"bearer": cfg.Reva.AuthBearer.URL,
|
||||
"publicshares": cfg.Reva.StoragePublicLink.URL,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -131,16 +134,18 @@ func Gateway(cfg *config.Config) *cli.Command {
|
||||
cfg.Reva.StorageRoot.MountID: cfg.Reva.StorageRoot.URL,
|
||||
cfg.Reva.StorageHome.MountPath: cfg.Reva.StorageHome.URL,
|
||||
// the home storage has no mount id. In responses it returns the mount id of the actual storage
|
||||
cfg.Reva.StorageEOS.MountPath: cfg.Reva.StorageEOS.URL,
|
||||
cfg.Reva.StorageEOS.MountID: cfg.Reva.StorageEOS.URL,
|
||||
cfg.Reva.StorageOC.MountPath: cfg.Reva.StorageOC.URL,
|
||||
cfg.Reva.StorageOC.MountID: cfg.Reva.StorageOC.URL,
|
||||
cfg.Reva.StorageS3.MountPath: cfg.Reva.StorageS3.URL,
|
||||
cfg.Reva.StorageS3.MountID: cfg.Reva.StorageS3.URL,
|
||||
cfg.Reva.StorageWND.MountPath: cfg.Reva.StorageWND.URL,
|
||||
cfg.Reva.StorageWND.MountID: cfg.Reva.StorageWND.URL,
|
||||
cfg.Reva.StorageCustom.MountPath: cfg.Reva.StorageCustom.URL,
|
||||
cfg.Reva.StorageCustom.MountID: cfg.Reva.StorageCustom.URL,
|
||||
cfg.Reva.StorageEOS.MountPath: cfg.Reva.StorageEOS.URL,
|
||||
cfg.Reva.StorageEOS.MountID: cfg.Reva.StorageEOS.URL,
|
||||
cfg.Reva.StorageOC.MountPath: cfg.Reva.StorageOC.URL,
|
||||
cfg.Reva.StorageOC.MountID: cfg.Reva.StorageOC.URL,
|
||||
cfg.Reva.StorageS3.MountPath: cfg.Reva.StorageS3.URL,
|
||||
cfg.Reva.StorageS3.MountID: cfg.Reva.StorageS3.URL,
|
||||
cfg.Reva.StorageWND.MountPath: cfg.Reva.StorageWND.URL,
|
||||
cfg.Reva.StorageWND.MountID: cfg.Reva.StorageWND.URL,
|
||||
cfg.Reva.StorageCustom.MountPath: cfg.Reva.StorageCustom.URL,
|
||||
cfg.Reva.StorageCustom.MountID: cfg.Reva.StorageCustom.URL,
|
||||
"/public/": "localhost:10054",
|
||||
"e1a73ede-549b-4226-abdf-40e69ca8230d": "localhost:10054",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -83,6 +83,7 @@ func Execute() error {
|
||||
StorageRoot(cfg),
|
||||
StorageHome(cfg),
|
||||
StorageHomeData(cfg),
|
||||
StoragePublicLink(cfg),
|
||||
StorageOC(cfg),
|
||||
StorageOCData(cfg),
|
||||
StorageEOS(cfg),
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/cs3org/reva/cmd/revad/runtime"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis-reva/pkg/config"
|
||||
"github.com/owncloud/ocis-reva/pkg/flagset"
|
||||
"github.com/owncloud/ocis-reva/pkg/server/debug"
|
||||
)
|
||||
|
||||
// StoragePublicLink is the entrypoint for the reva-storage-public-link command.
|
||||
func StoragePublicLink(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "reva-storage-public-link",
|
||||
Usage: "Start reva storage-public-link service",
|
||||
Flags: flagset.StoragePublicLink(cfg),
|
||||
Category: "Extensions",
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := NewLogger(cfg)
|
||||
|
||||
if cfg.Tracing.Enabled {
|
||||
switch t := cfg.Tracing.Type; t {
|
||||
case "agent":
|
||||
logger.Error().
|
||||
Str("type", t).
|
||||
Msg("Reva only supports the jaeger tracing backend")
|
||||
|
||||
case "jaeger":
|
||||
logger.Info().
|
||||
Str("type", t).
|
||||
Msg("configuring reva to use the jaeger tracing backend")
|
||||
|
||||
case "zipkin":
|
||||
logger.Error().
|
||||
Str("type", t).
|
||||
Msg("Reva only supports the jaeger tracing backend")
|
||||
|
||||
default:
|
||||
logger.Warn().
|
||||
Str("type", t).
|
||||
Msg("Unknown tracing backend")
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.Debug().
|
||||
Msg("Tracing is not enabled")
|
||||
}
|
||||
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
//metrics = metrics.New()
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
|
||||
{
|
||||
uuid := uuid.Must(uuid.NewV4())
|
||||
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
|
||||
|
||||
rcfg := map[string]interface{}{
|
||||
"core": map[string]interface{}{
|
||||
"max_cpus": cfg.Reva.StoragePublicLink.MaxCPUs,
|
||||
"tracing_enabled": true,
|
||||
},
|
||||
"shared": map[string]interface{}{
|
||||
"jwt_secret": cfg.Reva.JWTSecret,
|
||||
},
|
||||
"grpc": map[string]interface{}{
|
||||
"network": cfg.Reva.StoragePublicLink.Network,
|
||||
"address": cfg.Reva.StoragePublicLink.Addr,
|
||||
"interceptors": map[string]interface{}{
|
||||
"log": map[string]interface{}{},
|
||||
},
|
||||
"services": map[string]interface{}{
|
||||
"publicstorageprovider": map[string]interface{}{
|
||||
"mount_path": cfg.Reva.StoragePublicLink.MountPath,
|
||||
"mount_id": cfg.Reva.StoragePublicLink.MountID,
|
||||
"driver_addr": cfg.Reva.StoragePublicLink.PublicShareProviderAddr,
|
||||
"gateway_addr": cfg.Reva.Gateway.URL,
|
||||
},
|
||||
"authprovider": map[string]interface{}{
|
||||
"auth_manager": "publicshares",
|
||||
"auth_managers": map[string]interface{}{
|
||||
"publicshares": map[string]interface{}{
|
||||
"gateway_addr": cfg.Reva.Gateway.URL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
runtime.RunWithOptions(
|
||||
rcfg,
|
||||
pidFile,
|
||||
runtime.WithLogger(&logger.Logger),
|
||||
)
|
||||
return nil
|
||||
}, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", c.Command.Name).
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
server, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Reva.StoragePublicLink.DebugAddr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
logger.Info().
|
||||
Err(err).
|
||||
Str("server", c.Command.Name+"-debug").
|
||||
Msg("Failed to initialize server")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.ListenAndServe()
|
||||
}, func(_ error) {
|
||||
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
|
||||
|
||||
defer timeout()
|
||||
defer cancel()
|
||||
|
||||
if err := server.Shutdown(ctx); err != nil {
|
||||
logger.Info().
|
||||
Err(err).
|
||||
Str("server", c.Command.Name+"-debug").
|
||||
Msg("Failed to shutdown server")
|
||||
} else {
|
||||
logger.Info().
|
||||
Str("server", c.Command.Name+"-debug").
|
||||
Msg("Shutting down server")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
stop := make(chan os.Signal, 1)
|
||||
|
||||
gr.Add(func() error {
|
||||
signal.Notify(stop, os.Interrupt)
|
||||
|
||||
<-stop
|
||||
|
||||
return nil
|
||||
}, func(err error) {
|
||||
close(stop)
|
||||
cancel()
|
||||
})
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user