Rename folder and root command

This commit is contained in:
Michael Barz
2020-10-06 13:41:34 +02:00
parent 48de91ea2c
commit 9ff3ffe19f
165 changed files with 5 additions and 5 deletions
+191
View File
@@ -0,0 +1,191 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// AuthBasic is the entrypoint for the auth-basic command.
func AuthBasic(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "auth-basic",
Usage: "Start reva authprovider for basic auth",
Flags: flagset.AuthBasicWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.AuthBasic.Services = c.StringSlice("service")
return nil
},
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.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "auth-basic",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.AuthBasic.Network,
"address": cfg.Reva.AuthBasic.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"authprovider": map[string]interface{}{
"auth_manager": cfg.Reva.AuthProvider.Driver,
"auth_managers": map[string]interface{}{
"json": map[string]interface{}{
"users": cfg.Reva.AuthProvider.JSON,
},
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"base_dn": cfg.Reva.LDAP.BaseDN,
"loginfilter": cfg.Reva.LDAP.LoginFilter,
"bind_username": cfg.Reva.LDAP.BindDN,
"bind_password": cfg.Reva.LDAP.BindPassword,
"idp": cfg.Reva.LDAP.IDP,
"schema": map[string]interface{}{
"dn": "dn",
"uid": cfg.Reva.LDAP.Schema.UID,
"mail": cfg.Reva.LDAP.Schema.Mail,
"displayName": cfg.Reva.LDAP.Schema.DisplayName,
"cn": cfg.Reva.LDAP.Schema.CN,
},
},
},
},
},
},
}
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.AuthBasic.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "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", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "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()
},
}
}
+179
View File
@@ -0,0 +1,179 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// AuthBearer is the entrypoint for the auth-bearer command.
func AuthBearer(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "auth-bearer",
Usage: "Start reva authprovider for bearer auth",
Flags: flagset.AuthBearerWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.AuthBearer.Services = c.StringSlice("service")
return nil
},
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.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "auth-bearer",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.AuthBearer.Network,
"address": cfg.Reva.AuthBearer.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"authprovider": map[string]interface{}{
"auth_manager": "oidc",
"auth_managers": map[string]interface{}{
"oidc": map[string]interface{}{
"issuer": cfg.Reva.OIDC.Issuer,
"insecure": cfg.Reva.OIDC.Insecure,
"id_claim": cfg.Reva.OIDC.IDClaim,
"uid_claim": cfg.Reva.OIDC.UIDClaim,
"gid_claim": cfg.Reva.OIDC.GIDClaim,
},
},
},
},
},
}
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.AuthBearer.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "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", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "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()
},
}
}
+104
View File
@@ -0,0 +1,104 @@
package command
import (
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
func drivers(cfg *config.Config) map[string]interface{} {
return map[string]interface{}{
"eos": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Root,
"shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace,
"uploads_namespace": cfg.Reva.Storages.EOS.UploadsNamespace,
"share_folder": cfg.Reva.Storages.EOS.ShareFolder,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC,
},
"eoshome": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Root,
"shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace,
"uploads_namespace": cfg.Reva.Storages.EOS.UploadsNamespace,
"share_folder": cfg.Reva.Storages.EOS.ShareFolder,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
"user_layout": cfg.Reva.Storages.EOS.UserLayout,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC,
},
"eosgrpc": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Root,
"shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace,
"share_folder": cfg.Reva.Storages.EOS.ShareFolder,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"master_grpc_uri": cfg.Reva.Storages.EOS.GrpcURI,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
"user_layout": cfg.Reva.Storages.EOS.UserLayout,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"enable_home": cfg.Reva.Storages.EOS.EnableHome,
"gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC,
},
"local": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
"share_folder": cfg.Reva.Storages.Local.ShareFolder,
},
"localhome": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
"share_folder": cfg.Reva.Storages.Local.ShareFolder,
"user_layout": cfg.Reva.Storages.Local.UserLayout,
},
"owncloud": map[string]interface{}{
"datadirectory": cfg.Reva.Storages.OwnCloud.Root,
"upload_info_dir": cfg.Reva.Storages.OwnCloud.UploadInfoDir,
"sharedirectory": cfg.Reva.Storages.OwnCloud.ShareFolder,
"user_layout": cfg.Reva.Storages.OwnCloud.UserLayout,
"redis": cfg.Reva.Storages.OwnCloud.Redis,
"enable_home": cfg.Reva.Storages.OwnCloud.EnableHome,
"scan": cfg.Reva.Storages.OwnCloud.Scan,
"userprovidersvc": cfg.Reva.Users.URL,
},
"ocis": map[string]interface{}{
"root": cfg.Reva.Storages.Common.Root,
"enable_home": cfg.Reva.Storages.Common.EnableHome,
"user_layout": cfg.Reva.Storages.Common.UserLayout,
"treetime_accounting": true,
"treesize_accounting": true,
},
"s3": map[string]interface{}{
"region": cfg.Reva.Storages.S3.Region,
"access_key": cfg.Reva.Storages.S3.AccessKey,
"secret_key": cfg.Reva.Storages.S3.SecretKey,
"endpoint": cfg.Reva.Storages.S3.Endpoint,
"bucket": cfg.Reva.Storages.S3.Bucket,
"prefix": cfg.Reva.Storages.S3.Root,
},
}
}
+310
View File
@@ -0,0 +1,310 @@
package command
import (
"context"
"fmt"
"os"
"os/signal"
"path"
"strings"
"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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// Frontend is the entrypoint for the frontend command.
func Frontend(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "frontend",
Usage: "Start reva frontend service",
Flags: flagset.FrontendWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.Frontend.Services = c.StringSlice("service")
return nil
},
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")
// pregenerate list of valid localhost ports for the desktop redirect_uri
// TODO use custom scheme like "owncloud://localhost/user/callback" tracked in
var desktopRedirectURIs [65535 - 1024]string
for port := 0; port < len(desktopRedirectURIs); port++ {
desktopRedirectURIs[port] = fmt.Sprintf("http://localhost:%d", (port + 1024))
}
filesCfg := map[string]interface{}{
"private_links": false,
"bigfilechunking": false,
"blacklisted_files": []string{},
"undelete": true,
"versioning": true,
}
if !cfg.Reva.UploadDisableTus {
filesCfg["tus_support"] = map[string]interface{}{
"version": "1.0.0",
"resumable": "1.0.0",
"extension": "creation,creation-with-upload",
"http_method_override": cfg.Reva.UploadHTTPMethodOverride,
"max_chunk_size": int(cfg.Reva.UploadMaxChunkSize),
}
}
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "frontend",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
"gatewaysvc": cfg.Reva.Gateway.URL, // Todo or address?
},
"http": map[string]interface{}{
"network": cfg.Reva.Frontend.Network,
"address": cfg.Reva.Frontend.Addr,
"middlewares": map[string]interface{}{
"cors": map[string]interface{}{
"allow_credentials": true,
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"datagateway": map[string]interface{}{
"prefix": cfg.Reva.Frontend.DatagatewayPrefix,
"transfer_shared_secret": cfg.Reva.TransferSecret,
"timeout": 86400,
"insecure": true,
},
"ocdav": map[string]interface{}{
"prefix": cfg.Reva.Frontend.OCDavPrefix,
"chunk_folder": "/var/tmp/reva/chunks",
"files_namespace": cfg.Reva.OCDav.DavFilesNamespace,
"webdav_namespace": cfg.Reva.OCDav.WebdavNamespace,
"timeout": 86400,
"insecure": true,
"disable_tus": cfg.Reva.UploadDisableTus,
},
"ocs": map[string]interface{}{
"prefix": cfg.Reva.Frontend.OCSPrefix,
"config": map[string]interface{}{
"version": "1.8",
"website": "reva",
"host": urlWithScheme(cfg.Reva.Frontend.URL),
"contact": "admin@localhost",
"ssl": "false",
},
"disable_tus": cfg.Reva.UploadDisableTus,
"capabilities": map[string]interface{}{
"capabilities": map[string]interface{}{
"core": map[string]interface{}{
"poll_interval": 60,
"webdav_root": "remote.php/webdav",
"status": map[string]interface{}{
"installed": true,
"maintenance": false,
"needsDbUpgrade": false,
"version": "10.0.11.5",
"versionstring": "10.0.11",
"edition": "community",
"productname": "reva",
"hostname": "",
},
"support_url_signing": true,
},
"checksums": map[string]interface{}{
"supported_types": []string{"SHA256"},
"preferred_upload_type": "SHA256",
},
"files": filesCfg,
"dav": map[string]interface{}{},
"files_sharing": map[string]interface{}{
"api_enabled": true,
"resharing": true,
"group_sharing": true,
"auto_accept_share": true,
"share_with_group_members_only": true,
"share_with_membership_groups_only": true,
"default_permissions": 22,
"search_min_length": 3,
"public": map[string]interface{}{
"enabled": true,
"send_mail": true,
"social_share": true,
"upload": true,
"multiple": true,
"supports_upload_only": true,
"password": map[string]interface{}{
"enforced": true,
"enforced_for": map[string]interface{}{
"read_only": true,
"read_write": true,
"upload_only": true,
},
},
"expire_date": map[string]interface{}{
"enabled": true,
},
},
"user": map[string]interface{}{
"send_mail": true,
},
"user_enumeration": map[string]interface{}{
"enabled": true,
"group_members_only": true,
},
"federation": map[string]interface{}{
"outgoing": true,
"incoming": true,
},
},
"notifications": map[string]interface{}{
"endpoints": []string{"disable"},
},
},
"version": map[string]interface{}{
"edition": "reva",
"major": 10,
"minor": 0,
"micro": 11,
"string": "10.0.11",
},
},
},
},
},
}
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.Frontend.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "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", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "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()
},
}
}
// urlWithScheme checks if the given string is prefixed with "http". If it is not, "http://" will be added as prefix.
// As we can't tell if http or https should be the preferred scheme, the correct approach would be to fail on urls
// without scheme. As long as we have default urls in our flagsets which don't have a scheme, this is a feasible workaround.
func urlWithScheme(str string) string {
if !strings.HasPrefix(str, "http") {
str = "http://" + str
}
return str
}
+259
View File
@@ -0,0 +1,259 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"strings"
"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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
"github.com/owncloud/ocis/ocis-reva/pkg/service/external"
)
// Gateway is the entrypoint for the gateway command.
func Gateway(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "gateway",
Usage: "Start reva gateway",
Flags: flagset.GatewayWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.Gateway.Services = c.StringSlice("service")
cfg.Reva.StorageRegistry.Rules = c.StringSlice("storage-registry-rule")
return nil
},
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.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "gateway",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
"gatewaysvc": cfg.Reva.Gateway.URL, // Todo or address?
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Gateway.Network,
"address": cfg.Reva.Gateway.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"gateway": map[string]interface{}{
// registries is located on the gateway
"authregistrysvc": cfg.Reva.Gateway.URL,
"storageregistrysvc": cfg.Reva.Gateway.URL,
"appregistrysvc": cfg.Reva.Gateway.URL,
// user metadata is located on the users services
"preferencessvc": cfg.Reva.Users.URL,
"userprovidersvc": cfg.Reva.Users.URL,
// sharing is located on the sharing service
"usershareprovidersvc": cfg.Reva.Sharing.URL,
"publicshareprovidersvc": cfg.Reva.Sharing.URL,
"ocmshareprovidersvc": cfg.Reva.Sharing.URL,
"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.
// other
"disable_home_creation_on_login": cfg.Reva.Gateway.DisableHomeCreationOnLogin,
"datagateway": urlWithScheme(cfg.Reva.DataGateway.URL),
"transfer_shared_secret": cfg.Reva.TransferSecret,
"transfer_expires": cfg.Reva.TransferExpires,
},
"authregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
"basic": cfg.Reva.AuthBasic.URL,
"bearer": cfg.Reva.AuthBearer.URL,
"publicshares": cfg.Reva.StoragePublicLink.URL,
},
},
},
},
"storageregistry": map[string]interface{}{
"driver": cfg.Reva.StorageRegistry.Driver,
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"home_provider": cfg.Reva.StorageRegistry.HomeProvider,
"rules": rules(cfg),
},
},
},
},
},
}
gr.Add(func() error {
err := external.RegisterGRPCEndpoint(
ctx,
"com.owncloud.reva",
uuid.String(),
cfg.Reva.Gateway.Addr,
logger,
)
if err != nil {
return err
}
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.Gateway.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "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", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "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()
},
}
}
func rules(cfg *config.Config) map[string]interface{} {
// if a list of rules is given it overrides the generated rules from below
if len(cfg.Reva.StorageRegistry.Rules) > 0 {
rules := map[string]interface{}{}
for i := range cfg.Reva.StorageRegistry.Rules {
parts := strings.SplitN(cfg.Reva.StorageRegistry.Rules[i], "=", 2)
rules[parts[0]] = parts[1]
}
return rules
}
// generate rules based on default config
return map[string]interface{}{
cfg.Reva.StorageRoot.MountPath: cfg.Reva.StorageRoot.URL,
cfg.Reva.StorageRoot.MountID: cfg.Reva.StorageRoot.URL,
cfg.Reva.StorageHome.MountPath: cfg.Reva.StorageHome.URL,
cfg.Reva.StorageHome.MountID: cfg.Reva.StorageHome.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,
cfg.Reva.StoragePublicLink.MountPath: cfg.Reva.StoragePublicLink.URL,
// public link storage returns the mount id of the actual storage
}
}
+49
View File
@@ -0,0 +1,49 @@
package command
import (
"fmt"
"net/http"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
)
// Health is the entrypoint for the health command.
func Health(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "health",
Usage: "Check health status",
Flags: flagset.HealthWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
resp, err := http.Get(
fmt.Sprintf(
"http://%s/healthz",
cfg.Debug.Addr,
),
)
if err != nil {
logger.Fatal().
Err(err).
Msg("Failed to request health check")
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
logger.Fatal().
Int("code", resp.StatusCode).
Msg("Health seems to be in bad state")
}
logger.Debug().
Int("code", resp.StatusCode).
Msg("Health got a good state")
return nil
},
}
}
+117
View File
@@ -0,0 +1,117 @@
package command
import (
"os"
"strings"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/version"
"github.com/spf13/viper"
)
// Execute is the entry point for the ocis-reva command.
func Execute() error {
cfg := config.New()
app := &cli.App{
Name: "storage",
Version: version.String,
Usage: "Example service for Reva/oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
Flags: flagset.RootWithConfig(cfg),
Before: func(c *cli.Context) error {
logger := NewLogger(cfg)
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.SetEnvPrefix("STORAGE")
viper.AutomaticEnv()
if c.IsSet("config-file") {
viper.SetConfigFile(c.String("config-file"))
} else {
viper.SetConfigName("reva")
viper.AddConfigPath("/etc/ocis")
viper.AddConfigPath("$HOME/.ocis")
viper.AddConfigPath("./config")
}
if err := viper.ReadInConfig(); err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
logger.Info().
Msg("Continue without config")
case viper.UnsupportedConfigError:
logger.Fatal().
Err(err).
Msg("Unsupported config type")
default:
logger.Fatal().
Err(err).
Msg("Failed to read config")
}
}
if err := viper.Unmarshal(&cfg); err != nil {
logger.Fatal().
Err(err).
Msg("Failed to parse config")
}
return nil
},
Commands: []*cli.Command{
Frontend(cfg),
Gateway(cfg),
Users(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
Sharing(cfg),
StorageRoot(cfg),
StorageHome(cfg),
StorageHomeData(cfg),
StoragePublicLink(cfg),
StorageOC(cfg),
StorageMetadata(cfg),
StorageOCData(cfg),
StorageEOS(cfg),
StorageEOSData(cfg),
Health(cfg),
},
}
cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
Usage: "Show the help",
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version,v",
Usage: "Print the version",
}
return app.Run(os.Args)
}
// NewLogger initializes a service-specific logger instance.
func NewLogger(cfg *config.Config) log.Logger {
return log.NewLogger(
log.Name("reva"),
log.Level(cfg.Log.Level),
log.Pretty(cfg.Log.Pretty),
log.Color(cfg.Log.Color),
)
}
+178
View File
@@ -0,0 +1,178 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// Sharing is the entrypoint for the sharing command.
func Sharing(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "sharing",
Usage: "Start reva sharing service",
Flags: flagset.SharingWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.Sharing.Services = c.StringSlice("service")
return nil
},
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.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "sharing",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Sharing.Network,
"address": cfg.Reva.Sharing.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"usershareprovider": map[string]interface{}{
"driver": cfg.Reva.Sharing.UserDriver,
"drivers": map[string]interface{}{
"json": map[string]interface{}{
"file": cfg.Reva.Sharing.UserJSONFile,
},
},
},
"publicshareprovider": map[string]interface{}{
"driver": cfg.Reva.Sharing.PublicDriver,
},
},
},
}
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.Sharing.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()
},
}
}
+175
View File
@@ -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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageEOS is the entrypoint for the storage-eos command.
func StorageEOS(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-eos",
Usage: "Start reva storage-eos service",
Flags: flagset.StorageEOSWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageEOS.Services = c.StringSlice("service")
return nil
},
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.StorageEOS.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-eos",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageEOS.Network,
"address": cfg.Reva.StorageEOS.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageEOS.Driver,
"drivers": drivers(cfg),
"mount_path": cfg.Reva.StorageEOS.MountPath,
"mount_id": cfg.Reva.StorageEOS.MountID,
"expose_data_server": cfg.Reva.StorageEOS.ExposeDataServer,
// TODO use cfg.Reva.SStorageEOSData.URL, ?
"data_server_url": cfg.Reva.StorageEOS.DataServerURL,
},
},
},
}
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.StorageEOS.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()
},
}
}
+175
View File
@@ -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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageEOSData is the entrypoint for the storage-oc-data command.
func StorageEOSData(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-eos-data",
Usage: "Start reva storage-eos-data service",
Flags: flagset.StorageEOSDataWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageEOSData.Services = c.StringSlice("service")
return nil
},
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.StorageEOSData.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-eos-data",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
"gatewaysvc": cfg.Reva.Gateway.URL, // Todo or address?
},
"http": map[string]interface{}{
"network": cfg.Reva.StorageEOSData.Network,
"address": cfg.Reva.StorageEOSData.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"prefix": cfg.Reva.StorageEOSData.Prefix,
"driver": cfg.Reva.StorageEOSData.Driver,
"drivers": drivers(cfg),
"timeout": 86400,
"insecure": true,
"disable_tus": false,
},
},
},
}
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.StorageEOSData.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()
},
}
}
+183
View File
@@ -0,0 +1,183 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageHome is the entrypoint for the storage-home command.
func StorageHome(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-home",
Usage: "Start reva storage-home service",
Flags: flagset.StorageHomeWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageHome.Services = c.StringSlice("service")
return nil
},
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")
// override driver enable home option with home config
if cfg.Reva.Storages.Home.EnableHome {
cfg.Reva.Storages.Common.EnableHome = true
cfg.Reva.Storages.EOS.EnableHome = true
cfg.Reva.Storages.Local.EnableHome = true
cfg.Reva.Storages.OwnCloud.EnableHome = true
cfg.Reva.Storages.S3.EnableHome = true
}
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-home",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageHome.Network,
"address": cfg.Reva.StorageHome.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageHome.Driver,
"drivers": drivers(cfg),
"mount_path": cfg.Reva.StorageHome.MountPath,
"mount_id": cfg.Reva.StorageHome.MountID,
"expose_data_server": cfg.Reva.StorageHome.ExposeDataServer,
// TODO use cfg.Reva.StorageHomeData.URL, ?
"data_server_url": cfg.Reva.StorageHome.DataServerURL,
},
},
},
}
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.StorageHome.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()
},
}
}
+183
View File
@@ -0,0 +1,183 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageHomeData is the entrypoint for the storage-home-data command.
func StorageHomeData(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-home-data",
Usage: "Start reva storage-home-data service",
Flags: flagset.StorageHomeDataWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageHomeData.Services = c.StringSlice("service")
return nil
},
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")
// override driver enable home option with home config
if cfg.Reva.Storages.Home.EnableHome {
cfg.Reva.Storages.Common.EnableHome = true
cfg.Reva.Storages.EOS.EnableHome = true
cfg.Reva.Storages.Local.EnableHome = true
cfg.Reva.Storages.OwnCloud.EnableHome = true
cfg.Reva.Storages.S3.EnableHome = true
}
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-home-data",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
"gatewaysvc": cfg.Reva.Gateway.URL, // Todo or address?
},
"http": map[string]interface{}{
"network": cfg.Reva.StorageHomeData.Network,
"address": cfg.Reva.StorageHomeData.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"prefix": cfg.Reva.StorageHomeData.Prefix,
"driver": cfg.Reva.StorageHomeData.Driver,
"drivers": drivers(cfg),
"timeout": 86400,
"insecure": true,
"disable_tus": false,
},
},
},
}
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.StorageHomeData.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()
},
}
}
+205
View File
@@ -0,0 +1,205 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageMetadata the entrypoint for the reva-storage-metadata command.
//
// It provides a ocis-specific storage store metadata (shares,account,settings...)
func StorageMetadata(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-metadata",
Usage: "Start reva storage-metadata service",
Flags: flagset.StorageMetadata(cfg),
Category: "Extensions",
Before: func(c *cli.Context) error {
storageRoot := c.String("storage-root")
cfg.Reva.Storages.OwnCloud.Root = storageRoot
cfg.Reva.Storages.EOS.Root = storageRoot
cfg.Reva.Storages.Local.Root = storageRoot
cfg.Reva.Storages.S3.Root = storageRoot
cfg.Reva.Storages.Home.Root = storageRoot
return nil
},
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")
// Disable home because the metadata is stored independently
// of the user. This also means that a valid-token without any user-id
// is allowed to write to the metadata-storage.
cfg.Reva.Storages.Common.EnableHome = false
cfg.Reva.Storages.EOS.EnableHome = false
cfg.Reva.Storages.Local.EnableHome = false
cfg.Reva.Storages.OwnCloud.EnableHome = false
cfg.Reva.Storages.S3.EnableHome = false
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": "100",
"tracing_enabled": false,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-metadata",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageMetadata.Network,
"address": cfg.Reva.StorageMetadata.Addr,
"interceptors": map[string]interface{}{
"log": map[string]interface{}{},
},
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"mount_path": "/meta",
"data_server_url": cfg.Reva.StorageMetadataData.URL,
"driver": cfg.Reva.StorageMetadata.Driver,
"drivers": drivers(cfg),
},
},
},
"http": map[string]interface{}{
"network": cfg.Reva.StorageMetadataData.Network,
"address": cfg.Reva.StorageMetadataData.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"prefix": "data",
"driver": cfg.Reva.StorageMetadataData.Driver,
"drivers": drivers(cfg),
"timeout": 86400,
"insecure": true,
"disable_tus": true,
},
},
},
}
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.StorageMetadata.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()
},
}
}
+175
View File
@@ -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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageOC is the entrypoint for the storage-oc command.
func StorageOC(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-oc",
Usage: "Start reva storage-oc service",
Flags: flagset.StorageOCWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageOC.Services = c.StringSlice("service")
return nil
},
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.StorageOC.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-oc",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageOC.Network,
"address": cfg.Reva.StorageOC.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageOC.Driver,
"drivers": drivers(cfg),
"mount_path": cfg.Reva.StorageOC.MountPath,
"mount_id": cfg.Reva.StorageOC.MountID,
"expose_data_server": cfg.Reva.StorageOC.ExposeDataServer,
// TODO use cfg.Reva.SStorageOCData.URL, ?
"data_server_url": cfg.Reva.StorageOC.DataServerURL,
},
},
},
}
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.StorageOC.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()
},
}
}
+175
View File
@@ -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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageOCData is the entrypoint for the storage-oc-data command.
func StorageOCData(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-oc-data",
Usage: "Start reva storage-oc-data service",
Flags: flagset.StorageOCDataWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageOCData.Services = c.StringSlice("service")
return nil
},
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.StorageOCData.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-oc-data",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
"gatewaysvc": cfg.Reva.Gateway.URL, // Todo or address?
},
"http": map[string]interface{}{
"network": cfg.Reva.StorageOCData.Network,
"address": cfg.Reva.StorageOCData.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"prefix": cfg.Reva.StorageOCData.Prefix,
"driver": cfg.Reva.StorageOCData.Driver,
"drivers": drivers(cfg),
"timeout": 86400,
"insecure": true,
"disable_tus": false,
},
},
},
}
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.StorageOCData.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()
},
}
}
+176
View File
@@ -0,0 +1,176 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/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": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-public-link",
},
"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,
"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()
},
}
}
+174
View File
@@ -0,0 +1,174 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// StorageRoot is the entrypoint for the storage-root command.
func StorageRoot(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-root",
Usage: "Start reva storage-root service",
Flags: flagset.StorageRootWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.StorageRoot.Services = c.StringSlice("service")
return nil
},
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.StorageRoot.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-root",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageRoot.Network,
"address": cfg.Reva.StorageRoot.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageRoot.Driver,
"drivers": drivers(cfg),
"mount_path": cfg.Reva.StorageRoot.MountPath,
"mount_id": cfg.Reva.StorageRoot.MountID,
"expose_data_server": cfg.Reva.StorageRoot.ExposeDataServer,
"data_server_url": cfg.Reva.StorageRoot.DataServerURL,
},
},
},
}
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.StorageRoot.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()
},
}
}
+207
View File
@@ -0,0 +1,207 @@
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/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis-reva/pkg/server/debug"
)
// Users is the entrypoint for the sharing command.
func Users(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "users",
Usage: "Start reva users service",
Flags: flagset.UsersWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.Users.Services = c.StringSlice("service")
return nil
},
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.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "users",
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Users.Network,
"address": cfg.Reva.Users.Addr,
// TODO build services dynamically
"services": map[string]interface{}{
"userprovider": map[string]interface{}{
"driver": cfg.Reva.Users.Driver,
"drivers": map[string]interface{}{
"json": map[string]interface{}{
"users": cfg.Reva.Users.JSON,
},
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"base_dn": cfg.Reva.LDAP.BaseDN,
"userfilter": cfg.Reva.LDAP.UserFilter,
"attributefilter": cfg.Reva.LDAP.AttributeFilter,
"findfilter": cfg.Reva.LDAP.FindFilter,
"groupfilter": cfg.Reva.LDAP.GroupFilter,
"bind_username": cfg.Reva.LDAP.BindDN,
"bind_password": cfg.Reva.LDAP.BindPassword,
"idp": cfg.Reva.LDAP.IDP,
"schema": map[string]interface{}{
"dn": "dn",
"uid": cfg.Reva.LDAP.Schema.UID,
"mail": cfg.Reva.LDAP.Schema.Mail,
"displayName": cfg.Reva.LDAP.Schema.DisplayName,
"cn": cfg.Reva.LDAP.Schema.CN,
"uidNumber": cfg.Reva.LDAP.Schema.UIDNumber,
"gidNumber": cfg.Reva.LDAP.Schema.GIDNumber,
},
},
"rest": map[string]interface{}{
"client_id": cfg.Reva.UserRest.ClientID,
"client_secret": cfg.Reva.UserRest.ClientSecret,
"redis_address": cfg.Reva.UserRest.RedisAddress,
"redis_username": cfg.Reva.UserRest.RedisUsername,
"redis_password": cfg.Reva.UserRest.RedisPassword,
"user_groups_cache_expiration": cfg.Reva.UserRest.UserGroupsCacheExpiration,
"id_provider": cfg.Reva.UserRest.IDProvider,
"api_base_url": cfg.Reva.UserRest.APIBaseURL,
"oidc_token_endpoint": cfg.Reva.UserRest.OIDCTokenEndpoint,
"target_api": cfg.Reva.UserRest.TargetAPI,
},
},
},
},
},
}
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.Users.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()
},
}
}
+338
View File
@@ -0,0 +1,338 @@
package config
// Log defines the available logging configuration.
type Log struct {
Level string
Pretty bool
Color bool
}
// Debug defines the available debug configuration.
type Debug struct {
Addr string
Token string
Pprof bool
Zpages bool
}
// Gateway defines the available gateway configuration.
type Gateway struct {
Port
CommitShareToStorageGrant bool
CommitShareToStorageRef bool
ShareFolder string
LinkGrants string
DisableHomeCreationOnLogin bool
}
// StorageRegistry defines the available storage registry configuration
type StorageRegistry struct {
Driver string
// HomeProvider is the path in the global namespace that the static storage registry uses to determine the home storage
HomeProvider string
Rules []string
}
// Sharing defines the available sharing configuration.
type Sharing struct {
Port
UserDriver string
UserJSONFile string
PublicDriver string
}
// Port defines the available port configuration.
type Port struct {
// MaxCPUs can be a number or a percentage
MaxCPUs string
LogLevel string
// Network can be tcp, udp or unix
Network string
// Addr to listen on, hostname:port (0.0.0.0:9999 for all interfaces) or socket (/var/run/reva/sock)
Addr string
// Protocol can be grpc or http
Protocol string
// URL is used by the gateway and registries (eg http://localhost:9100 or https://cloud.example.com)
URL string
// DebugAddr for the debug endpoint to bind to
DebugAddr string
// Services can be used to give a list of services that should be started on this port
Services []string
// Config can be used to configure the reva instance.
// Services and Protocol will be ignored if this is used
Config map[string]interface{}
}
// Users defines the available users configuration.
type Users struct {
Port
Driver string
JSON string
}
// FrontendPort defines the available frontend configuration.
type FrontendPort struct {
Port
DatagatewayPrefix string
OCDavPrefix string
OCSPrefix string
}
// StoragePort defines the available storage configuration.
type StoragePort struct {
Port
Driver string
MountPath string
MountID string
ExposeDataServer bool
DataServerURL string
// for HTTP ports with only one http service
Prefix string
TempFolder string
}
// PublicStorage configures a public storage provider
type PublicStorage struct {
StoragePort
PublicShareProviderAddr string
UserProviderAddr string
}
// StorageConfig combines all available storage driver configuration parts.
type StorageConfig struct {
Home DriverCommon
EOS DriverEOS
Local DriverCommon
OwnCloud DriverOwnCloud
S3 DriverS3
Common DriverCommon
// TODO checksums ... figure out what that is supposed to do
}
// DriverCommon defines common driver configuration options.
type DriverCommon struct {
// Root is the absolute path to the location of the data
Root string
//ShareFolder defines the name of the folder jailing all shares
ShareFolder string
// UserLayout contains the template used to construct
// the internal path, eg: `{{substr 0 1 .Username}}/{{.Username}}`
UserLayout string
// EnableHome enables the creation of home directories.
EnableHome bool
}
// DriverEOS defines the available EOS driver configuration.
type DriverEOS struct {
DriverCommon
// ShadowNamespace for storing shadow data
ShadowNamespace string
// UploadsNamespace for storing upload data
UploadsNamespace string
// Location of the eos binary.
// Default is /usr/bin/eos.
EosBinary string
// Location of the xrdcopy binary.
// Default is /usr/bin/xrdcopy.
XrdcopyBinary string
// URL of the Master EOS MGM.
// Default is root://eos-example.org
MasterURL string
// URI of the EOS MGM grpc server
// Default is empty
GrpcURI string
// URL of the Slave EOS MGM.
// Default is root://eos-example.org
SlaveURL string
// Location on the local fs where to store reads.
// Defaults to os.TempDir()
CacheDirectory string
// Enables logging of the commands executed
// Defaults to false
EnableLogging bool
// ShowHiddenSysFiles shows internal EOS files like
// .sys.v# and .sys.a# files.
ShowHiddenSysFiles bool
// ForceSingleUserMode will force connections to EOS to use SingleUsername
ForceSingleUserMode bool
// UseKeyTabAuth changes will authenticate requests by using an EOS keytab.
UseKeytab bool
// SecProtocol specifies the xrootd security protocol to use between the server and EOS.
SecProtocol string
// Keytab specifies the location of the keytab to use to authenticate to EOS.
Keytab string
// SingleUsername is the username to use when SingleUserMode is enabled
SingleUsername string
// gateway service to use for uid lookups
GatewaySVC string
}
// DriverOwnCloud defines the available ownCloud storage driver configuration.
type DriverOwnCloud struct {
DriverCommon
UploadInfoDir string
Redis string
Scan bool
}
// DriverS3 defines the available S3 storage driver configuration.
type DriverS3 struct {
DriverCommon
Region string
AccessKey string
SecretKey string
Endpoint string
Bucket string
}
// OIDC defines the available OpenID Connect configuration.
type OIDC struct {
Issuer string
Insecure bool
IDClaim string
UIDClaim string
GIDClaim string
}
// LDAP defines the available ldap configuration.
type LDAP struct {
Hostname string
Port int
BaseDN string
LoginFilter string
UserFilter string
AttributeFilter string
FindFilter string
GroupFilter string
BindDN string
BindPassword string
IDP string
Schema LDAPSchema
}
// UserRest defines the user REST driver specification.
type UserRest struct {
ClientID string
ClientSecret string
RedisAddress string
RedisUsername string
RedisPassword string
IDProvider string
APIBaseURL string
OIDCTokenEndpoint string
TargetAPI string
UserGroupsCacheExpiration int
}
// LDAPSchema defines the available ldap schema configuration.
type LDAPSchema struct {
UID string
Mail string
DisplayName string
CN string
UIDNumber string
GIDNumber string
}
// OCDav defines the available ocdav configuration.
type OCDav struct {
WebdavNamespace string
DavFilesNamespace string
}
// Reva defines the available reva configuration.
type Reva struct {
// JWTSecret used to sign jwt tokens between services
JWTSecret string
TransferSecret string
TransferExpires int
OIDC OIDC
LDAP LDAP
UserRest UserRest
OCDav OCDav
Storages StorageConfig
// Ports are used to configure which services to start on which port
Frontend FrontendPort
DataGateway Port
Gateway Gateway
StorageRegistry StorageRegistry
Users Users
AuthProvider Users
AuthBasic Port
AuthBearer Port
Sharing Sharing
StorageRoot StoragePort
StorageRootData StoragePort
StorageHome StoragePort
StorageHomeData StoragePort
StorageEOS StoragePort
StorageEOSData StoragePort
StorageOC StoragePort
StorageOCData StoragePort
StorageS3 StoragePort
StorageS3Data StoragePort
StorageWND StoragePort
StorageWNDData StoragePort
StorageCustom StoragePort
StorageCustomData StoragePort
StoragePublicLink PublicStorage
StorageMetadata StoragePort
StorageMetadataData StoragePort
// Configs can be used to configure the reva instance.
// Services and Ports will be ignored if this is used
Configs map[string]interface{}
// chunking and resumable upload config (TUS)
UploadMaxChunkSize int
UploadHTTPMethodOverride string
UploadDisableTus bool
}
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool
Type string
Endpoint string
Collector string
Service string
}
// Asset defines the available asset configuration.
type Asset struct {
Path string
}
// Config combines all available configuration parts.
type Config struct {
File string
Log Log
Debug Debug
Reva Reva
Tracing Tracing
Asset Asset
}
// New initializes a new configuration with or without defaults.
func New() *Config {
return &Config{}
}
+84
View File
@@ -0,0 +1,84 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// AuthBasicWithConfig applies cfg to the root flagset
func AuthBasicWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9147",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_AUTH_BASIC_DEBUG_ADDR"},
Destination: &cfg.Reva.AuthBasic.DebugAddr,
},
// Auth
&cli.StringFlag{
Name: "auth-driver",
Value: "ldap",
Usage: "auth driver: 'demo', 'json' or 'ldap'",
EnvVars: []string{"REVA_AUTH_DRIVER"},
Destination: &cfg.Reva.AuthProvider.Driver,
},
&cli.StringFlag{
Name: "auth-json",
Value: "",
Usage: "Path to users.json file",
EnvVars: []string{"REVA_AUTH_JSON"},
Destination: &cfg.Reva.AuthProvider.JSON,
},
// Services
// AuthBasic
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva auth-basic service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_AUTH_BASIC_NETWORK"},
Destination: &cfg.Reva.AuthBasic.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_AUTH_BASIC_PROTOCOL"},
Destination: &cfg.Reva.AuthBasic.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9146",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_AUTH_BASIC_ADDR"},
Destination: &cfg.Reva.AuthBasic.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9146",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_AUTH_BASIC_URL"},
Destination: &cfg.Reva.AuthBasic.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("authprovider"),
Usage: "--service authprovider [--service otherservice]",
EnvVars: []string{"REVA_AUTH_BASIC_SERVICES"},
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, LDAPWithConfig(cfg)...)
return flags
}
+110
View File
@@ -0,0 +1,110 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// AuthBearerWithConfig applies cfg to the root flagset
func AuthBearerWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9149",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_AUTH_BEARER_DEBUG_ADDR"},
Destination: &cfg.Reva.AuthBearer.DebugAddr,
},
// OIDC
&cli.StringFlag{
Name: "oidc-issuer",
Value: "https://localhost:9200",
Usage: "OIDC issuer",
EnvVars: []string{"REVA_OIDC_ISSUER"},
Destination: &cfg.Reva.OIDC.Issuer,
},
&cli.BoolFlag{
Name: "oidc-insecure",
Value: true,
Usage: "OIDC allow insecure communication",
EnvVars: []string{"REVA_OIDC_INSECURE"},
Destination: &cfg.Reva.OIDC.Insecure,
},
&cli.StringFlag{
Name: "oidc-id-claim",
// preferred_username is a workaround
// the user manager needs to take care of the sub to user metadata lookup, which ldap cannot do
// TODO sub is stable and defined as unique.
// AFAICT we want to use the account id from ocis-accounts
// TODO add an ocis middleware to reva that changes the users opaqueid?
// TODO add an ocis-accounts backed user manager
Value: "preferred_username",
Usage: "OIDC id claim",
EnvVars: []string{"REVA_OIDC_ID_CLAIM"},
Destination: &cfg.Reva.OIDC.IDClaim,
},
&cli.StringFlag{
Name: "oidc-uid-claim",
Value: "",
Usage: "OIDC uid claim",
EnvVars: []string{"REVA_OIDC_UID_CLAIM"},
Destination: &cfg.Reva.OIDC.UIDClaim,
},
&cli.StringFlag{
Name: "oidc-gid-claim",
Value: "",
Usage: "OIDC gid claim",
EnvVars: []string{"REVA_OIDC_GID_CLAIM"},
Destination: &cfg.Reva.OIDC.GIDClaim,
},
// Services
// AuthBearer
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_AUTH_BEARER_NETWORK"},
Destination: &cfg.Reva.AuthBearer.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_AUTH_BEARER_PROTOCOL"},
Destination: &cfg.Reva.AuthBearer.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9148",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_AUTH_BEARER_ADDR"},
Destination: &cfg.Reva.AuthBearer.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9148",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_AUTH_BEARER_URL"},
Destination: &cfg.Reva.AuthBearer.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("authprovider"), // TODO preferences
Usage: "--service authprovider [--service otherservice]",
EnvVars: []string{"REVA_AUTH_BEARER_SERVICES"},
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
return flags
}
+31
View File
@@ -0,0 +1,31 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// DebugWithConfig applies common debug config cfg to the flagset
func DebugWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVars: []string{"REVA_DEBUG_TOKEN"},
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVars: []string{"REVA_DEBUG_PPROF"},
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVars: []string{"REVA_DEBUG_ZPAGES"},
Destination: &cfg.Debug.Zpages,
},
}
}
+133
View File
@@ -0,0 +1,133 @@
package flagset
import (
"os"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// DriverEOSWithConfig applies cfg to the root flagset
func DriverEOSWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "storage-eos-namespace",
Value: "/eos/dockertest/reva",
Usage: "Namespace for metadata operations",
EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"},
Destination: &cfg.Reva.Storages.EOS.Root,
},
&cli.StringFlag{
Name: "storage-eos-shadow-namespace",
// Defaults to path.Join(c.Namespace, ".shadow")
Usage: "Shadow namespace where share references are stored",
EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"},
Destination: &cfg.Reva.Storages.EOS.ShadowNamespace,
},
&cli.StringFlag{
Name: "storage-eos-share-folder",
Value: "/Shares",
Usage: "name of the share folder",
EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"},
Destination: &cfg.Reva.Storages.EOS.ShareFolder,
},
&cli.StringFlag{
Name: "storage-eos-binary",
Value: "/usr/bin/eos",
Usage: "Location of the eos binary",
EnvVars: []string{"REVA_STORAGE_EOS_BINARY"},
Destination: &cfg.Reva.Storages.EOS.EosBinary,
},
&cli.StringFlag{
Name: "storage-eos-xrdcopy-binary",
Value: "/usr/bin/xrdcopy",
Usage: "Location of the xrdcopy binary",
EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"},
Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary,
},
&cli.StringFlag{
Name: "storage-eos-master-url",
Value: "root://eos-mgm1.eoscluster.cern.ch:1094",
Usage: "URL of the Master EOS MGM",
EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"},
Destination: &cfg.Reva.Storages.EOS.MasterURL,
},
&cli.StringFlag{
Name: "storage-eos-slave-url",
Value: "root://eos-mgm1.eoscluster.cern.ch:1094",
Usage: "URL of the Slave EOS MGM",
EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"},
Destination: &cfg.Reva.Storages.EOS.SlaveURL,
},
&cli.StringFlag{
Name: "storage-eos-cache-directory",
Value: os.TempDir(),
Usage: "Location on the local fs where to store reads",
EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"},
Destination: &cfg.Reva.Storages.EOS.CacheDirectory,
},
&cli.BoolFlag{
Name: "storage-eos-enable-logging",
Usage: "Enables logging of the commands executed",
EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"},
Destination: &cfg.Reva.Storages.EOS.EnableLogging,
},
&cli.BoolFlag{
Name: "storage-eos-show-hidden-sysfiles",
Usage: "show internal EOS files like .sys.v# and .sys.a# files.",
EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"},
Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
},
&cli.BoolFlag{
Name: "storage-eos-force-singleuser-mode",
Usage: "force connections to EOS to use SingleUsername",
EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"},
Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode,
},
&cli.BoolFlag{
Name: "storage-eos-use-keytab",
Usage: "authenticate requests by using an EOS keytab",
EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"},
Destination: &cfg.Reva.Storages.EOS.UseKeytab,
},
&cli.BoolFlag{
Name: "storage-eos-enable-home",
Usage: "enable the creation of home directories",
EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"},
Destination: &cfg.Reva.Storages.EOS.EnableHome,
},
&cli.StringFlag{
Name: "storage-eos-sec-protocol",
Usage: "the xrootd security protocol to use between the server and EOS",
EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"},
Destination: &cfg.Reva.Storages.EOS.SecProtocol,
},
&cli.StringFlag{
Name: "storage-eos-keytab",
Usage: "the location of the keytab to use to authenticate to EOS",
EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"},
Destination: &cfg.Reva.Storages.EOS.Keytab,
},
&cli.StringFlag{
Name: "storage-eos-single-username",
Usage: "the username to use when SingleUserMode is enabled",
EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"},
Destination: &cfg.Reva.Storages.EOS.SingleUsername,
},
&cli.StringFlag{
Name: "storage-eos-layout",
Value: "{{substr 0 1 .Username}}/{{.Username}}",
Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `,
EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"},
Destination: &cfg.Reva.Storages.EOS.UserLayout,
},
&cli.StringFlag{
Name: "storage-eos-gatewaysvc",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"},
Destination: &cfg.Reva.Storages.EOS.GatewaySVC,
},
}
}
+19
View File
@@ -0,0 +1,19 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// DriverLocalWithConfig applies cfg to the root flagset
func DriverLocalWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "storage-local-root",
Value: "/var/tmp/reva/root",
Usage: "the path to the local storage root",
EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"},
Destination: &cfg.Reva.Storages.Local.Root,
},
}
}
+33
View File
@@ -0,0 +1,33 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// DriverOCISWithConfig applies cfg to the root flagset
func DriverOCISWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "storage-ocis-root",
Value: "/var/tmp/ocis/root",
Usage: "the path to the local storage root",
EnvVars: []string{"REVA_STORAGE_OCIS_ROOT"},
Destination: &cfg.Reva.Storages.Common.Root,
},
&cli.BoolFlag{
Name: "storage-ocis-enable-home",
Value: false,
Usage: "enable the creation of home storages",
EnvVars: []string{"REVA_STORAGE_OCIS_ENABLE_HOME"},
Destination: &cfg.Reva.Storages.Common.EnableHome,
},
&cli.StringFlag{
Name: "storage-ocis-layout",
Value: "{{.Id.OpaqueId}}",
Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `,
EnvVars: []string{"REVA_STORAGE_OCIS_LAYOUT"},
Destination: &cfg.Reva.Storages.Common.UserLayout,
},
}
}
+61
View File
@@ -0,0 +1,61 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// DriverOwnCloudWithConfig applies cfg to the root flagset
func DriverOwnCloudWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "storage-owncloud-datadir",
Value: "/var/tmp/reva/data",
Usage: "the path to the owncloud data directory",
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"},
Destination: &cfg.Reva.Storages.OwnCloud.Root,
},
&cli.StringFlag{
Name: "storage-owncloud-uploadinfo-dir",
Value: "/var/tmp/reva/uploadinfo",
Usage: "the path to the tus upload info directory",
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_UPLOADINFO_DIR"},
Destination: &cfg.Reva.Storages.OwnCloud.UploadInfoDir,
},
&cli.StringFlag{
Name: "storage-owncloud-share-folder",
Value: "/Shares",
Usage: "name of the shares folder",
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SHARE_FOLDER"},
Destination: &cfg.Reva.Storages.OwnCloud.ShareFolder,
},
&cli.BoolFlag{
Name: "storage-owncloud-scan",
Value: true,
Usage: "scan files on startup to add fileids",
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"},
Destination: &cfg.Reva.Storages.OwnCloud.Scan,
},
&cli.StringFlag{
Name: "storage-owncloud-redis",
Value: ":6379",
Usage: "the address of the redis server",
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"},
Destination: &cfg.Reva.Storages.OwnCloud.Redis,
},
&cli.BoolFlag{
Name: "storage-owncloud-enable-home",
Value: false,
Usage: "enable the creation of home storages",
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"},
Destination: &cfg.Reva.Storages.OwnCloud.EnableHome,
},
&cli.StringFlag{
Name: "storage-owncloud-layout",
Value: "{{.Id.OpaqueId}}",
Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `,
EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"},
Destination: &cfg.Reva.Storages.OwnCloud.UserLayout,
},
}
}
+150
View File
@@ -0,0 +1,150 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// FrontendWithConfig applies cfg to the root flagset
func FrontendWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9141",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_FRONTEND_DEBUG_ADDR"},
Destination: &cfg.Reva.Frontend.DebugAddr,
},
// REVA
&cli.StringFlag{
Name: "transfer-secret",
Value: "replace-me-with-a-transfer-secret",
Usage: "Transfer secret for datagateway",
EnvVars: []string{"REVA_TRANSFER_SECRET"},
Destination: &cfg.Reva.TransferSecret,
},
// OCDav
&cli.StringFlag{
Name: "webdav-namespace",
Value: "/home/",
Usage: "Namespace prefix for the /webdav endpoint",
EnvVars: []string{"WEBDAV_NAMESPACE"},
Destination: &cfg.Reva.OCDav.WebdavNamespace,
},
// the /dav/files endpoint expects a username as the first path segment
// this can eg. be set to /eos/users
&cli.StringFlag{
Name: "dav-files-namespace",
Value: "/oc/",
Usage: "Namespace prefix for the webdav /dav/files endpoint",
EnvVars: []string{"DAV_FILES_NAMESPACE"},
Destination: &cfg.Reva.OCDav.DavFilesNamespace,
},
// Services
// Frontend
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_FRONTEND_NETWORK"},
Destination: &cfg.Reva.Frontend.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_FRONTEND_PROTOCOL"},
Destination: &cfg.Reva.Frontend.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9140",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_FRONTEND_ADDR"},
Destination: &cfg.Reva.Frontend.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "https://localhost:9200",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_FRONTEND_URL"},
Destination: &cfg.Reva.Frontend.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("datagateway", "ocdav", "ocs"),
Usage: "--service ocdav [--service ocs]",
EnvVars: []string{"REVA_FRONTEND_SERVICES"},
},
&cli.StringFlag{
Name: "datagateway-prefix",
Value: "data",
Usage: "datagateway prefix",
EnvVars: []string{"REVA_FRONTEND_DATAGATEWAY_PREFIX"},
Destination: &cfg.Reva.Frontend.DatagatewayPrefix,
},
&cli.StringFlag{
Name: "ocdav-prefix",
Value: "",
Usage: "owncloud webdav endpoint prefix",
EnvVars: []string{"REVA_FRONTEND_OCDAV_PREFIX"},
Destination: &cfg.Reva.Frontend.OCDavPrefix,
},
&cli.StringFlag{
Name: "ocs-prefix",
Value: "ocs",
Usage: "open collaboration services endpoint prefix",
EnvVars: []string{"REVA_FRONTEND_OCS_PREFIX"},
Destination: &cfg.Reva.Frontend.OCSPrefix,
},
// Gateway
&cli.StringFlag{
Name: "gateway-url",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVars: []string{"REVA_GATEWAY_URL"},
Destination: &cfg.Reva.Gateway.URL,
},
// Chunking
&cli.BoolFlag{
Name: "upload-disable-tus",
Value: false,
Usage: "Disables TUS upload mechanism",
EnvVars: []string{"REVA_FRONTEND_UPLOAD_DISABLE_TUS"},
Destination: &cfg.Reva.UploadDisableTus,
},
&cli.IntFlag{
Name: "upload-max-chunk-size",
Value: 0,
Usage: "Max chunk size in bytes to advertise to clients through capabilities, or 0 for unlimited",
EnvVars: []string{"REVA_FRONTEND_UPLOAD_MAX_CHUNK_SIZE"},
Destination: &cfg.Reva.UploadMaxChunkSize,
},
&cli.StringFlag{
Name: "upload-http-method-override",
Value: "",
Usage: "Specify an HTTP method (ex: POST) that clients should to use when uploading instead of PATCH",
EnvVars: []string{"REVA_FRONTEND_UPLOAD_HTTP_METHOD_OVERRIDE"},
Destination: &cfg.Reva.UploadHTTPMethodOverride,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
return flags
}
+287
View File
@@ -0,0 +1,287 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// GatewayWithConfig applies cfg to the root flagset
func GatewayWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9143",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_GATEWAY_DEBUG_ADDR"},
Destination: &cfg.Reva.Gateway.DebugAddr,
},
// REVA
&cli.StringFlag{
Name: "transfer-secret",
Value: "replace-me-with-a-transfer-secret",
Usage: "Transfer secret for datagateway",
EnvVars: []string{"REVA_TRANSFER_SECRET"},
Destination: &cfg.Reva.TransferSecret,
},
&cli.IntFlag{
Name: "transfer-expires",
Value: 24 * 60 * 60, // one day
Usage: "Transfer token ttl in seconds",
EnvVars: []string{"REVA_TRANSFER_EXPIRES"},
Destination: &cfg.Reva.TransferExpires,
},
// TODO allow configuring clients
// Services
// Gateway
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_GATEWAY_NETWORK"},
Destination: &cfg.Reva.Gateway.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_GATEWAY_PROTOCOL"},
Destination: &cfg.Reva.Gateway.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9142",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_GATEWAY_ADDR"},
Destination: &cfg.Reva.Gateway.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9142",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_GATEWAY_URL"},
Destination: &cfg.Reva.Gateway.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("gateway", "authregistry", "storageregistry"), // TODO appregistry
Usage: "--service gateway [--service authregistry]",
EnvVars: []string{"REVA_GATEWAY_SERVICES"},
},
&cli.BoolFlag{
Name: "commit-share-to-storage-grant",
Value: true,
// TODO clarify
Usage: "Commit shares to the share manager",
EnvVars: []string{"REVA_GATEWAY_COMMIT_SHARE_TO_STORAGE_GRANT"},
Destination: &cfg.Reva.Gateway.CommitShareToStorageGrant,
},
&cli.BoolFlag{
Name: "commit-share-to-storage-ref",
Value: true,
// TODO clarify
Usage: "Commit shares to the storage",
EnvVars: []string{"REVA_GATEWAY_COMMIT_SHARE_TO_STORAGE_REF"},
Destination: &cfg.Reva.Gateway.CommitShareToStorageRef,
},
&cli.StringFlag{
Name: "share-folder",
Value: "Shares",
Usage: "mount shares in this folder of the home storage provider",
EnvVars: []string{"REVA_GATEWAY_SHARE_FOLDER"},
Destination: &cfg.Reva.Gateway.ShareFolder,
},
&cli.BoolFlag{
Name: "disable-home-creation-on-login",
Usage: "Disable creation of home folder on login",
EnvVars: []string{"REVA_GATEWAY_DISABLE_HOME_CREATION_ON_LOGIN"},
Destination: &cfg.Reva.Gateway.DisableHomeCreationOnLogin,
},
// other services
// storage registry
&cli.StringFlag{
Name: "storage-registry-driver",
Value: "static",
Usage: "driver of the storage registry",
EnvVars: []string{"REVA_STORAGE_REGISTRY_DRIVER"},
Destination: &cfg.Reva.StorageRegistry.Driver,
},
&cli.StringSliceFlag{
Name: "storage-registry-rule",
Value: cli.NewStringSlice(),
Usage: `Replaces the generated storage registry rules with this set: --storage-registry-rule "/eos=localhost:9158" [--storage-registry-rule "1284d238-aa92-42ce-bdc4-0b0000009162=localhost:9162"]`,
EnvVars: []string{"REVA_STORAGE_REGISTRY_RULES"},
},
&cli.StringFlag{
Name: "storage-home-provider",
Value: "/home",
Usage: "mount point of the storage provider for user homes in the global namespace",
EnvVars: []string{"REVA_STORAGE_HOME_PROVIDER"},
Destination: &cfg.Reva.StorageRegistry.HomeProvider,
},
&cli.StringFlag{
Name: "frontend-url",
Value: "https://localhost:9200",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_FRONTEND_URL"},
Destination: &cfg.Reva.Frontend.URL,
},
&cli.StringFlag{
Name: "datagateway-url",
Value: "https://localhost:9200/data",
Usage: "URL to use for the reva datagateway",
EnvVars: []string{"REVA_DATAGATEWAY_URL"},
Destination: &cfg.Reva.DataGateway.URL,
},
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
&cli.StringFlag{
Name: "auth-basic-url",
Value: "localhost:9146",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_AUTH_BASIC_URL"},
Destination: &cfg.Reva.AuthBasic.URL,
},
&cli.StringFlag{
Name: "auth-bearer-url",
Value: "localhost:9148",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_AUTH_BEARER_URL"},
Destination: &cfg.Reva.AuthBearer.URL,
},
&cli.StringFlag{
Name: "sharing-url",
Value: "localhost:9150",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_SHARING_URL"},
Destination: &cfg.Reva.Sharing.URL,
},
&cli.StringFlag{
Name: "storage-root-url",
Value: "localhost:9152",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_ROOT_URL"},
Destination: &cfg.Reva.StorageRoot.URL,
},
&cli.StringFlag{
Name: "storage-root-mount-path",
Value: "/",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_ROOT_MOUNT_PATH"},
Destination: &cfg.Reva.StorageRoot.MountPath,
},
&cli.StringFlag{
Name: "storage-root-mount-id",
Value: "1284d238-aa92-42ce-bdc4-0b0000009152",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_ROOT_MOUNT_ID"},
Destination: &cfg.Reva.StorageRoot.MountID,
},
&cli.StringFlag{
Name: "storage-home-url",
Value: "localhost:9154",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_HOME_URL"},
Destination: &cfg.Reva.StorageHome.URL,
},
&cli.StringFlag{
Name: "storage-home-mount-path",
Value: "/home",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_HOME_MOUNT_PATH"},
Destination: &cfg.Reva.StorageHome.MountPath,
},
&cli.StringFlag{
Name: "storage-home-mount-id",
Value: "1284d238-aa92-42ce-bdc4-0b0000009154",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_HOME_MOUNT_ID"},
Destination: &cfg.Reva.StorageHome.MountID,
},
&cli.StringFlag{
Name: "storage-eos-url",
Value: "localhost:9158",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_EOS_URL"},
Destination: &cfg.Reva.StorageEOS.URL,
},
&cli.StringFlag{
Name: "storage-eos-mount-path",
Value: "/eos",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_EOS_MOUNT_PATH"},
Destination: &cfg.Reva.StorageEOS.MountPath,
},
&cli.StringFlag{
Name: "storage-eos-mount-id",
Value: "1284d238-aa92-42ce-bdc4-0b0000009158",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_EOS_MOUNT_ID"},
Destination: &cfg.Reva.StorageEOS.MountID,
},
&cli.StringFlag{
Name: "storage-oc-url",
Value: "localhost:9162",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_OC_URL"},
Destination: &cfg.Reva.StorageOC.URL,
},
&cli.StringFlag{
Name: "storage-oc-mount-path",
Value: "/oc",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_OC_MOUNT_PATH"},
Destination: &cfg.Reva.StorageOC.MountPath,
},
&cli.StringFlag{
Name: "storage-oc-mount-id",
Value: "1284d238-aa92-42ce-bdc4-0b0000009162",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_OC_MOUNT_ID"},
Destination: &cfg.Reva.StorageOC.MountID,
},
&cli.StringFlag{
Name: "public-link-url",
Value: "localhost:9178",
Usage: "URL to use for the public links service",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_URL"},
Destination: &cfg.Reva.StoragePublicLink.URL,
},
&cli.StringFlag{
Name: "storage-public-link-mount-path",
Value: "/public/",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_MOUNT_PATH"},
Destination: &cfg.Reva.StoragePublicLink.MountPath,
},
// public-link has no mount id
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
return flags
}
+19
View File
@@ -0,0 +1,19 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// HealthWithConfig applies cfg to the health flagset
func HealthWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9109",
Usage: "Address to debug endpoint",
EnvVars: []string{"REVA_DEBUG_ADDR"},
Destination: &cfg.Debug.Addr,
},
}
}
+134
View File
@@ -0,0 +1,134 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// LDAPWithConfig applies LDAP cfg to the flagset
func LDAPWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "ldap-hostname",
Value: "localhost",
Usage: "LDAP hostname",
EnvVars: []string{"REVA_LDAP_HOSTNAME"},
Destination: &cfg.Reva.LDAP.Hostname,
},
&cli.IntFlag{
Name: "ldap-port",
Value: 9126,
Usage: "LDAP port",
EnvVars: []string{"REVA_LDAP_PORT"},
Destination: &cfg.Reva.LDAP.Port,
},
&cli.StringFlag{
Name: "ldap-base-dn",
Value: "dc=example,dc=org",
Usage: "LDAP basedn",
EnvVars: []string{"REVA_LDAP_BASE_DN"},
Destination: &cfg.Reva.LDAP.BaseDN,
},
&cli.StringFlag{
Name: "ldap-loginfilter",
Value: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))",
Usage: "LDAP login filter",
EnvVars: []string{"REVA_LDAP_LOGINFILTER"},
Destination: &cfg.Reva.LDAP.LoginFilter,
},
&cli.StringFlag{
Name: "ldap-userfilter",
Value: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))",
Usage: "LDAP filter used when getting a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.",
EnvVars: []string{"REVA_LDAP_USERFILTER"},
Destination: &cfg.Reva.LDAP.UserFilter,
},
&cli.StringFlag{
Name: "ldap-attributefilter",
Value: "(&(objectclass=posixAccount)({{attr}}={{value}}))",
Usage: "LDAP filter used when searching for a user by claim/attribute. {{attr}} will be replaced with the attribute, {{value}} with the value.",
EnvVars: []string{"REVA_LDAP_ATTRIBUTEFILTER"},
Destination: &cfg.Reva.LDAP.AttributeFilter,
},
&cli.StringFlag{
Name: "ldap-findfilter",
Value: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))",
Usage: "LDAP filter used when searching for recipients. {{query}} will be replaced with the search query",
EnvVars: []string{"REVA_LDAP_FINDFILTER"},
Destination: &cfg.Reva.LDAP.FindFilter,
},
&cli.StringFlag{
Name: "ldap-groupfilter",
// FIXME the reva implementation needs to use the memberof overlay to get the cn when it only has the uuid,
// because the ldap schema either uses the dn or the member(of) attributes to establish membership
Value: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", // This filter will never work
Usage: "LDAP filter used when getting the groups of a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.",
EnvVars: []string{"REVA_LDAP_GROUPFILTER"},
Destination: &cfg.Reva.LDAP.GroupFilter,
},
&cli.StringFlag{
Name: "ldap-bind-dn",
Value: "cn=reva,ou=sysusers,dc=example,dc=org",
Usage: "LDAP bind dn",
EnvVars: []string{"REVA_LDAP_BIND_DN"},
Destination: &cfg.Reva.LDAP.BindDN,
},
&cli.StringFlag{
Name: "ldap-bind-password",
Value: "reva",
Usage: "LDAP bind password",
EnvVars: []string{"REVA_LDAP_BIND_PASSWORD"},
Destination: &cfg.Reva.LDAP.BindPassword,
},
&cli.StringFlag{
Name: "ldap-idp",
Value: "https://localhost:9200",
Usage: "Identity provider to use for users",
EnvVars: []string{"REVA_LDAP_IDP"},
Destination: &cfg.Reva.LDAP.IDP,
},
// ldap dn is always the dn
&cli.StringFlag{
Name: "ldap-schema-uid",
Value: "ownclouduuid",
Usage: "LDAP schema uid",
EnvVars: []string{"REVA_LDAP_SCHEMA_UID"},
Destination: &cfg.Reva.LDAP.Schema.UID,
},
&cli.StringFlag{
Name: "ldap-schema-mail",
Value: "mail",
Usage: "LDAP schema mail",
EnvVars: []string{"REVA_LDAP_SCHEMA_MAIL"},
Destination: &cfg.Reva.LDAP.Schema.Mail,
},
&cli.StringFlag{
Name: "ldap-schema-displayName",
Value: "displayname",
Usage: "LDAP schema displayName",
EnvVars: []string{"REVA_LDAP_SCHEMA_DISPLAYNAME"},
Destination: &cfg.Reva.LDAP.Schema.DisplayName,
},
&cli.StringFlag{
Name: "ldap-schema-cn",
Value: "cn",
Usage: "LDAP schema cn",
EnvVars: []string{"REVA_LDAP_SCHEMA_CN"},
Destination: &cfg.Reva.LDAP.Schema.CN,
},
&cli.StringFlag{
Name: "ldap-schema-uidnumber",
Value: "uidnumber",
Usage: "LDAP schema uidnumber",
EnvVars: []string{"REVA_LDAP_SCHEMA_UID_NUMBER"},
Destination: &cfg.Reva.LDAP.Schema.UIDNumber,
},
&cli.StringFlag{
Name: "ldap-schema-gidnumber",
Value: "gidnumber",
Usage: "LDAP schema gidnumber",
EnvVars: []string{"REVA_LDAP_SCHEMA_GIDNUMBER"},
Destination: &cfg.Reva.LDAP.Schema.GIDNumber,
},
}
}
+38
View File
@@ -0,0 +1,38 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// RootWithConfig applies cfg to the root flagset
func RootWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "config-file",
Value: "",
Usage: "Path to config file",
EnvVars: []string{"REVA_CONFIG_FILE"},
Destination: &cfg.File,
},
&cli.StringFlag{
Name: "log-level",
Value: "info",
Usage: "Set logging level",
EnvVars: []string{"REVA_LOG_LEVEL"},
Destination: &cfg.Log.Level,
},
&cli.BoolFlag{
Name: "log-pretty",
Usage: "Enable pretty logging",
EnvVars: []string{"REVA_LOG_PRETTY"},
Destination: &cfg.Log.Pretty,
},
&cli.BoolFlag{
Name: "log-color",
Usage: "Enable colored logging",
EnvVars: []string{"REVA_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
}
}
+19
View File
@@ -0,0 +1,19 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// SecretWithConfig applies cfg to the root flagset
func SecretWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVars: []string{"REVA_JWT_SECRET"},
Destination: &cfg.Reva.JWTSecret,
},
}
}
+87
View File
@@ -0,0 +1,87 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// SharingWithConfig applies cfg to the root flagset
func SharingWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9151",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_SHARING_DEBUG_ADDR"},
Destination: &cfg.Reva.Sharing.DebugAddr,
},
// Services
// Sharing
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_SHARING_NETWORK"},
Destination: &cfg.Reva.Sharing.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_SHARING_PROTOCOL"},
Destination: &cfg.Reva.Sharing.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9150",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_SHARING_ADDR"},
Destination: &cfg.Reva.Sharing.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9150",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_SHARING_URL"},
Destination: &cfg.Reva.Sharing.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("usershareprovider", "publicshareprovider"), // TODO osmshareprovider
Usage: "--service usershareprovider [--service publicshareprovider]",
EnvVars: []string{"REVA_SHARING_SERVICES"},
},
&cli.StringFlag{
Name: "user-driver",
Value: "json",
Usage: "driver to use for the UserShareProvider",
EnvVars: []string{"REVA_SHARING_USER_DRIVER"},
Destination: &cfg.Reva.Sharing.UserDriver,
},
&cli.StringFlag{
Name: "user-json-file",
Value: "/var/tmp/reva/shares.json",
Usage: "file used to persist shares for the UserShareProvider",
EnvVars: []string{"REVA_SHARING_USER_JSON_FILE"},
Destination: &cfg.Reva.Sharing.UserJSONFile,
},
&cli.StringFlag{
Name: "public-driver",
Value: "json",
Usage: "driver to use for the PublicShareProvider",
EnvVars: []string{"REVA_SHARING_PUBLIC_DRIVER"},
Destination: &cfg.Reva.Sharing.PublicDriver,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
return flags
}
+104
View File
@@ -0,0 +1,104 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageEOSWithConfig applies cfg to the root flagset
func StorageEOSWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9159",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_EOS_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageEOS.DebugAddr,
},
// Storage eos
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_EOS_NETWORK"},
Destination: &cfg.Reva.StorageEOS.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_EOS_PROTOCOL"},
Destination: &cfg.Reva.StorageEOS.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9158",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_EOS_ADDR"},
Destination: &cfg.Reva.StorageEOS.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9158",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_EOS_URL"},
Destination: &cfg.Reva.StorageEOS.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("storageprovider"),
Usage: "--service storageprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_EOS_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "eos",
Usage: "storage driver for eos mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_EOS_DRIVER"},
Destination: &cfg.Reva.StorageEOS.Driver,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/eos",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_EOS_MOUNT_PATH"},
Destination: &cfg.Reva.StorageEOS.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
Value: "1284d238-aa92-42ce-bdc4-0b0000009158",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_EOS_MOUNT_ID"},
Destination: &cfg.Reva.StorageEOS.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Value: false,
Usage: "exposes a dedicated data server",
EnvVars: []string{"REVA_STORAGE_EOS_EXPOSE_DATA_SERVER"},
Destination: &cfg.Reva.StorageEOS.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "http://localhost:9160/data",
Usage: "data server url",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_SERVER_URL"},
Destination: &cfg.Reva.StorageEOS.DataServerURL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+111
View File
@@ -0,0 +1,111 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageEOSDataWithConfig applies cfg to the root flagset
func StorageEOSDataWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9161",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_OC_DATA_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageEOSData.DebugAddr,
},
// Services
// Storage eos data
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_NETWORK"},
Destination: &cfg.Reva.StorageEOSData.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_PROTOCOL"},
Destination: &cfg.Reva.StorageEOSData.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9160",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_ADDR"},
Destination: &cfg.Reva.StorageEOSData.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9160",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_URL"},
Destination: &cfg.Reva.StorageEOSData.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("dataprovider"),
Usage: "--service dataprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "eos",
Usage: "storage driver for eos data mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_DRIVER"},
Destination: &cfg.Reva.StorageEOSData.Driver,
},
&cli.StringFlag{
Name: "prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_PREFIX"},
Destination: &cfg.Reva.StorageEOSData.Prefix,
},
&cli.StringFlag{
Name: "temp-folder",
Value: "/var/tmp/",
Usage: "temp folder",
EnvVars: []string{"REVA_STORAGE_EOS_DATA_TEMP_FOLDER"},
Destination: &cfg.Reva.StorageEOSData.TempFolder,
},
// Gateway
&cli.StringFlag{
Name: "gateway-url",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVars: []string{"REVA_GATEWAY_URL"},
Destination: &cfg.Reva.Gateway.URL,
},
// User provider
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+127
View File
@@ -0,0 +1,127 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageHomeWithConfig applies cfg to the root flagset
func StorageHomeWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9155",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_HOME_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageHome.DebugAddr,
},
// Services
// Storage home
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_HOME_NETWORK"},
Destination: &cfg.Reva.StorageHome.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_HOME_PROTOCOL"},
Destination: &cfg.Reva.StorageHome.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9154",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_HOME_ADDR"},
Destination: &cfg.Reva.StorageHome.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9154",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_HOME_URL"},
Destination: &cfg.Reva.StorageHome.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("storageprovider"),
Usage: "--service storageprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_HOME_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver for home mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_HOME_DRIVER"},
Destination: &cfg.Reva.StorageHome.Driver,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/home",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_HOME_MOUNT_PATH"},
Destination: &cfg.Reva.StorageHome.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
// This is the mount id of the storage provider using the same storage driver
// as /home but withoud home enabled. Set it to
// 1284d238-aa92-42ce-bdc4-0b0000009158 for /eos
// 1284d238-aa92-42ce-bdc4-0b0000009162 for /oc
Value: "1284d238-aa92-42ce-bdc4-0b0000009162", // /oc
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_HOME_MOUNT_ID"},
Destination: &cfg.Reva.StorageHome.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Value: false,
Usage: "exposes a dedicated data server",
EnvVars: []string{"REVA_STORAGE_HOME_EXPOSE_DATA_SERVER"},
Destination: &cfg.Reva.StorageHome.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "http://localhost:9156/data",
Usage: "data server url",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_SERVER_URL"},
Destination: &cfg.Reva.StorageHome.DataServerURL,
},
&cli.BoolFlag{
Name: "enable-home",
Value: true,
Usage: "enable the creation of home directories",
EnvVars: []string{"REVA_STORAGE_HOME_ENABLE_HOME"},
Destination: &cfg.Reva.Storages.Home.EnableHome,
},
// User provider
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+118
View File
@@ -0,0 +1,118 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageHomeDataWithConfig applies cfg to the root flagset
func StorageHomeDataWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9157",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageHomeData.DebugAddr,
},
// Services
// Storage home data
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_NETWORK"},
Destination: &cfg.Reva.StorageHomeData.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_PROTOCOL"},
Destination: &cfg.Reva.StorageHomeData.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9156",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_ADDR"},
Destination: &cfg.Reva.StorageHomeData.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9156",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_URL"},
Destination: &cfg.Reva.StorageHomeData.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("dataprovider"),
Usage: "--service dataprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver for home data mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_DRIVER"},
Destination: &cfg.Reva.StorageHomeData.Driver,
},
&cli.StringFlag{
Name: "prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_PREFIX"},
Destination: &cfg.Reva.StorageHomeData.Prefix,
},
&cli.StringFlag{
Name: "temp-folder",
Value: "/var/tmp/",
Usage: "temp folder",
EnvVars: []string{"REVA_STORAGE_HOME_DATA_TEMP_FOLDER"},
Destination: &cfg.Reva.StorageHomeData.TempFolder,
},
&cli.BoolFlag{
Name: "enable-home",
Value: true,
Usage: "enable the creation of home directories",
EnvVars: []string{"REVA_STORAGE_HOME_ENABLE_HOME"},
Destination: &cfg.Reva.Storages.Home.EnableHome,
},
// Gateway
&cli.StringFlag{
Name: "gateway-url",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVars: []string{"REVA_GATEWAY_URL"},
Destination: &cfg.Reva.Gateway.URL,
},
// User provider
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+79
View File
@@ -0,0 +1,79 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageMetadata applies cfg to the root flagset
func StorageMetadata(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9217",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_METADATA_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageMetadata.DebugAddr,
},
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_METADATA_NETWORK"},
Destination: &cfg.Reva.StorageMetadata.Network,
},
&cli.StringFlag{
Name: "provider-addr",
Value: "0.0.0.0:9215",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_METADATA_PROVIDER_ADDR"},
Destination: &cfg.Reva.StorageMetadata.Addr,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "http://localhost:9216",
Usage: "URL of the data-server the storage-provider uses",
EnvVars: []string{"REVA_STORAGE_METADATA_DATA_SERVER_URL"},
Destination: &cfg.Reva.StorageMetadata.DataServerURL,
},
&cli.StringFlag{
Name: "data-server-addr",
Value: "0.0.0.0:9216",
Usage: "Address to bind the metadata data-server to",
EnvVars: []string{"REVA_STORAGE_METADATA_DATA_SERVER_ADDR"},
Destination: &cfg.Reva.StorageMetadataData.Addr,
},
&cli.StringFlag{
Name: "storage-provider-driver",
Value: "local",
Usage: "storage driver for metadata mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_METADATA_PROVIDER_DRIVER"},
Destination: &cfg.Reva.StorageMetadata.Driver,
},
&cli.StringFlag{
Name: "data-provider-driver",
Value: "local",
Usage: "storage driver for data-provider mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_METADATA_DATA_PROVIDER_DRIVER"},
Destination: &cfg.Reva.StorageMetadataData.Driver,
},
&cli.StringFlag{
Name: "storage-root",
Value: "/var/tmp/ocis/metadata",
Usage: "the path to the metadata storage root",
EnvVars: []string{"REVA_STORAGE_METADATA_ROOT"},
Destination: &cfg.Reva.Storages.Common.Root,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+116
View File
@@ -0,0 +1,116 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageOCWithConfig applies cfg to the root flagset
func StorageOCWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9163",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_OC_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageOC.DebugAddr,
},
// Services
// Storage oc
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_OC_NETWORK"},
Destination: &cfg.Reva.StorageOC.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_OC_PROTOCOL"},
Destination: &cfg.Reva.StorageOC.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9162",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_OC_ADDR"},
Destination: &cfg.Reva.StorageOC.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9162",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_OC_URL"},
Destination: &cfg.Reva.StorageOC.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("storageprovider"),
Usage: "--service storageprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_OC_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver for oc mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_OC_DRIVER"},
Destination: &cfg.Reva.StorageOC.Driver,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/oc",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_OC_MOUNT_PATH"},
Destination: &cfg.Reva.StorageOC.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
Value: "1284d238-aa92-42ce-bdc4-0b0000009162",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_OC_MOUNT_ID"},
Destination: &cfg.Reva.StorageOC.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Value: false,
Usage: "exposes a dedicated data server",
EnvVars: []string{"REVA_STORAGE_OC_EXPOSE_DATA_SERVER"},
Destination: &cfg.Reva.StorageOC.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "http://localhost:9164/data",
Usage: "data server url",
EnvVars: []string{"REVA_STORAGE_OC_DATA_SERVER_URL"},
Destination: &cfg.Reva.StorageOC.DataServerURL,
},
// User provider
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+111
View File
@@ -0,0 +1,111 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageOCDataWithConfig applies cfg to the root flagset
func StorageOCDataWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9165",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_OC_DATA_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageOCData.DebugAddr,
},
// Services
// Storage oc data
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_OC_DATA_NETWORK"},
Destination: &cfg.Reva.StorageOCData.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_OC_DATA_PROTOCOL"},
Destination: &cfg.Reva.StorageOCData.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9164",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_OC_DATA_ADDR"},
Destination: &cfg.Reva.StorageOCData.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9164",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_OC_DATA_URL"},
Destination: &cfg.Reva.StorageOCData.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("dataprovider"),
Usage: "--service dataprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_OC_DATA_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver for oc data mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_OC_DATA_DRIVER"},
Destination: &cfg.Reva.StorageOCData.Driver,
},
&cli.StringFlag{
Name: "prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVars: []string{"REVA_STORAGE_OC_DATA_PREFIX"},
Destination: &cfg.Reva.StorageOCData.Prefix,
},
&cli.StringFlag{
Name: "temp-folder",
Value: "/var/tmp/",
Usage: "temp folder",
EnvVars: []string{"REVA_STORAGE_OC_DATA_TEMP_FOLDER"},
Destination: &cfg.Reva.StorageOCData.TempFolder,
},
// Gateway
&cli.StringFlag{
Name: "gateway-url",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVars: []string{"REVA_GATEWAY_URL"},
Destination: &cfg.Reva.Gateway.URL,
},
// User provider
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+71
View File
@@ -0,0 +1,71 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StoragePublicLink applies cfg to the root flagset
func StoragePublicLink(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9179",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_DEBUG_ADDR"},
Destination: &cfg.Reva.StoragePublicLink.DebugAddr,
},
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_NETWORK"},
Destination: &cfg.Reva.StoragePublicLink.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_PROTOCOL"},
Destination: &cfg.Reva.StoragePublicLink.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9178",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_ADDR"},
Destination: &cfg.Reva.StoragePublicLink.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9178",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_URL"},
Destination: &cfg.Reva.StoragePublicLink.URL,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/public/",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_MOUNT_PATH"},
Destination: &cfg.Reva.StoragePublicLink.MountPath,
},
&cli.StringFlag{
Name: "gateway-url",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVars: []string{"REVA_GATEWAY_URL"},
Destination: &cfg.Reva.Gateway.URL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
return flags
}
+105
View File
@@ -0,0 +1,105 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// StorageRootWithConfig applies cfg to the root flagset
func StorageRootWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9153",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_STORAGE_ROOT_DEBUG_ADDR"},
Destination: &cfg.Reva.StorageRoot.DebugAddr,
},
// Services
// Storage root
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_STORAGE_ROOT_NETWORK"},
Destination: &cfg.Reva.StorageRoot.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_STORAGE_ROOT_PROTOCOL"},
Destination: &cfg.Reva.StorageRoot.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9152",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_STORAGE_ROOT_ADDR"},
Destination: &cfg.Reva.StorageRoot.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9152",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_STORAGE_ROOT_URL"},
Destination: &cfg.Reva.StorageRoot.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("storageprovider"),
Usage: "--service storageprovider [--service otherservice]",
EnvVars: []string{"REVA_STORAGE_ROOT_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "local",
Usage: "storage driver for root mount: eg. local, eos, owncloud, ocis or s3",
EnvVars: []string{"REVA_STORAGE_ROOT_DRIVER"},
Destination: &cfg.Reva.StorageRoot.Driver,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/",
Usage: "mount path",
EnvVars: []string{"REVA_STORAGE_ROOT_MOUNT_PATH"},
Destination: &cfg.Reva.StorageRoot.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
Value: "123e4567-e89b-12d3-a456-426655440001",
Usage: "mount id",
EnvVars: []string{"REVA_STORAGE_ROOT_MOUNT_ID"},
Destination: &cfg.Reva.StorageRoot.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Usage: "exposes a dedicated data server",
EnvVars: []string{"REVA_STORAGE_ROOT_EXPOSE_DATA_SERVER"},
Destination: &cfg.Reva.StorageRoot.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "",
Usage: "data server url",
EnvVars: []string{"REVA_STORAGE_ROOT_DATA_SERVER_URL"},
Destination: &cfg.Reva.StorageRoot.DataServerURL,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, DriverEOSWithConfig(cfg)...)
flags = append(flags, DriverLocalWithConfig(cfg)...)
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
return flags
}
+47
View File
@@ -0,0 +1,47 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// TracingWithConfig applies cfg to the root flagset
func TracingWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVars: []string{"REVA_TRACING_ENABLED"},
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVars: []string{"REVA_TRACING_TYPE"},
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVars: []string{"REVA_TRACING_ENDPOINT"},
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVars: []string{"REVA_TRACING_COLLECTOR"},
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVars: []string{"REVA_TRACING_SERVICE"},
Destination: &cfg.Tracing.Service,
},
}
}
+155
View File
@@ -0,0 +1,155 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// UsersWithConfig applies cfg to the root flagset
func UsersWithConfig(cfg *config.Config) []cli.Flag {
flags := []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9145",
Usage: "Address to bind debug server",
EnvVars: []string{"REVA_SHARING_DEBUG_ADDR"},
Destination: &cfg.Reva.Users.DebugAddr,
},
// Services
// Users
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVars: []string{"REVA_USERS_NETWORK"},
Destination: &cfg.Reva.Users.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVars: []string{"REVA_USERS_PROTOCOL"},
Destination: &cfg.Reva.Users.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9144",
Usage: "Address to bind reva service",
EnvVars: []string{"REVA_USERS_ADDR"},
Destination: &cfg.Reva.Users.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVars: []string{"REVA_USERS_URL"},
Destination: &cfg.Reva.Users.URL,
},
&cli.StringSliceFlag{
Name: "service",
Value: cli.NewStringSlice("userprovider"), // TODO preferences
Usage: "--service userprovider [--service otherservice]",
EnvVars: []string{"REVA_USERS_SERVICES"},
},
&cli.StringFlag{
Name: "driver",
Value: "ldap",
Usage: "user driver: 'demo', 'json', 'ldap', or 'rest'",
EnvVars: []string{"REVA_USERS_DRIVER"},
Destination: &cfg.Reva.Users.Driver,
},
&cli.StringFlag{
Name: "json-config",
Value: "",
Usage: "Path to users.json file",
EnvVars: []string{"REVA_USERS_JSON"},
Destination: &cfg.Reva.Users.JSON,
},
// rest driver
&cli.StringFlag{
Name: "rest-client-id",
Value: "",
Usage: "User rest driver Client ID",
EnvVars: []string{"REVA_REST_CLIENT_ID"},
Destination: &cfg.Reva.UserRest.ClientID,
},
&cli.StringFlag{
Name: "rest-client-secret",
Value: "",
Usage: "User rest driver Client Secret",
EnvVars: []string{"REVA_REST_CLIENT_SECRET"},
Destination: &cfg.Reva.UserRest.ClientSecret,
},
&cli.StringFlag{
Name: "rest-redis-address",
Value: "localhost:6379",
Usage: "Address for redis server",
EnvVars: []string{"REVA_REST_REDIS_ADDRESS"},
Destination: &cfg.Reva.UserRest.RedisAddress,
},
&cli.StringFlag{
Name: "rest-redis-username",
Value: "",
Usage: "Username for redis server",
EnvVars: []string{"REVA_REST_REDIS_USERNAME"},
Destination: &cfg.Reva.UserRest.RedisUsername,
},
&cli.StringFlag{
Name: "rest-redis-password",
Value: "",
Usage: "Password for redis server",
EnvVars: []string{"REVA_REST_REDIS_PASSWORD"},
Destination: &cfg.Reva.UserRest.RedisPassword,
},
&cli.IntFlag{
Name: "rest-user-groups-cache-expiration",
Value: 5,
Usage: "Time in minutes for redis cache expiration.",
EnvVars: []string{"REVA_REST_CACHE_EXPIRATION"},
Destination: &cfg.Reva.UserRest.UserGroupsCacheExpiration,
},
&cli.StringFlag{
Name: "rest-id-provider",
Value: "",
Usage: "The OIDC Provider",
EnvVars: []string{"REVA_REST_ID_PROVIDER"},
Destination: &cfg.Reva.UserRest.IDProvider,
},
&cli.StringFlag{
Name: "rest-api-base-url",
Value: "",
Usage: "Base API Endpoint",
EnvVars: []string{"REVA_REST_API_BASE_URL"},
Destination: &cfg.Reva.UserRest.APIBaseURL,
},
&cli.StringFlag{
Name: "rest-oidc-token-endpoint",
Value: "",
Usage: "Endpoint to generate token to access the API",
EnvVars: []string{"REVA_REST_OIDC_TOKEN_ENDPOINT"},
Destination: &cfg.Reva.UserRest.OIDCTokenEndpoint,
},
&cli.StringFlag{
Name: "rest-target-api",
Value: "",
Usage: "The target application",
EnvVars: []string{"REVA_REST_TARGET_API"},
Destination: &cfg.Reva.UserRest.TargetAPI,
},
}
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, LDAPWithConfig(cfg)...)
return flags
}
+66
View File
@@ -0,0 +1,66 @@
package debug
import (
"context"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
)
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Name string
Addr string
Logger log.Logger
Context context.Context
Config *config.Config
}
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// Name provides a function to set the name option.
func Name(val string) Option {
return func(o *Options) {
o.Name = val
}
}
// Addr provides a function to set the addr option.
func Addr(val string) Option {
return func(o *Options) {
o.Addr = val
}
}
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {
o.Logger = val
}
}
// Context provides a function to set the context option.
func Context(val context.Context) Option {
return func(o *Options) {
o.Context = val
}
}
// Config provides a function to set the config option.
func Config(val *config.Config) Option {
return func(o *Options) {
o.Config = val
}
}
+51
View File
@@ -0,0 +1,51 @@
package debug
import (
"io"
"net/http"
"github.com/owncloud/ocis/ocis-pkg/service/debug"
"github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/version"
)
// Server initializes the debug service and server.
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Name),
debug.Version(version.String),
debug.Address(options.Addr),
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),
debug.Health(health(options.Config)),
debug.Ready(ready(options.Config)),
), nil
}
// health implements the health check.
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running
io.WriteString(w, http.StatusText(http.StatusOK))
}
}
// ready implements the ready check.
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running
io.WriteString(w, http.StatusText(http.StatusOK))
}
}
+66
View File
@@ -0,0 +1,66 @@
package external
import (
"context"
"time"
"github.com/micro/go-micro/v2/broker"
"github.com/micro/go-micro/v2/registry"
"github.com/owncloud/ocis/ocis-pkg/log"
)
// RegisterGRPCEndpoint publishes an arbitrary endpoint to the service-registry. This allows to query nodes of
// non-micro GRPC-services like reva. No health-checks are done, thus the caller is responsible for canceling.
//
func RegisterGRPCEndpoint(ctx context.Context, serviceID, uuid, addr string, logger log.Logger) error {
node := &registry.Node{
Id: serviceID + "-" + uuid,
Address: addr,
Metadata: make(map[string]string),
}
node.Metadata["broker"] = broker.String()
node.Metadata["registry"] = registry.String()
node.Metadata["server"] = "grpc"
node.Metadata["transport"] = "grpc"
node.Metadata["protocol"] = "grpc"
service := &registry.Service{
Name: serviceID,
Version: "",
Nodes: []*registry.Node{node},
Endpoints: make([]*registry.Endpoint, 0),
}
rOpts := []registry.RegisterOption{registry.RegisterTTL(time.Minute)}
logger.Info().Msgf("Registering external service %v@%v", node.Id, node.Address)
if err := registry.Register(service, rOpts...); err != nil {
logger.Fatal().Err(err).Msgf("Registration error for external service %v", serviceID)
}
t := time.NewTicker(time.Second * 30)
go func() {
for {
select {
case <-t.C:
logger.Debug().Interface("service", service).Msg("refreshing external service-registration")
err := registry.Register(service, rOpts...)
if err != nil {
logger.Error().Err(err).Msgf("registration error for external service %v", serviceID)
}
case <-ctx.Done():
logger.Debug().Interface("service", service).Msg("unregistering")
t.Stop()
err := registry.Deregister(service)
if err != nil {
logger.Err(err).Msgf("Error unregistering external service %v", serviceID)
}
}
}
}()
return nil
}
+60
View File
@@ -0,0 +1,60 @@
package external
//
//import (
// "context"
// "testing"
//
// "github.com/micro/go-micro/v2/registry"
// "github.com/owncloud/ocis/ocis-pkg/log"
//)
//
//func TestRegisterGRPCEndpoint(t *testing.T) {
// ctx, cancel := context.WithCancel(context.Background())
// err := RegisterGRPCEndpoint(ctx, "test", "1234", "192.168.0.1:777", log.Logger{})
// if err != nil {
// t.Errorf("Unexpected error: %v", err)
// }
//
// s, err := registry.GetService("test")
// if err != nil {
// t.Errorf("Unexpected error: %v", err)
// }
//
// if len(s) != 1 {
// t.Errorf("Expected exactly one service to be returned got %v", len(s))
// }
//
// if len(s[0].Nodes) != 1 {
// t.Errorf("Expected exactly one node to be returned got %v", len(s[0].Nodes))
// }
//
// testSvc := s[0]
// if testSvc.Name != "test" {
// t.Errorf("Expected service name to be 'test' got %v", s[0].Name)
// }
//
// testNode := testSvc.Nodes[0]
//
// if testNode.Address != "192.168.0.1:777" {
// t.Errorf("Expected node address to be '192.168.0.1:777' got %v", testNode.Address)
// }
//
// if testNode.Id != "test-1234" {
// t.Errorf("Expected node id to be 'test-1234' got %v", testNode.Id)
// }
//
// cancel()
//
// // When switching over to monorepo this little test fails. We're unsure of what the cause is, but since this test
// // is testing a framework specific behavior, we're better off letting it commented out. There is also no use of
// // com.owncloud.reva anywhere in the codebase, so we're effectively only registering reva as a go-micro service,
// // but not sending any message.
// s, err = registry.GetService("test")
// if err != nil {
// t.Errorf("Unexpected error: %v", err)
// }
//
// if len(s) != 0 {
// t.Errorf("Deregister on cancelation failed. Result-length should be zero, got %v", len(s))
// }
//}
+19
View File
@@ -0,0 +1,19 @@
package version
import (
"time"
)
var (
// String gets defined by the build system.
String = "0.0.0"
// Date indicates the build date.
Date = "00000000"
)
// Compiled returns the compile time of this service.
func Compiled() time.Time {
t, _ := time.Parse("20060102", Date)
return t
}