add missing commands and unify service / namespace options

This commit is contained in:
Willy Kloucek
2021-11-24 18:30:20 +01:00
committed by Jörn Friedrich Dreyer
parent 6621ac2ef6
commit 3b5a33590e
66 changed files with 516 additions and 218 deletions

View File

@@ -41,7 +41,7 @@ func AddAccount(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
accSvcID := cfg.GRPC.Namespace + "." + cfg.Server.Name
accSvcID := cfg.GRPC.Namespace + "." + cfg.Service.Name
accSvc := accounts.NewAccountsService(accSvcID, grpc.NewClient())
_, err := accSvc.CreateAccount(c.Context, &accounts.CreateAccountRequest{
Account: a,

View File

@@ -22,7 +22,7 @@ func InspectAccount(cfg *config.Config) *cli.Command {
ArgsUsage: "id",
Flags: flagset.InspectAccountWithConfig(cfg),
Action: func(c *cli.Context) error {
accServiceID := cfg.GRPC.Namespace + "." + cfg.Server.Name
accServiceID := cfg.GRPC.Namespace + "." + cfg.Service.Name
if c.NArg() != 1 {
fmt.Println("Please provide a user-id")
os.Exit(1)

View File

@@ -22,7 +22,7 @@ func ListAccounts(cfg *config.Config) *cli.Command {
Aliases: []string{"ls"},
Flags: flagset.ListAccountsWithConfig(cfg),
Action: func(c *cli.Context) error {
accSvcID := cfg.GRPC.Namespace + "." + cfg.Server.Name
accSvcID := cfg.GRPC.Namespace + "." + cfg.Service.Name
accSvc := accounts.NewAccountsService(accSvcID, grpc.NewClient())
resp, err := accSvc.ListAccounts(c.Context, &accounts.ListAccountsRequest{})

View File

@@ -21,7 +21,7 @@ func RemoveAccount(cfg *config.Config) *cli.Command {
Aliases: []string{"rm"},
Flags: flagset.RemoveAccountWithConfig(cfg),
Action: func(c *cli.Context) error {
accServiceID := cfg.GRPC.Namespace + "." + cfg.Server.Name
accServiceID := cfg.GRPC.Namespace + "." + cfg.Service.Name
if c.NArg() != 1 {
fmt.Println("Please provide a user-id")
os.Exit(1)

View File

@@ -27,7 +27,7 @@ func Execute(cfg *config.Config) error {
},
},
Before: func(c *cli.Context) error {
cfg.Server.Version = version.String
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},

View File

@@ -47,7 +47,7 @@ func Server(cfg *config.Config) *cli.Command {
defer cancel()
mtrcs.BuildInfo.WithLabelValues(cfg.Server.Version).Set(1)
mtrcs.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
handler, err := svc.New(svc.Logger(logger), svc.Config(cfg))
if err != nil {
@@ -58,7 +58,7 @@ func Server(cfg *config.Config) *cli.Command {
httpServer := http.Server(
http.Config(cfg),
http.Logger(logger),
http.Name(cfg.Server.Name),
http.Name(cfg.Service.Name),
http.Context(ctx),
http.Metrics(mtrcs),
http.Handler(handler),
@@ -72,7 +72,7 @@ func Server(cfg *config.Config) *cli.Command {
grpcServer := grpc.Server(
grpc.Config(cfg),
grpc.Logger(logger),
grpc.Name(cfg.Server.Name),
grpc.Name(cfg.Service.Name),
grpc.Context(ctx),
grpc.Metrics(mtrcs),
grpc.Handler(handler),

View File

@@ -40,7 +40,7 @@ func UpdateAccount(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
a.Id = c.Args().First()
accSvcID := cfg.GRPC.Namespace + "." + cfg.Server.Name
accSvcID := cfg.GRPC.Namespace + "." + cfg.Service.Name
accSvc := accounts.NewAccountsService(accSvcID, grpc.NewClient())
_, err := accSvc.UpdateAccount(c.Context, &accounts.UpdateAccountRequest{
Account: a,

View File

@@ -18,7 +18,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
Usage: "Print the versions of the running instances",
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Server.Name)
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get accounts services from the registry: %v", err))
return err

View File

@@ -56,12 +56,10 @@ type GRPC struct {
Namespace string `ocisConfig:"namespace"`
}
// Server configures a server.
type Server struct {
Version string `ocisConfig:"version"`
Name string `ocisConfig:"name"`
HashDifficulty int `ocisConfig:"hash_difficulty"`
DemoUsersAndGroups bool `ocisConfig:"demo_users_and_groups"`
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Asset defines the available asset configuration.
@@ -125,17 +123,19 @@ type Tracing struct {
type Config struct {
*shared.Commons
LDAP LDAP `ocisConfig:"ldap"`
HTTP HTTP `ocisConfig:"http"`
GRPC GRPC `ocisConfig:"grpc"`
Server Server `ocisConfig:"server"`
Asset Asset `ocisConfig:"asset"`
Log *shared.Log `ocisConfig:"log"`
TokenManager TokenManager `ocisConfig:"token_manager"`
Repo Repo `ocisConfig:"repo"`
Index Index `ocisConfig:"index"`
ServiceUser ServiceUser `ocisConfig:"service_user"`
Tracing Tracing `ocisConfig:"tracing"`
LDAP LDAP `ocisConfig:"ldap"`
HTTP HTTP `ocisConfig:"http"`
GRPC GRPC `ocisConfig:"grpc"`
Service Service `ocisConfig:"service"`
Asset Asset `ocisConfig:"asset"`
Log *shared.Log `ocisConfig:"log"`
TokenManager TokenManager `ocisConfig:"token_manager"`
Repo Repo `ocisConfig:"repo"`
Index Index `ocisConfig:"index"`
ServiceUser ServiceUser `ocisConfig:"service_user"`
HashDifficulty int `ocisConfig:"hash_difficulty"`
DemoUsersAndGroups bool `ocisConfig:"demo_users_and_groups"`
Tracing Tracing `ocisConfig:"tracing"`
Context context.Context
Supervised bool
@@ -167,15 +167,15 @@ func DefaultConfig() *Config {
Addr: "127.0.0.1:9180",
Namespace: "com.owncloud.api",
},
Server: Server{
Name: "accounts",
HashDifficulty: 11,
DemoUsersAndGroups: true,
Service: Service{
Name: "accounts",
},
Asset: Asset{},
TokenManager: TokenManager{
JWTSecret: "Pive-Fumkiu4",
},
HashDifficulty: 11,
DemoUsersAndGroups: true,
Repo: Repo{
Backend: "CS3",
Disk: Disk{

View File

@@ -69,16 +69,16 @@ func structMappings(cfg *Config) []shared.EnvBinding {
Destination: &cfg.GRPC.Addr,
},
{
EnvVars: []string{"ACCOUNTS_NAME"},
Destination: &cfg.Server.Name,
EnvVars: []string{"ACCOUNTS_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
{
EnvVars: []string{"ACCOUNTS_HASH_DIFFICULTY"},
Destination: &cfg.Server.HashDifficulty,
Destination: &cfg.HashDifficulty,
},
{
EnvVars: []string{"ACCOUNTS_DEMO_USERS_AND_GROUPS"},
Destination: &cfg.Server.DemoUsersAndGroups,
Destination: &cfg.DemoUsersAndGroups,
},
{
EnvVars: []string{"ACCOUNTS_ASSET_PATH"},

View File

@@ -23,10 +23,10 @@ func UpdateAccountWithConfig(cfg *config.Config, a *accounts.Account) []cli.Flag
},
&cli.StringFlag{
Name: "name",
Value: flags.OverrideDefaultString(cfg.Server.Name, "accounts"),
Value: flags.OverrideDefaultString(cfg.Service.Name, "accounts"),
Usage: "service name",
EnvVars: []string{"ACCOUNTS_NAME"},
Destination: &cfg.Server.Name,
Destination: &cfg.Service.Name,
},
&cli.BoolFlag{
Name: "enabled",
@@ -107,10 +107,10 @@ func AddAccountWithConfig(cfg *config.Config, a *accounts.Account) []cli.Flag {
},
&cli.StringFlag{
Name: "name",
Value: flags.OverrideDefaultString(cfg.Server.Name, "accounts"),
Value: flags.OverrideDefaultString(cfg.Service.Name, "accounts"),
Usage: "service name",
EnvVars: []string{"ACCOUNTS_NAME"},
Destination: &cfg.Server.Name,
Destination: &cfg.Service.Name,
},
&cli.BoolFlag{
Name: "enabled",
@@ -191,10 +191,10 @@ func ListAccountsWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "name",
Value: flags.OverrideDefaultString(cfg.Server.Name, "accounts"),
Value: flags.OverrideDefaultString(cfg.Service.Name, "accounts"),
Usage: "service name",
EnvVars: []string{"ACCOUNTS_NAME"},
Destination: &cfg.Server.Name,
Destination: &cfg.Service.Name,
},
}
}
@@ -211,10 +211,10 @@ func RemoveAccountWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "name",
Value: flags.OverrideDefaultString(cfg.Server.Name, "accounts"),
Value: flags.OverrideDefaultString(cfg.Service.Name, "accounts"),
Usage: "service name",
EnvVars: []string{"ACCOUNTS_NAME"},
Destination: &cfg.Server.Name,
Destination: &cfg.Service.Name,
},
}
}
@@ -231,10 +231,10 @@ func InspectAccountWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "name",
Value: flags.OverrideDefaultString(cfg.Server.Name, "accounts"),
Value: flags.OverrideDefaultString(cfg.Service.Name, "accounts"),
Usage: "service name",
EnvVars: []string{"ACCOUNTS_NAME"},
Destination: &cfg.Server.Name,
Destination: &cfg.Service.Name,
},
}
}

View File

@@ -81,7 +81,7 @@ func init() {
cfg := config.New()
cfg.Repo.Backend = "disk"
cfg.Repo.Disk.Path = dataPath
cfg.Server.DemoUsersAndGroups = true
cfg.DemoUsersAndGroups = true
var hdlr *svc.Service
var err error

View File

@@ -11,13 +11,13 @@ func Server(opts ...Option) grpc.Service {
handler := options.Handler
service := grpc.NewService(
grpc.Name(options.Config.Server.Name),
grpc.Name(options.Config.Service.Name),
grpc.Context(options.Context),
grpc.Address(options.Config.GRPC.Addr),
grpc.Namespace(options.Config.GRPC.Namespace),
grpc.Logger(options.Logger),
grpc.Flags(options.Flags...),
grpc.Version(options.Config.Server.Version),
grpc.Version(options.Config.Service.Version),
)
if err := proto.RegisterAccountsServiceHandler(service.Server(), handler); err != nil {

View File

@@ -21,7 +21,7 @@ func Server(opts ...Option) http.Service {
service := http.NewService(
http.Logger(options.Logger),
http.Name(options.Name),
http.Version(options.Config.Server.Version),
http.Version(options.Config.Service.Version),
http.Address(options.Config.HTTP.Addr),
http.Namespace(options.Config.HTTP.Namespace),
http.Context(options.Context),

View File

@@ -381,7 +381,7 @@ func (s Service) CreateAccount(ctx context.Context, in *proto.CreateAccountReque
if out.PasswordProfile != nil {
if out.PasswordProfile.Password != "" {
// encrypt password
hashed, err := bcrypt.GenerateFromPassword([]byte(in.Account.PasswordProfile.Password), s.Config.Server.HashDifficulty)
hashed, err := bcrypt.GenerateFromPassword([]byte(in.Account.PasswordProfile.Password), s.Config.HashDifficulty)
if err != nil {
s.log.Error().Err(err).Str("id", id).Msg("could not hash password")
return merrors.InternalServerError(s.id, "could not hash password: %v", err.Error())
@@ -572,7 +572,7 @@ func (s Service) UpdateAccount(ctx context.Context, in *proto.UpdateAccountReque
}
if in.Account.PasswordProfile.Password != "" {
// encrypt password
hashed, err := bcrypt.GenerateFromPassword([]byte(in.Account.PasswordProfile.Password), s.Config.Server.HashDifficulty)
hashed, err := bcrypt.GenerateFromPassword([]byte(in.Account.PasswordProfile.Password), s.Config.HashDifficulty)
if err != nil {
in.Account.PasswordProfile.Password = ""
s.log.Error().Err(err).Str("id", id).Msg("could not hash password")

View File

@@ -32,7 +32,7 @@ var (
func init() {
cfg := config.New()
cfg.Server.Name = "accounts"
cfg.Service.Name = "accounts"
cfg.Repo.Backend = "disk"
cfg.Repo.Disk.Path = dataPath
logger := olog.NewLogger(olog.Color(true), olog.Pretty(true))

View File

@@ -57,7 +57,7 @@ func New(opts ...Option) (s *Service, err error) {
}
s = &Service{
id: cfg.GRPC.Namespace + "." + cfg.Server.Name,
id: cfg.GRPC.Namespace + "." + cfg.Service.Name,
log: logger,
Config: cfg,
RoleService: roleService,
@@ -81,11 +81,11 @@ func New(opts ...Option) (s *Service, err error) {
return nil, err
}
if err = s.createDefaultAccounts(cfg.Server.DemoUsersAndGroups); err != nil {
if err = s.createDefaultAccounts(cfg.DemoUsersAndGroups); err != nil {
return nil, err
}
if err = s.createDefaultGroups(cfg.Server.DemoUsersAndGroups); err != nil {
if err = s.createDefaultGroups(cfg.DemoUsersAndGroups); err != nil {
return nil, err
}
return

View File

@@ -28,7 +28,7 @@ func Execute(cfg *config.Config) error {
},
},
Before: func(c *cli.Context) error {
cfg.Version = version.String
cfg.Service.Version = version.String
return nil
},
Commands: []*cli.Command{

View File

@@ -2,7 +2,6 @@ package command
import (
"context"
"strings"
glauthcfg "github.com/glauth/glauth/v2/pkg/config"
"github.com/oklog/run"
@@ -23,9 +22,6 @@ func Server(cfg *config.Config) *cli.Command {
Name: "server",
Usage: "Start integrated server",
Before: func(ctx *cli.Context) error {
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
if err := ParseConfig(ctx, cfg); err != nil {
return err

View File

@@ -0,0 +1,47 @@
package command
import (
"fmt"
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/glauth/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Ldaps.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get glauth services from the registry: %v", err))
return err
}
if len(services) == 0 {
fmt.Println("No running glauth service found.")
return nil
}
table := tw.NewWriter(os.Stdout)
table.SetHeader([]string{"Version", "Address", "Id"})
table.SetAutoFormatHeaders(false)
for _, s := range services {
for _, n := range s.Nodes {
table.Append([]string{s.Version, n.Address, n.Id})
}
}
table.Render()
return nil
},
}
}

View File

@@ -17,11 +17,10 @@ type Debug struct {
Zpages bool `ocisConfig:"zpages"`
}
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `ocisConfig:"addr"`
Namespace string `ocisConfig:"namespace"`
Root string `ocisConfig:"root"`
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -35,16 +34,18 @@ type Tracing struct {
// Ldap defined the available LDAP configuration.
type Ldap struct {
Enabled bool `ocisConfig:"enabled"`
Addr string `ocisConfig:"addr"`
Enabled bool `ocisConfig:"enabled"`
Addr string `ocisConfig:"addr"`
Namespace string `ocisConfig:"namespace"`
}
// Ldaps defined the available LDAPS configuration.
type Ldaps struct {
Addr string `ocisConfig:"addr"`
Enabled bool `ocisConfig:"enabled"`
Cert string `ocisConfig:"cert"`
Key string `ocisConfig:"key"`
Enabled bool `ocisConfig:"enabled"`
Addr string `ocisConfig:"addr"`
Namespace string `ocisConfig:"namespace"`
Cert string `ocisConfig:"cert"`
Key string `ocisConfig:"key"`
}
// Backend defined the available backend configuration.
@@ -66,7 +67,7 @@ type Config struct {
File string `ocisConfig:"file"`
Log *shared.Log `ocisConfig:"log"`
Debug Debug `ocisConfig:"debug"`
HTTP HTTP `ocisConfig:"http"`
Service Service `ocisConfig:"service"`
Tracing Tracing `ocisConfig:"tracing"`
Ldap Ldap `ocisConfig:"ldap"`
Ldaps Ldaps `ocisConfig:"ldaps"`
@@ -89,20 +90,24 @@ func DefaultConfig() *Config {
Debug: Debug{
Addr: "127.0.0.1:9129",
},
HTTP: HTTP{},
Tracing: Tracing{
Type: "jaeger",
Service: "glauth",
},
Service: Service{
Name: "glauth",
},
Ldap: Ldap{
Enabled: true,
Addr: "127.0.0.1:9125",
Enabled: true,
Addr: "127.0.0.1:9125",
Namespace: "com.owncloud.ldap",
},
Ldaps: Ldaps{
Addr: "127.0.0.1:9126",
Enabled: true,
Cert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"),
Key: path.Join(defaults.BaseDataPath(), "ldap", "ldap.key"),
Enabled: true,
Addr: "127.0.0.1:9126",
Namespace: "com.owncloud.ldaps",
Cert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"),
Key: path.Join(defaults.BaseDataPath(), "ldap", "ldap.key"),
},
Backend: Backend{
Datastore: "accounts",

View File

@@ -26,7 +26,7 @@ func Execute(cfg *config.Config) error {
},
},
Before: func(c *cli.Context) error {
cfg.Server.Version = version.String
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{

View File

@@ -42,7 +42,7 @@ func Server(cfg *config.Config) *cli.Command {
defer cancel()
mtrcs.BuildInfo.WithLabelValues(cfg.Server.Version).Set(1)
mtrcs.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
{
server, err := http.Server(

View File

@@ -0,0 +1,47 @@
package command
import (
"fmt"
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/graph-explorer/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get graph services from the registry: %v", err))
return err
}
if len(services) == 0 {
fmt.Println("No running graph service found.")
return nil
}
table := tw.NewWriter(os.Stdout)
table.SetHeader([]string{"Version", "Address", "Id"})
table.SetAutoFormatHeaders(false)
for _, s := range services {
for _, n := range s.Nodes {
table.Append([]string{s.Version, n.Address, n.Id})
}
}
table.Render()
return nil
},
}
}

View File

@@ -21,10 +21,10 @@ type HTTP struct {
Namespace string `ocisConfig:"namespace"`
}
// Server configures a server.
type Server struct {
Version string `ocisConfig:"version"`
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -50,7 +50,7 @@ type Config struct {
Log shared.Log `ocisConfig:"log"`
Debug Debug `ocisConfig:"debug"`
HTTP HTTP `ocisConfig:"http"`
Server Server `ocisConfig:"server"`
Service Service `ocisConfig:"service"`
Tracing Tracing `ocisConfig:"tracing"`
GraphExplorer GraphExplorer `ocisConfig:"graph_explorer"`
@@ -78,7 +78,9 @@ func DefaultConfig() *Config {
Root: "/graph-explorer",
Namespace: "com.owncloud.web",
},
Server: Server{},
Service: Service{
Name: "graph",
},
Tracing: Tracing{
Type: "jaeger",
Endpoint: "",

View File

@@ -29,7 +29,7 @@ func Execute(cfg *config.Config) error {
},
},
Before: func(c *cli.Context) error {
cfg.Server.Version = version.String
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{

View File

@@ -47,7 +47,7 @@ func Server(cfg *config.Config) *cli.Command {
defer cancel()
mtrcs.BuildInfo.WithLabelValues(cfg.Server.Version).Set(1)
mtrcs.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
{
server, err := http.Server(

View File

@@ -0,0 +1,47 @@
package command
import (
"fmt"
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/graph/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get graph services from the registry: %v", err))
return err
}
if len(services) == 0 {
fmt.Println("No running graph service found.")
return nil
}
table := tw.NewWriter(os.Stdout)
table.SetHeader([]string{"Version", "Address", "Id"})
table.SetAutoFormatHeaders(false)
for _, s := range services {
for _, n := range s.Nodes {
table.Append([]string{s.Version, n.Address, n.Id})
}
}
table.Render()
return nil
},
}
}

View File

@@ -21,10 +21,10 @@ type HTTP struct {
Root string `ocisConfig:"root"`
}
// Server configures a server.
type Server struct {
Version string `ocisConfig:"version"`
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -85,7 +85,7 @@ type Config struct {
Log *shared.Log `ocisConfig:"log"`
Debug Debug `ocisConfig:"debug"`
HTTP HTTP `ocisConfig:"http"`
Server Server `ocisConfig:"server"`
Service Service `ocisConfig:"service"`
Tracing Tracing `ocisConfig:"tracing"`
Reva Reva `ocisConfig:"reva"`
TokenManager TokenManager `ocisConfig:"token_manager"`
@@ -109,10 +109,12 @@ func DefaultConfig() *Config {
},
HTTP: HTTP{
Addr: "127.0.0.1:9120",
Namespace: "com.owncloud.web",
Namespace: "com.owncloud.graph",
Root: "/graph",
},
Server: Server{},
Service: Service{
Name: "graph",
},
Tracing: Tracing{
Enabled: false,
Type: "jaeger",

View File

@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name)
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get idp services from the registry: %v", err))
return err

View File

@@ -19,11 +19,18 @@ type Debug struct {
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
TLSCert string `ocisConfig:"tls_cert"`
TLSKey string `ocisConfig:"tls_key"`
TLS bool `ocisConfig:"tls"`
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
Namespace string `ocisConfig:"namespace"`
TLSCert string `ocisConfig:"tls_cert"`
TLSKey string `ocisConfig:"tls_key"`
TLS bool `ocisConfig:"tls"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Ldap defines the available LDAP configuration.
@@ -41,13 +48,6 @@ type Ldap struct {
Filter string `ocisConfig:"filter"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Namespace string `ocisConfig:"namespace"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool `ocisConfig:"enabled"`
@@ -125,11 +125,15 @@ func DefaultConfig() *Config {
Addr: "127.0.0.1:9134",
},
HTTP: HTTP{
Addr: "127.0.0.1:9130",
Root: "/",
TLSCert: path.Join(defaults.BaseDataPath(), "idp", "server.crt"),
TLSKey: path.Join(defaults.BaseDataPath(), "idp", "server.key"),
TLS: false,
Addr: "127.0.0.1:9130",
Root: "/",
Namespace: "com.owncloud.web",
TLSCert: path.Join(defaults.BaseDataPath(), "idp", "server.crt"),
TLSKey: path.Join(defaults.BaseDataPath(), "idp", "server.key"),
TLS: false,
},
Service: Service{
Name: "idp",
},
Tracing: Tracing{
Type: "jaeger",
@@ -184,9 +188,5 @@ func DefaultConfig() *Config {
UUIDAttributeType: "text",
Filter: "(objectClass=posixaccount)",
},
Service: Service{
Name: "idp",
Namespace: "com.owncloud.web",
},
}
}

View File

@@ -89,10 +89,10 @@ func structMappings(cfg *Config) []shared.EnvBinding {
},
{
EnvVars: []string{"IDP_HTTP_NAMESPACE"},
Destination: &cfg.Service.Namespace,
Destination: &cfg.HTTP.Namespace,
},
{
EnvVars: []string{"IDP_NAME"},
EnvVars: []string{"IDP_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
{

View File

@@ -40,7 +40,7 @@ func Server(opts ...Option) (http.Service, error) {
service := http.NewService(
http.Logger(options.Logger),
http.Namespace(options.Config.Service.Namespace),
http.Namespace(options.Config.HTTP.Namespace),
http.Name(options.Config.Service.Name),
http.Version(options.Config.Service.Version),
http.Address(options.Config.HTTP.Addr),

42
ocis/pkg/command/graph.go Normal file
View File

@@ -0,0 +1,42 @@
//go:build !simple
// +build !simple
package command
import (
"github.com/owncloud/ocis/graph/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
// GraphCommand is the entrypoint for the graph command.
func GraphCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "graph",
Usage: "Start graph server",
Category: "Extensions",
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
if cfg.Commons != nil {
cfg.Graph.Commons = cfg.Commons
}
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.Graph)
return handleOriginalAction(c, origCmd)
},
Subcommands: []*cli.Command{
command.PrintVersion(cfg.Graph),
},
}
}
func init() {
register.AddCommand(GraphCommand)
}

View File

@@ -0,0 +1,42 @@
//go:build !simple
// +build !simple
package command
import (
"github.com/owncloud/ocis/graph-explorer/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
// GraphExplorerCommand is the entrypoint for the graph-explorer command.
func GraphExplorerCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "graph-explorer",
Usage: "Start graph-explorer server",
Category: "Extensions",
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
if cfg.Commons != nil {
cfg.Graph.Commons = cfg.Commons
}
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.GraphExplorer)
return handleOriginalAction(c, origCmd)
},
Subcommands: []*cli.Command{
command.PrintVersion(cfg.GraphExplorer),
},
}
}
func init() {
register.AddCommand(GraphExplorerCommand)
}

View File

@@ -16,7 +16,7 @@ func StorageAuthMachineCommand(cfg *config.Config) *cli.Command {
Name: "storage-auth-machine",
Usage: "Start storage auth-machine service",
Category: "Extensions",
//Flags: flagset.AuthBearerWithConfig(cfg.Storage),
//Flags: flagset.AuthMachineWithConfig(cfg.Storage),
Before: func(ctx *cli.Context) error {
return ParseStorageCommon(ctx, cfg)
},

View File

@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name)
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get ocs services from the registry: %v", err))
return err

View File

@@ -24,16 +24,16 @@ type CORS struct {
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
CORS CORS `ocisConfig:"cors"`
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
Namespace string `ocisConfig:"namespace"`
CORS CORS `ocisConfig:"cors"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Namespace string `ocisConfig:"namespace"`
Version string `ocisConfig:"version"`
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -98,8 +98,9 @@ func DefaultConfig() *Config {
Zpages: false,
},
HTTP: HTTP{
Addr: "127.0.0.1:9110",
Root: "/ocs",
Addr: "127.0.0.1:9110",
Root: "/ocs",
Namespace: "com.owncloud.web",
CORS: CORS{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
@@ -107,6 +108,9 @@ func DefaultConfig() *Config {
AllowCredentials: true,
},
},
Service: Service{
Name: "ocs",
},
Tracing: Tracing{
Enabled: false,
Type: "jaeger",
@@ -117,10 +121,6 @@ func DefaultConfig() *Config {
TokenManager: TokenManager{
JWTSecret: "Pive-Fumkiu4",
},
Service: Service{
Name: "ocs",
Namespace: "com.owncloud.web",
},
AccountBackend: "accounts",
Reva: Reva{Address: "127.0.0.1:9142"},
StorageUsersDriver: "ocis",

View File

@@ -84,11 +84,11 @@ func structMappings(cfg *Config) []shared.EnvBinding {
Destination: &cfg.HTTP.Addr,
},
{
EnvVars: []string{"OCS_NAMESPACE"},
Destination: &cfg.Service.Namespace,
EnvVars: []string{"OCS_HTTP_NAMESPACE"},
Destination: &cfg.HTTP.Namespace,
},
{
EnvVars: []string{"OCS_NAME"},
EnvVars: []string{"OCS_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
{

View File

@@ -18,7 +18,7 @@ func Server(opts ...Option) (http.Service, error) {
http.Logger(options.Logger),
http.Name(options.Config.Service.Name),
http.Version(options.Config.Service.Version),
http.Namespace(options.Config.Service.Namespace),
http.Namespace(options.Config.HTTP.Namespace),
http.Address(options.Config.HTTP.Addr),
http.Context(options.Context),
http.Flags(options.Flags...),

View File

@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name)
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get proxy services from the registry: %v", err))
return err

View File

@@ -26,18 +26,18 @@ type Debug struct {
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
TLSCert string `ocisConfig:"tls_cert"`
TLSKey string `ocisConfig:"tls_key"`
TLS bool `ocisConfig:"tls"`
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
Namespace string `ocisConfig:"namespace"`
TLSCert string `ocisConfig:"tls_cert"`
TLSKey string `ocisConfig:"tls_key"`
TLS bool `ocisConfig:"tls"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Namespace string `ocisConfig:"namespace"`
Version string `ocisConfig:"version"`
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -207,15 +207,15 @@ func DefaultConfig() *Config {
Token: "",
},
HTTP: HTTP{
Addr: "0.0.0.0:9200",
Root: "/",
TLSCert: path.Join(defaults.BaseDataPath(), "proxy", "server.crt"),
TLSKey: path.Join(defaults.BaseDataPath(), "proxy", "server.key"),
TLS: true,
Addr: "0.0.0.0:9200",
Root: "/",
Namespace: "com.owncloud.web",
TLSCert: path.Join(defaults.BaseDataPath(), "proxy", "server.crt"),
TLSKey: path.Join(defaults.BaseDataPath(), "proxy", "server.key"),
TLS: true,
},
Service: Service{
Name: "proxy",
Namespace: "com.owncloud.web",
Name: "proxy",
},
Tracing: Tracing{
Type: "jaeger",

View File

@@ -101,15 +101,9 @@ func structMappings(cfg *Config) []shared.EnvBinding {
EnvVars: []string{"PROXY_HTTP_ROOT"},
Destination: &cfg.HTTP.Root,
},
// Service
{
EnvVars: []string{"PROXY_SERVICE_NAMESPACE"},
Destination: &cfg.Service.Namespace,
},
{
EnvVars: []string{"PROXY_SERVICE_NAME"},
Destination: &cfg.Service.Name,
EnvVars: []string{"PROXY_HTTP_NAMESPACE"},
Destination: &cfg.HTTP.Namespace,
},
{
EnvVars: []string{"PROXY_TRANSPORT_TLS_CERT"},
@@ -123,6 +117,14 @@ func structMappings(cfg *Config) []shared.EnvBinding {
EnvVars: []string{"PROXY_TLS"},
Destination: &cfg.HTTP.TLS,
},
// Service
{
EnvVars: []string{"PROXY_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
// Other
{
EnvVars: []string{"OCIS_JWT_SECRET", "PROXY_JWT_SECRET"},
Destination: &cfg.TokenManager.JWTSecret,

View File

@@ -43,11 +43,11 @@ func Server(opts ...Option) (svc.Service, error) {
service := svc.NewService(
svc.Name(options.Config.Service.Name),
svc.Version(options.Config.Service.Version),
svc.TLSConfig(tlsConfig),
svc.Logger(options.Logger),
svc.Namespace(options.Config.Service.Namespace),
svc.Version(options.Config.Service.Version),
svc.Address(options.Config.HTTP.Addr),
svc.Namespace(options.Config.HTTP.Namespace),
svc.Context(options.Context),
svc.Flags(options.Flags...),
)

View File

@@ -36,7 +36,7 @@ type HTTP struct {
// GRPC defines the available grpc configuration.
type GRPC struct {
Addr string `ocisConfig:"grpc"`
Addr string `ocisConfig:"addr"`
Namespace string `ocisConfig:"namespace"`
}

View File

@@ -104,7 +104,7 @@ func structMappings(cfg *Config) []shared.EnvBinding {
Destination: &cfg.GRPC.Namespace,
},
{
EnvVars: []string{"SETTINGS_NAME"},
EnvVars: []string{"SETTINGS_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
{

View File

@@ -35,6 +35,7 @@ func Execute(cfg *config.Config) error {
AppProvider(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
AuthMachine(cfg),
Sharing(cfg),
StorageUsers(cfg),
StorageShares(cfg),

View File

@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name)
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get store services from the registry: %v", err))
return err

View File

@@ -18,15 +18,15 @@ type Debug struct {
// GRPC defines the available grpc configuration.
type GRPC struct {
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
Namespace string `ocisConfig:"namespace"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Namespace string `ocisConfig:"namespace"`
Version string `ocisConfig:"version"`
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -67,7 +67,11 @@ func DefaultConfig() *Config {
Zpages: false,
},
GRPC: GRPC{
Addr: "127.0.0.1:9460",
Addr: "127.0.0.1:9460",
Namespace: "com.owncloud.api",
},
Service: Service{
Name: "store",
},
Tracing: Tracing{
Enabled: false,
@@ -77,10 +81,6 @@ func DefaultConfig() *Config {
Service: "store",
},
Datapath: path.Join(defaults.BaseDataPath(), "store"),
Service: Service{
Name: "store",
Namespace: "com.owncloud.api",
},
}
}

View File

@@ -66,14 +66,14 @@ func structMappings(cfg *Config) []shared.EnvBinding {
},
{
EnvVars: []string{"STORE_GRPC_NAMESPACE"},
Destination: &cfg.Service.Namespace,
Destination: &cfg.GRPC.Namespace,
},
{
EnvVars: []string{"STORE_GRPC_ADDR"},
Destination: &cfg.GRPC.Addr,
},
{
EnvVars: []string{"STORE_NAME"},
EnvVars: []string{"STORE_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
{

View File

@@ -11,7 +11,7 @@ func Server(opts ...Option) grpc.Service {
options := newOptions(opts...)
service := grpc.NewService(
grpc.Namespace(options.Config.Service.Namespace),
grpc.Namespace(options.Config.GRPC.Namespace),
grpc.Name(options.Config.Service.Name),
grpc.Version(options.Config.Service.Version),
grpc.Context(options.Context),

View File

@@ -49,7 +49,7 @@ func New(opts ...Option) (s *Service, err error) {
indexMapping.DefaultAnalyzer = keyword.Name
s = &Service{
id: cfg.Service.Namespace + "." + cfg.Service.Name,
id: cfg.GRPC.Namespace + "." + cfg.Service.Name,
log: logger,
Config: cfg,
}

View File

@@ -30,7 +30,7 @@ func Execute(cfg *config.Config) error {
},
Before: func(c *cli.Context) error {
cfg.Server.Version = version.String
cfg.Service.Version = version.String
return nil
},

View File

@@ -43,15 +43,15 @@ func Server(cfg *config.Config) *cli.Command {
defer cancel()
metrics.BuildInfo.WithLabelValues(cfg.Server.Version).Set(1)
metrics.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
service := grpc.NewService(
grpc.Logger(logger),
grpc.Context(ctx),
grpc.Config(cfg),
grpc.Name(cfg.Server.Name),
grpc.Namespace(cfg.Server.Namespace),
grpc.Address(cfg.Server.Address),
grpc.Name(cfg.Service.Name),
grpc.Namespace(cfg.GRPC.Namespace),
grpc.Address(cfg.GRPC.Addr),
grpc.Metrics(metrics),
)

View File

@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Server.Namespace + "." + cfg.Server.Name)
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get thumbnails services from the registry: %v", err))
return err

View File

@@ -16,12 +16,16 @@ type Debug struct {
Zpages bool `ocisConfig:"zpages"`
}
// Server defines the available server configuration.
type Server struct {
Name string `ocisConfig:"name"`
// GRPC defines the available grpc configuration.
type GRPC struct {
Addr string `ocisConfig:"addr"`
Namespace string `ocisConfig:"namespace"`
Address string `ocisConfig:"address"`
Version string `ocisConfig:"version"`
}
// Service provides configuration options for the service
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -40,7 +44,8 @@ type Config struct {
File string `ocisConfig:"file"`
Log *shared.Log `ocisConfig:"log"`
Debug Debug `ocisConfig:"debug"`
Server Server `ocisConfig:"server"`
GRPC GRPC `ocisConfig:"grpc"`
Service Service `ocisConfig:"service"`
Tracing Tracing `ocisConfig:"tracing"`
Thumbnail Thumbnail `ocisConfig:"thumbnail"`
@@ -81,10 +86,12 @@ func DefaultConfig() *Config {
Pprof: false,
Zpages: false,
},
Server: Server{
Name: "thumbnails",
GRPC: GRPC{
Addr: "127.0.0.1:9185",
Namespace: "com.owncloud.api",
Address: "127.0.0.1:9185",
},
Service: Service{
Name: "thumbnails",
},
Tracing: Tracing{
Enabled: false,

View File

@@ -80,16 +80,16 @@ func structMappings(cfg *Config) []shared.EnvBinding {
Destination: &cfg.Debug.Zpages,
},
{
EnvVars: []string{"THUMBNAILS_GRPC_NAME"},
Destination: &cfg.Server.Name,
EnvVars: []string{"THUMBNAILS_SERVICE_NAME"},
Destination: &cfg.Service.Name,
},
{
EnvVars: []string{"THUMBNAILS_GRPC_ADDR"},
Destination: &cfg.Server.Address,
Destination: &cfg.GRPC.Addr,
},
{
EnvVars: []string{"THUMBNAILS_GRPC_NAMESPACE"},
Destination: &cfg.Server.Namespace,
Destination: &cfg.GRPC.Namespace,
},
{
EnvVars: []string{"THUMBNAILS_TXT_FONTMAP_FILE"},

View File

@@ -14,8 +14,8 @@ func Server(opts ...Option) (*http.Server, error) {
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Config.Server.Name),
debug.Version(options.Config.Server.Version),
debug.Name(options.Config.Service.Name),
debug.Version(options.Config.Service.Version),
debug.Address(options.Config.Debug.Addr),
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),

View File

@@ -22,7 +22,7 @@ func NewService(opts ...Option) grpc.Service {
grpc.Address(options.Address),
grpc.Context(options.Context),
grpc.Flags(options.Flags...),
grpc.Version(options.Config.Server.Version),
grpc.Version(options.Config.Service.Version),
)
tconf := options.Config.Thumbnail
gc, err := pool.GetGatewayServiceClient(tconf.RevaGateway)

View File

@@ -31,7 +31,8 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
logger.Fatal().Err(err).Msg("resolutions not configured correctly")
}
svc := Thumbnail{
serviceID: options.Config.Server.Namespace + "." + options.Config.Server.Name,
serviceID: options.Config.GRPC.Namespace + "." + options.Config.Service.Name,
webdavNamespace: options.Config.Thumbnail.WebdavNamespace,
manager: thumbnail.NewSimpleManager(
resolutions,
options.ThumbnailStorage,

View File

@@ -0,0 +1,47 @@
package command
import (
"fmt"
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/web/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get web services from the registry: %v", err))
return err
}
if len(services) == 0 {
fmt.Println("No running web service found.")
return nil
}
table := tw.NewWriter(os.Stdout)
table.SetHeader([]string{"Version", "Address", "Id"})
table.SetAutoFormatHeaders(false)
for _, s := range services {
for _, n := range s.Nodes {
table.Append([]string{s.Version, n.Address, n.Id})
}
}
table.Render()
return nil
},
}
}

View File

@@ -22,6 +22,12 @@ type HTTP struct {
CacheTTL int `ocisConfig:"cache_ttl"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool `ocisConfig:"enabled"`
@@ -92,6 +98,7 @@ type Config struct {
Log *shared.Log `ocisConfig:"log"`
Debug Debug `ocisConfig:"debug"`
HTTP HTTP `ocisConfig:"http"`
Service Service `ocisConfig:"service"`
Tracing Tracing `ocisConfig:"tracing"`
Asset Asset `ocisConfig:"asset"`
Web Web `ocisConfig:"web"`
@@ -119,6 +126,9 @@ func DefaultConfig() *Config {
Namespace: "com.owncloud.web",
CacheTTL: 604800, // 7 days
},
Service: Service{
Name: "web",
},
Tracing: Tracing{
Enabled: false,
Type: "jaeger",

View File

@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name)
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get webdav services from the registry: %v", err))
return err

View File

@@ -24,16 +24,16 @@ type CORS struct {
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
CORS CORS `ocisConfig:"cors"`
Addr string `ocisConfig:"addr"`
Root string `ocisConfig:"root"`
Namespace string `ocisConfig:"namespace"`
CORS CORS `ocisConfig:"cors"`
}
// Service defines the available service configuration.
type Service struct {
Name string `ocisConfig:"name"`
Namespace string `ocisConfig:"namespace"`
Version string `ocisConfig:"version"`
Name string `ocisConfig:"name"`
Version string `ocisConfig:"version"`
}
// Tracing defines the available tracing configuration.
@@ -77,8 +77,9 @@ func DefaultConfig() *Config {
Zpages: false,
},
HTTP: HTTP{
Addr: "127.0.0.1:9115",
Root: "/",
Addr: "127.0.0.1:9115",
Root: "/",
Namespace: "com.owncloud.web",
CORS: CORS{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
@@ -86,6 +87,9 @@ func DefaultConfig() *Config {
AllowCredentials: true,
},
},
Service: Service{
Name: "webdav",
},
Tracing: Tracing{
Enabled: false,
Type: "jaeger",
@@ -93,10 +97,6 @@ func DefaultConfig() *Config {
Collector: "",
Service: "webdav",
},
Service: Service{
Name: "webdav",
Namespace: "com.owncloud.web",
},
OcisPublicURL: "https://127.0.0.1:9200",
WebdavNamespace: "/users/{{.Id.OpaqueId}}",
RevaGateway: "127.0.0.1:9142",

View File

@@ -85,7 +85,7 @@ func structMappings(cfg *Config) []shared.EnvBinding {
},
{
EnvVars: []string{"WEBDAV_HTTP_NAMESPACE"},
Destination: &cfg.Service.Namespace,
Destination: &cfg.HTTP.Namespace,
},
{
EnvVars: []string{"WEBDAV_SERVICE_NAME"},

View File

@@ -15,7 +15,7 @@ func Server(opts ...Option) (http.Service, error) {
service := http.NewService(
http.Logger(options.Logger),
http.Namespace(options.Config.Service.Namespace),
http.Namespace(options.Config.HTTP.Namespace),
http.Name(options.Config.Service.Name),
http.Version(options.Config.Service.Version),
http.Address(options.Config.HTTP.Addr),