From 7abcf96ea84a384cd5b0d4bde2e2ed62f0ebe55e Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 17 Dec 2021 16:30:57 +0100 Subject: [PATCH] revert storage, remove tracing.service and bring back common --- accounts/pkg/command/root.go | 22 +- accounts/pkg/config/config.go | 6 +- accounts/pkg/config/defaultconfig.go | 5 - accounts/pkg/config/tracing.go | 1 - accounts/pkg/logging/logging.go | 2 +- accounts/pkg/service/v0/service.go | 6 +- accounts/pkg/tracing/tracing.go | 2 +- glauth/pkg/command/root.go | 22 +- glauth/pkg/config/config.go | 6 +- glauth/pkg/config/defaultconfig.go | 6 +- glauth/pkg/config/tracing.go | 1 - glauth/pkg/logging/logging.go | 2 +- glauth/pkg/tracing/tracing.go | 2 +- graph-explorer/pkg/command/root.go | 22 +- graph-explorer/pkg/config/config.go | 6 +- graph-explorer/pkg/config/defaultconfig.go | 2 +- graph-explorer/pkg/config/tracing.go | 1 - graph-explorer/pkg/logging/logging.go | 2 +- graph-explorer/pkg/tracing/tracing.go | 2 +- graph/pkg/command/root.go | 22 +- graph/pkg/config/config.go | 6 +- graph/pkg/config/defaultconfig.go | 7 +- graph/pkg/config/tracing.go | 1 - graph/pkg/logging/logging.go | 2 +- graph/pkg/tracing/tracing.go | 2 +- idp/pkg/command/root.go | 22 +- idp/pkg/config/config.go | 6 +- idp/pkg/config/defaultconfig.go | 2 +- idp/pkg/config/tracing.go | 1 - idp/pkg/logging/logging.go | 2 +- idp/pkg/tracing/tracing.go | 2 +- ocis-pkg/config/config.go | 41 +- ocis-pkg/log/log.go | 2 +- ocis-pkg/shared/shared_types.go | 9 + ocis/pkg/command/accounts.go | 6 +- ocis/pkg/command/glauth.go | 6 +- ocis/pkg/command/graph.go | 6 +- ocis/pkg/command/graphexplorer.go | 6 +- ocis/pkg/command/idp.go | 6 +- ocis/pkg/command/ocs.go | 6 +- ocis/pkg/command/proxy.go | 6 +- ocis/pkg/command/settings.go | 6 +- ocis/pkg/command/thumbnails.go | 6 +- ocis/pkg/command/util.go | 21 +- ocis/pkg/command/web.go | 6 +- ocis/pkg/command/webdav.go | 6 +- ocis/pkg/runtime/service/service.go | 6 +- ocs/pkg/command/root.go | 22 +- ocs/pkg/config/config.go | 6 +- ocs/pkg/config/defaultconfig.go | 1 - ocs/pkg/config/tracing.go | 1 - ocs/pkg/logging/logging.go | 2 +- ocs/pkg/tracing/tracing.go | 2 +- proxy/pkg/command/root.go | 22 +- proxy/pkg/config/config.go | 10 +- proxy/pkg/config/defaultconfig.go | 2 +- proxy/pkg/config/tracing.go | 1 - proxy/pkg/logging/logging.go | 2 +- proxy/pkg/tracing/tracing.go | 2 +- settings/pkg/command/root.go | 22 +- settings/pkg/config/config.go | 7 +- settings/pkg/config/defaultconfig.go | 1 - settings/pkg/config/tracing.go | 1 - settings/pkg/logging/logging.go | 2 +- settings/pkg/tracing/tracing.go | 2 +- storage/pkg/command/appprovider.go | 5 +- storage/pkg/command/authbasic.go | 5 +- storage/pkg/command/authbearer.go | 5 +- storage/pkg/command/authmachine.go | 5 +- storage/pkg/command/frontend.go | 5 +- storage/pkg/command/gateway.go | 26 +- storage/pkg/command/groups.go | 5 +- storage/pkg/command/health.go | 3 +- storage/pkg/command/root.go | 17 +- storage/pkg/command/sharing.go | 5 +- storage/pkg/command/storagehome.go | 5 +- storage/pkg/command/storagemetadata.go | 5 +- storage/pkg/command/storagepubliclink.go | 5 +- storage/pkg/command/storageusers.go | 5 +- storage/pkg/command/users.go | 5 +- storage/pkg/config/config.go | 488 ++++++++++++++++++++- storage/pkg/config/debug.go | 9 - storage/pkg/config/defaultconfig.go | 443 ------------------- storage/pkg/config/grpc.go | 7 - storage/pkg/config/http.go | 18 - storage/pkg/config/log.go | 9 - storage/pkg/config/reva.go | 6 - storage/pkg/config/service.go | 7 - storage/pkg/config/tracing.go | 10 - storage/pkg/logging/logging.go | 17 - store/pkg/command/root.go | 22 +- store/pkg/config/config.go | 6 +- store/pkg/config/defaultconfig.go | 1 - store/pkg/config/tracing.go | 1 - store/pkg/logging/logging.go | 2 +- store/pkg/tracing/tracing.go | 2 +- thumbnails/pkg/command/root.go | 22 +- thumbnails/pkg/config/config.go | 6 +- thumbnails/pkg/config/defaultconfig.go | 1 - thumbnails/pkg/config/tracing.go | 1 - thumbnails/pkg/logging/logging.go | 2 +- thumbnails/pkg/tracing/tracing.go | 2 +- web/pkg/command/root.go | 22 +- web/pkg/config/config.go | 10 +- web/pkg/config/defaultconfig.go | 1 - web/pkg/config/tracing.go | 1 - web/pkg/logging/logging.go | 2 +- web/pkg/tracing/tracing.go | 2 +- webdav/pkg/command/root.go | 22 +- webdav/pkg/config/config.go | 6 +- webdav/pkg/config/defaultconfig.go | 1 - webdav/pkg/config/tracing.go | 1 - webdav/pkg/logging/logging.go | 2 +- webdav/pkg/tracing/tracing.go | 2 +- 114 files changed, 824 insertions(+), 882 deletions(-) delete mode 100644 storage/pkg/config/debug.go delete mode 100644 storage/pkg/config/defaultconfig.go delete mode 100644 storage/pkg/config/grpc.go delete mode 100644 storage/pkg/config/http.go delete mode 100644 storage/pkg/config/log.go delete mode 100644 storage/pkg/config/reva.go delete mode 100644 storage/pkg/config/service.go delete mode 100644 storage/pkg/config/tracing.go delete mode 100644 storage/pkg/logging/logging.go diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index 5854e0f60..366abad0f 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -67,16 +67,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -99,7 +99,7 @@ type SutureService struct { // NewSutureService creates a new accounts.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Accounts.Commons = cfg.Commons + cfg.Accounts.Commons = cfg.Commons return SutureService{ cfg: cfg.Accounts, } diff --git a/accounts/pkg/config/config.go b/accounts/pkg/config/config.go index e10f6a932..eb07e2ca5 100644 --- a/accounts/pkg/config/config.go +++ b/accounts/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/accounts/pkg/config/defaultconfig.go b/accounts/pkg/config/defaultconfig.go index 8e7caa101..5b027a545 100644 --- a/accounts/pkg/config/defaultconfig.go +++ b/accounts/pkg/config/defaultconfig.go @@ -8,7 +8,6 @@ import ( func DefaultConfig() *Config { return &Config{ - HTTP: HTTP{ Addr: "127.0.0.1:9181", Namespace: "com.owncloud.web", @@ -60,9 +59,5 @@ func DefaultConfig() *Config { UID: 0, GID: 0, }, - Tracing: Tracing{ - Type: "jaeger", - Service: "accounts", - }, } } diff --git a/accounts/pkg/config/tracing.go b/accounts/pkg/config/tracing.go index 3547373fb..fc673f824 100644 --- a/accounts/pkg/config/tracing.go +++ b/accounts/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;ACCOUNTS_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;ACCOUNTS_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;ACCOUNTS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"ACCOUNTS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/accounts/pkg/logging/logging.go b/accounts/pkg/logging/logging.go index 9b09b128e..4836eaec4 100644 --- a/accounts/pkg/logging/logging.go +++ b/accounts/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/accounts/pkg/service/v0/service.go b/accounts/pkg/service/v0/service.go index 957f5a50c..18703e805 100644 --- a/accounts/pkg/service/v0/service.go +++ b/accounts/pkg/service/v0/service.go @@ -109,9 +109,9 @@ func (s Service) buildIndex() (*indexer.Indexer, error) { func configFromSvc(cfg *config.Config) (*idxcfg.Config, error) { c := idxcfg.New() - //if cfg.Log == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil { + cfg.Log = &config.Log{} + } defer func(cfg *config.Config) { l := log.NewLogger(log.Color(cfg.Log.Color), log.Pretty(cfg.Log.Pretty), log.Level(cfg.Log.Level)) diff --git a/accounts/pkg/tracing/tracing.go b/accounts/pkg/tracing/tracing.go index 4da38009f..5f9bd3b65 100644 --- a/accounts/pkg/tracing/tracing.go +++ b/accounts/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "accounts", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/glauth/pkg/command/root.go b/glauth/pkg/command/root.go index b7b5fef7c..3b16d07a2 100644 --- a/glauth/pkg/command/root.go +++ b/glauth/pkg/command/root.go @@ -59,16 +59,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -91,7 +91,7 @@ type SutureService struct { // NewSutureService creates a new glauth.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.GLAuth.Commons = cfg.Commons + cfg.GLAuth.Commons = cfg.Commons return SutureService{ cfg: cfg.GLAuth, } diff --git a/glauth/pkg/config/config.go b/glauth/pkg/config/config.go index c13d732ea..6292cfc35 100644 --- a/glauth/pkg/config/config.go +++ b/glauth/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` Ldap Ldap `ocisConfig:"ldap"` diff --git a/glauth/pkg/config/defaultconfig.go b/glauth/pkg/config/defaultconfig.go index 23c12f844..becff0bb9 100644 --- a/glauth/pkg/config/defaultconfig.go +++ b/glauth/pkg/config/defaultconfig.go @@ -12,8 +12,10 @@ func DefaultConfig() *Config { Addr: "127.0.0.1:9129", }, Tracing: Tracing{ - Type: "jaeger", - Service: "glauth", + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", }, Service: Service{ Name: "glauth", diff --git a/glauth/pkg/config/tracing.go b/glauth/pkg/config/tracing.go index 3caca2705..52733d097 100644 --- a/glauth/pkg/config/tracing.go +++ b/glauth/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GLAUTH_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GLAUTH_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GLAUTH_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"GLAUTH_TRACING_SERVICE"` // TODO: } diff --git a/glauth/pkg/logging/logging.go b/glauth/pkg/logging/logging.go index 2dd2f1cd4..5282014a6 100644 --- a/glauth/pkg/logging/logging.go +++ b/glauth/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/glauth/pkg/tracing/tracing.go b/glauth/pkg/tracing/tracing.go index a02161687..734fd1d52 100644 --- a/glauth/pkg/tracing/tracing.go +++ b/glauth/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "glauth", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/graph-explorer/pkg/command/root.go b/graph-explorer/pkg/command/root.go index 621958d00..f99e3eaf3 100644 --- a/graph-explorer/pkg/command/root.go +++ b/graph-explorer/pkg/command/root.go @@ -56,17 +56,17 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { return err } - // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + // provide with defaults for shared logging, since we need a valid destination address for BindEnv. + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} diff --git a/graph-explorer/pkg/config/config.go b/graph-explorer/pkg/config/config.go index 9e11dd8e7..ea0577b0f 100644 --- a/graph-explorer/pkg/config/config.go +++ b/graph-explorer/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/graph-explorer/pkg/config/defaultconfig.go b/graph-explorer/pkg/config/defaultconfig.go index b44927243..7ea490819 100644 --- a/graph-explorer/pkg/config/defaultconfig.go +++ b/graph-explorer/pkg/config/defaultconfig.go @@ -17,10 +17,10 @@ func DefaultConfig() *Config { Name: "graph-explorer", }, Tracing: Tracing{ + Enabled: false, Type: "jaeger", Endpoint: "", Collector: "", - Service: "graph-explorer", }, GraphExplorer: GraphExplorer{ ClientID: "ocis-explorer.js", diff --git a/graph-explorer/pkg/config/tracing.go b/graph-explorer/pkg/config/tracing.go index cf4214eb4..db55ec8c5 100644 --- a/graph-explorer/pkg/config/tracing.go +++ b/graph-explorer/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GRAPH_EXPLORER_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_EXPLORER_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_EXPLORER_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"GRAPH_EXPLORER_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/graph-explorer/pkg/logging/logging.go b/graph-explorer/pkg/logging/logging.go index 8d3175cbf..24a2567a1 100644 --- a/graph-explorer/pkg/logging/logging.go +++ b/graph-explorer/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/graph-explorer/pkg/tracing/tracing.go b/graph-explorer/pkg/tracing/tracing.go index b7fe7a3f6..73b4c863c 100644 --- a/graph-explorer/pkg/tracing/tracing.go +++ b/graph-explorer/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "graph-explorer", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/graph/pkg/command/root.go b/graph/pkg/command/root.go index 7168eb16a..2492597ef 100644 --- a/graph/pkg/command/root.go +++ b/graph/pkg/command/root.go @@ -58,16 +58,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -90,7 +90,7 @@ type SutureService struct { // NewSutureService creates a new graph.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Graph.Commons = cfg.Commons + cfg.Graph.Commons = cfg.Commons return SutureService{ cfg: cfg.Graph, } diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index e2cc81c47..03ec948bb 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/graph/pkg/config/defaultconfig.go b/graph/pkg/config/defaultconfig.go index b5d09a9d2..5879b9487 100644 --- a/graph/pkg/config/defaultconfig.go +++ b/graph/pkg/config/defaultconfig.go @@ -15,9 +15,10 @@ func DefaultConfig() *Config { Name: "graph", }, Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Service: "graph", + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", }, Reva: Reva{ Address: "127.0.0.1:9142", diff --git a/graph/pkg/config/tracing.go b/graph/pkg/config/tracing.go index 457edb0fd..077a4819a 100644 --- a/graph/pkg/config/tracing.go +++ b/graph/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GRAPH_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"GRAPH_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/graph/pkg/logging/logging.go b/graph/pkg/logging/logging.go index 07f8b4450..daf29f40b 100644 --- a/graph/pkg/logging/logging.go +++ b/graph/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/graph/pkg/tracing/tracing.go b/graph/pkg/tracing/tracing.go index 5e67b08eb..3f2d775a5 100644 --- a/graph/pkg/tracing/tracing.go +++ b/graph/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "graph", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/idp/pkg/command/root.go b/idp/pkg/command/root.go index 77c740592..ec61ab260 100644 --- a/idp/pkg/command/root.go +++ b/idp/pkg/command/root.go @@ -60,16 +60,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -92,7 +92,7 @@ type SutureService struct { // NewSutureService creates a new idp.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.IDP.Commons = cfg.Commons + cfg.IDP.Commons = cfg.Commons return SutureService{ cfg: cfg.IDP, } diff --git a/idp/pkg/config/config.go b/idp/pkg/config/config.go index cc1e3b538..426c34dd4 100644 --- a/idp/pkg/config/config.go +++ b/idp/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/idp/pkg/config/defaultconfig.go b/idp/pkg/config/defaultconfig.go index dbaa3ba57..21e59a339 100644 --- a/idp/pkg/config/defaultconfig.go +++ b/idp/pkg/config/defaultconfig.go @@ -23,10 +23,10 @@ func DefaultConfig() *Config { Name: "idp", }, Tracing: Tracing{ + Enabled: false, Type: "jaeger", Endpoint: "", Collector: "", - Service: "idp", }, Asset: Asset{}, IDP: Settings{ diff --git a/idp/pkg/config/tracing.go b/idp/pkg/config/tracing.go index 8cb1d9db6..c149f9da1 100644 --- a/idp/pkg/config/tracing.go +++ b/idp/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;IDP_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;IDP_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;IDP_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"IDP_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/idp/pkg/logging/logging.go b/idp/pkg/logging/logging.go index cbcc64833..97eb83fcd 100644 --- a/idp/pkg/logging/logging.go +++ b/idp/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/idp/pkg/tracing/tracing.go b/idp/pkg/tracing/tracing.go index eb116d6ce..756b6210c 100644 --- a/idp/pkg/tracing/tracing.go +++ b/idp/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "idp", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index 40436f6fa..bdd6cd549 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -24,7 +24,6 @@ type Tracing struct { Type string `ocisConfig:"type"` Endpoint string `ocisConfig:"endpoint"` Collector string `ocisConfig:"collector"` - Service string `ocisConfig:"service"` } // TokenManager is the config for using the reva token manager @@ -42,28 +41,6 @@ const ( type Mode int -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"ACCOUNTS_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"ACCOUNTS_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"ACCOUNTS_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"ACCOUNTS_DEBUG_ZPAGES"` -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE"` -} - // Runtime configures the oCIS runtime when running in supervised mode. type Runtime struct { Port string `ocisConfig:"port"` @@ -75,11 +52,8 @@ type Runtime struct { type Config struct { *shared.Commons `ocisConfig:"shared"` - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` + Tracing shared.Tracing `ocisConfig:"tracing"` + Log shared.Log `ocisConfig:"log"` Mode Mode // DEPRECATED File string @@ -106,13 +80,6 @@ type Config struct { func DefaultConfig() *Config { return &Config{ - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "ocis", - }, TokenManager: TokenManager{ JWTSecret: "Pive-Fumkiu4", }, @@ -189,10 +156,6 @@ func structMappings(cfg *Config) []shared.EnvBinding { EnvVars: []string{"OCIS_TRACING_COLLECTOR"}, Destination: &cfg.Tracing.Collector, }, - { - EnvVars: []string{"OCIS_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, { EnvVars: []string{"OCIS_JWT_SECRET"}, Destination: &cfg.TokenManager.JWTSecret, diff --git a/ocis-pkg/log/log.go b/ocis-pkg/log/log.go index 42ae508f8..f2ab74e12 100644 --- a/ocis-pkg/log/log.go +++ b/ocis-pkg/log/log.go @@ -21,7 +21,7 @@ type Logger struct { } // LoggerFromConfig initializes a service-specific logger instance. -func LoggerFromConfig(name string, cfg shared.Log) Logger { +func LoggerFromConfig(name string, cfg *shared.Log) Logger { return NewLogger( Name(name), Level(cfg.Level), diff --git a/ocis-pkg/shared/shared_types.go b/ocis-pkg/shared/shared_types.go index fc655e73d..25aa96269 100644 --- a/ocis-pkg/shared/shared_types.go +++ b/ocis-pkg/shared/shared_types.go @@ -16,9 +16,18 @@ type Log struct { File string `mapstructure:"file"` } +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled"` + Type string `ocisConfig:"type"` + Endpoint string `ocisConfig:"endpoint"` + Collector string `ocisConfig:"collector"` +} + // Commons holds configuration that are common to all extensions. Each extension can then decide whether // to overwrite its values. type Commons struct { *Log `mapstructure:"log"` + Tracing `mapstrucuture:"log"` OcisURL string `mapstructure:"ocis_url"` } diff --git a/ocis/pkg/command/accounts.go b/ocis/pkg/command/accounts.go index cb3bdc620..1c3db45c0 100644 --- a/ocis/pkg/command/accounts.go +++ b/ocis/pkg/command/accounts.go @@ -26,9 +26,9 @@ func AccountsCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Accounts.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Accounts.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/glauth.go b/ocis/pkg/command/glauth.go index d6adfa74a..c6baacfde 100644 --- a/ocis/pkg/command/glauth.go +++ b/ocis/pkg/command/glauth.go @@ -18,9 +18,9 @@ func GLAuthCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.GLAuth.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.GLAuth.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/graph.go b/ocis/pkg/command/graph.go index 162416d24..ecc94826c 100644 --- a/ocis/pkg/command/graph.go +++ b/ocis/pkg/command/graph.go @@ -18,9 +18,9 @@ func GraphCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Graph.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Graph.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/graphexplorer.go b/ocis/pkg/command/graphexplorer.go index ede47b9c8..7833206b9 100644 --- a/ocis/pkg/command/graphexplorer.go +++ b/ocis/pkg/command/graphexplorer.go @@ -18,9 +18,9 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Graph.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Graph.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go index 399b9339a..7b35c15ba 100644 --- a/ocis/pkg/command/idp.go +++ b/ocis/pkg/command/idp.go @@ -21,9 +21,9 @@ func IDPCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.IDP.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.IDP.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index 40c79fd32..243c27696 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -18,9 +18,9 @@ func OCSCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.OCS.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.OCS.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go index 6b3dc5b95..7458a80d6 100644 --- a/ocis/pkg/command/proxy.go +++ b/ocis/pkg/command/proxy.go @@ -21,9 +21,9 @@ func ProxyCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Proxy.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Proxy.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index 7980f9d0b..90bdafc30 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -21,9 +21,9 @@ func SettingsCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Settings.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Settings.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go index 01cdae6fc..f671358e7 100644 --- a/ocis/pkg/command/thumbnails.go +++ b/ocis/pkg/command/thumbnails.go @@ -21,9 +21,9 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Thumbnails.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Thumbnails.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/util.go b/ocis/pkg/command/util.go index c49fb2c12..a2e9b1abc 100644 --- a/ocis/pkg/command/util.go +++ b/ocis/pkg/command/util.go @@ -2,6 +2,7 @@ package command import ( "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/owncloud/ocis/ocis-pkg/shared" "github.com/urfave/cli/v2" ) @@ -10,16 +11,16 @@ func ParseStorageCommon(ctx *cli.Context, cfg *config.Config) error { return err } - //if cfg.Storage.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Storage.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Storage.Log == nil && cfg.Commons == nil { - // cfg.Storage.Log = &shared.Log{} - //} + if cfg.Storage.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Storage.Log = &shared.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Storage.Log == nil && cfg.Commons == nil { + cfg.Storage.Log = &shared.Log{} + } return nil } diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go index 5d63587c2..c3f2df2ea 100644 --- a/ocis/pkg/command/web.go +++ b/ocis/pkg/command/web.go @@ -18,9 +18,9 @@ func WebCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.Web.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.Web.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index ad95e8498..31cb2c528 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -22,9 +22,9 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { return err } - //if cfg.Commons != nil { - // cfg.WebDAV.Commons = cfg.Commons - //} + if cfg.Commons != nil { + cfg.WebDAV.Commons = cfg.Commons + } return nil }, diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 603183284..2def6c6f5 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -164,9 +164,9 @@ func Start(o ...Option) error { } } - //if s.cfg.Storage.Log == nil { - // s.cfg.Storage.Log = &shared.Log{} - //} + if s.cfg.Storage.Log == nil { + s.cfg.Storage.Log = &shared.Log{} + } s.cfg.Storage.Log.Color = s.cfg.Commons.Color s.cfg.Storage.Log.Level = s.cfg.Commons.Level diff --git a/ocs/pkg/command/root.go b/ocs/pkg/command/root.go index 01d18eb58..141bc1bda 100644 --- a/ocs/pkg/command/root.go +++ b/ocs/pkg/command/root.go @@ -61,16 +61,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -93,7 +93,7 @@ type SutureService struct { // NewSutureService creates a new ocs.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.OCS.Commons = cfg.Commons + cfg.OCS.Commons = cfg.Commons return SutureService{ cfg: cfg.OCS, } diff --git a/ocs/pkg/config/config.go b/ocs/pkg/config/config.go index b8554f887..0171ef7a0 100644 --- a/ocs/pkg/config/config.go +++ b/ocs/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/ocs/pkg/config/defaultconfig.go b/ocs/pkg/config/defaultconfig.go index 428b254a4..59cbfb8f1 100644 --- a/ocs/pkg/config/defaultconfig.go +++ b/ocs/pkg/config/defaultconfig.go @@ -27,7 +27,6 @@ func DefaultConfig() *Config { Type: "jaeger", Endpoint: "", Collector: "", - Service: "ocs", }, TokenManager: TokenManager{ JWTSecret: "Pive-Fumkiu4", diff --git a/ocs/pkg/config/tracing.go b/ocs/pkg/config/tracing.go index f627ec382..310462e90 100644 --- a/ocs/pkg/config/tracing.go +++ b/ocs/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;OCS_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;OCS_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;OCS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"OCS_TRACING_SERVICE"` } diff --git a/ocs/pkg/logging/logging.go b/ocs/pkg/logging/logging.go index 355ab6c0d..80350b0d0 100644 --- a/ocs/pkg/logging/logging.go +++ b/ocs/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/ocs/pkg/tracing/tracing.go b/ocs/pkg/tracing/tracing.go index d79ef622f..bd4873036 100644 --- a/ocs/pkg/tracing/tracing.go +++ b/ocs/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "ocs", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/proxy/pkg/command/root.go b/proxy/pkg/command/root.go index 9801fe65a..1d771d9cb 100644 --- a/proxy/pkg/command/root.go +++ b/proxy/pkg/command/root.go @@ -60,16 +60,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -92,7 +92,7 @@ type SutureService struct { // NewSutureService creates a new proxy.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Proxy.Commons = cfg.Commons + cfg.Proxy.Commons = cfg.Commons return SutureService{ cfg: cfg.Proxy, } diff --git a/proxy/pkg/config/config.go b/proxy/pkg/config/config.go index 4408550b7..048928e6a 100644 --- a/proxy/pkg/config/config.go +++ b/proxy/pkg/config/config.go @@ -1,13 +1,19 @@ package config -import "context" +import ( + "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" +) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/proxy/pkg/config/defaultconfig.go b/proxy/pkg/config/defaultconfig.go index ea1940a57..b41014013 100644 --- a/proxy/pkg/config/defaultconfig.go +++ b/proxy/pkg/config/defaultconfig.go @@ -24,10 +24,10 @@ func DefaultConfig() *Config { Name: "proxy", }, Tracing: Tracing{ + Enabled: false, Type: "jaeger", Endpoint: "", Collector: "", - Service: "proxy", }, OIDC: OIDC{ Issuer: "https://localhost:9200", diff --git a/proxy/pkg/config/tracing.go b/proxy/pkg/config/tracing.go index 914726759..79429ee5c 100644 --- a/proxy/pkg/config/tracing.go +++ b/proxy/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;PROXY_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;PROXY_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;PROXY_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"PROXY_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/proxy/pkg/logging/logging.go b/proxy/pkg/logging/logging.go index b2626eb74..dfaeabd24 100644 --- a/proxy/pkg/logging/logging.go +++ b/proxy/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/proxy/pkg/tracing/tracing.go b/proxy/pkg/tracing/tracing.go index e3b3aa50c..5ab072223 100644 --- a/proxy/pkg/tracing/tracing.go +++ b/proxy/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "proxy", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/settings/pkg/command/root.go b/settings/pkg/command/root.go index 24d5b3619..fb7c930cb 100644 --- a/settings/pkg/command/root.go +++ b/settings/pkg/command/root.go @@ -61,16 +61,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -93,7 +93,7 @@ type SutureService struct { // NewSutureService creates a new settings.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Settings.Commons = cfg.Commons + cfg.Settings.Commons = cfg.Commons return SutureService{ cfg: cfg.Settings, } diff --git a/settings/pkg/config/config.go b/settings/pkg/config/config.go index 18284a56c..052a07360 100644 --- a/settings/pkg/config/config.go +++ b/settings/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` @@ -27,4 +31,3 @@ type Config struct { type Asset struct { Path string `ocisConfig:"path" env:"SETTINGS_ASSET_PATH"` } - diff --git a/settings/pkg/config/defaultconfig.go b/settings/pkg/config/defaultconfig.go index 100c1e80f..a667c0c25 100644 --- a/settings/pkg/config/defaultconfig.go +++ b/settings/pkg/config/defaultconfig.go @@ -38,7 +38,6 @@ func DefaultConfig() *Config { Type: "jaeger", Endpoint: "", Collector: "", - Service: "settings", }, DataPath: path.Join(defaults.BaseDataPath(), "settings"), Asset: Asset{ diff --git a/settings/pkg/config/tracing.go b/settings/pkg/config/tracing.go index 543298663..7197a69f3 100644 --- a/settings/pkg/config/tracing.go +++ b/settings/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;SETTINGS_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;SETTINGS_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;SETTINGS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"SETTINGS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/settings/pkg/logging/logging.go b/settings/pkg/logging/logging.go index 147d07e7c..aba0cbe82 100644 --- a/settings/pkg/logging/logging.go +++ b/settings/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/settings/pkg/tracing/tracing.go b/settings/pkg/tracing/tracing.go index 09d85008b..620d261cc 100644 --- a/settings/pkg/tracing/tracing.go +++ b/settings/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "settings", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/storage/pkg/command/appprovider.go b/storage/pkg/command/appprovider.go index 86ccac4f0..80c8c523b 100644 --- a/storage/pkg/command/appprovider.go +++ b/storage/pkg/command/appprovider.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -28,7 +27,7 @@ func AppProvider(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-app-provider") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -129,7 +128,7 @@ type AppProviderSutureService struct { // NewAppProvider creates a new store.AppProviderSutureService func NewAppProvider(cfg *ociscfg.Config) suture.Service { - ////cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return AppProviderSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index 1d57341f1..10268754a 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -13,7 +13,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -29,7 +28,7 @@ func AuthBasic(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-auth-basic") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -148,7 +147,7 @@ type AuthBasicSutureService struct { // NewAuthBasicSutureService creates a new store.AuthBasicSutureService func NewAuthBasic(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return AuthBasicSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index 7c2e23a84..af60ccbda 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -28,7 +27,7 @@ func AuthBearer(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-auth-bearer") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -124,7 +123,7 @@ type AuthBearerSutureService struct { // NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService func NewAuthBearer(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return AuthBearerSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authmachine.go b/storage/pkg/command/authmachine.go index 9bce040bf..eaaa97cbf 100644 --- a/storage/pkg/command/authmachine.go +++ b/storage/pkg/command/authmachine.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -28,7 +27,7 @@ func AuthMachine(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-auth-machine") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -120,7 +119,7 @@ type AuthMachineSutureService struct { // NewAuthMachineSutureService creates a new gateway.AuthMachineSutureService func NewAuthMachine(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return AuthMachineSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index c3394f84b..f3b3d9f6f 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -16,7 +16,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/conversions" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -35,7 +34,7 @@ func Frontend(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-frontend") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) @@ -339,7 +338,7 @@ type FrontendSutureService struct { // NewFrontend creates a new frontend.FrontendSutureService func NewFrontend(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return FrontendSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index a2128c77b..63f158da1 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -15,10 +15,10 @@ import ( "github.com/oklog/run" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/ocis-pkg/shared" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/service/external" "github.com/owncloud/ocis/storage/pkg/tracing" @@ -43,7 +43,7 @@ func Gateway(cfg *config.Config) *cli.Command { return nil }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -352,7 +352,7 @@ type GatewaySutureService struct { // NewGatewaySutureService creates a new gateway.GatewaySutureService func NewGateway(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return GatewaySutureService{ cfg: cfg.Storage, } @@ -388,16 +388,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config, storageExtension string) er } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &shared.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &shared.Log{} + } // load all env variables relevant to the config in the current context. conf.LoadOSEnv(config.GetEnv(cfg), false) diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index 0d37c4149..043c96fdc 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -13,7 +13,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -29,7 +28,7 @@ func Groups(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-groups") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -162,7 +161,7 @@ type GroupSutureService struct { // NewGroupProviderSutureService creates a new storage.GroupProvider func NewGroupProvider(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return GroupSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/health.go b/storage/pkg/command/health.go index 244ce713d..a3c3791a9 100644 --- a/storage/pkg/command/health.go +++ b/storage/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/urfave/cli/v2" ) @@ -18,7 +17,7 @@ func Health(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) resp, err := http.Get( fmt.Sprintf( diff --git a/storage/pkg/command/root.go b/storage/pkg/command/root.go index ee8aa9f4f..4ac235e8c 100644 --- a/storage/pkg/command/root.go +++ b/storage/pkg/command/root.go @@ -3,6 +3,7 @@ package command import ( "os" + "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/config" "github.com/urfave/cli/v2" @@ -22,10 +23,8 @@ func Execute(cfg *config.Config) error { Email: "support@owncloud.com", }, }, - Before: func(c *cli.Context) error { - cfg.Service.Version = version.String - return ParseConfig(c, cfg, "_") + return ParseConfig(c, cfg, "storage") }, Commands: []*cli.Command{ @@ -36,7 +35,6 @@ func Execute(cfg *config.Config) error { AppProvider(cfg), AuthBasic(cfg), AuthBearer(cfg), - AuthMachine(cfg), Sharing(cfg), StorageHome(cfg), StorageUsers(cfg), @@ -58,3 +56,14 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } + +// NewLogger initializes a service-specific logger instance. +func NewLogger(cfg *config.Config) log.Logger { + return log.NewLogger( + log.Name("storage"), + log.Level(cfg.Log.Level), + log.Pretty(cfg.Log.Pretty), + log.Color(cfg.Log.Color), + log.File(cfg.Log.File), + ) +} diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 7229b7f28..abace4d50 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -7,7 +7,6 @@ import ( "path" "path/filepath" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/sync" @@ -31,7 +30,7 @@ func Sharing(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-sharing") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) @@ -188,7 +187,7 @@ type SharingSutureService struct { // NewSharingSutureService creates a new store.SharingSutureService func NewSharing(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return SharingSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index c3a2a312a..bbeca4d70 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -7,7 +7,6 @@ import ( "path" "github.com/owncloud/ocis/ocis-pkg/sync" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" @@ -30,7 +29,7 @@ func StorageHome(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-home") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) @@ -147,7 +146,7 @@ type StorageHomeSutureService struct { // NewStorageHomeSutureService creates a new storage.StorageHomeSutureService func NewStorageHome(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return StorageHomeSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index 6ff7a2819..1c84313a3 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -7,7 +7,6 @@ import ( "path" "github.com/owncloud/ocis/ocis-pkg/sync" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" @@ -35,7 +34,7 @@ func StorageMetadata(cfg *config.Config) *cli.Command { }, Category: "Extensions", Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} @@ -167,7 +166,7 @@ type MetadataSutureService struct { // NewSutureService creates a new storagemetadata.SutureService func NewStorageMetadata(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return MetadataSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index f61b32a78..edd73c9ad 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -29,7 +28,7 @@ func StoragePublicLink(cfg *config.Config) *cli.Command { }, Category: "Extensions", Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) @@ -127,7 +126,7 @@ type StoragePublicLinkSutureService struct { // NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService func NewStoragePublicLink(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return StoragePublicLinkSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index 0d61415d1..7bb7aa6c0 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -13,7 +13,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/command/storagedrivers" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -29,7 +28,7 @@ func StorageUsers(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-userprovider") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) @@ -147,7 +146,7 @@ type StorageUsersSutureService struct { // NewStorageUsersSutureService creates a new storage.StorageUsersSutureService func NewStorageUsers(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return StorageUsersSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index 908865ae7..34aee1d7c 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -13,7 +13,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/logging" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -29,7 +28,7 @@ func Users(cfg *config.Config) *cli.Command { return ParseConfig(c, cfg, "storage-users") }, Action: func(c *cli.Context) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := NewLogger(cfg) tracing.Configure(cfg, logger) @@ -183,7 +182,7 @@ type UserProviderSutureService struct { // NewUserProviderSutureService creates a new storage.UserProvider func NewUserProvider(cfg *ociscfg.Config) suture.Service { - //cfg.Storage.Commons = cfg.Commons + cfg.Storage.Commons = cfg.Commons return UserProviderSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 35d544a98..6691edda4 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -2,21 +2,28 @@ package config import ( "context" + "os" + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" "github.com/owncloud/ocis/ocis-pkg/shared" ) -// Config combines all available configuration parts. -type Config struct { - Service Service +// Log defines the available logging configuration. +type Log struct { + Level string `ocisConfig:"level"` + Pretty bool `ocisConfig:"pretty"` + Color bool `ocisConfig:"color"` + File string `ocisConfig:"file"` +} - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - Reva Reva `ocisConfig:"reva"` - - Asset Asset `ocisConfig:"asset"` +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr"` + Token string `ocisConfig:"token"` + Pprof bool `ocisConfig:"pprof"` + Zpages bool `ocisConfig:"zpages"` } // Gateway defines the available gateway configuration. @@ -483,11 +490,472 @@ type Reva struct { DefaultUploadProtocol string `ocisConfig:"default_upload_protocol"` } +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled"` + Type string `ocisConfig:"type"` + Endpoint string `ocisConfig:"endpoint"` + Collector string `ocisConfig:"collector"` + Service string `ocisConfig:"service"` +} + // Asset defines the available asset configuration. type Asset struct { Path string `ocisConfig:"path"` } +// Config combines all available configuration parts. +type Config struct { + *shared.Commons + + File string `ocisConfig:"file"` + Log *shared.Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` + Reva Reva `ocisConfig:"reva"` + Tracing Tracing `ocisConfig:"tracing"` + Asset Asset `ocisConfig:"asset"` +} + +// New initializes a new configuration with or without defaults. +func New() *Config { + return &Config{} +} + +func DefaultConfig() *Config { + return &Config{ + // log is inherited + Debug: Debug{ + Addr: "127.0.0.1:9109", + }, + Reva: Reva{ + JWTSecret: "Pive-Fumkiu4", + SkipUserGroupsInToken: false, + TransferSecret: "replace-me-with-a-transfer-secret", + TransferExpires: 24 * 60 * 60, + OIDC: OIDC{ + Issuer: "https://localhost:9200", + Insecure: false, + IDClaim: "preferred_username", + }, + LDAP: LDAP{ + Hostname: "localhost", + Port: 9126, + CACert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"), + Insecure: false, + BaseDN: "dc=ocis,dc=test", + LoginFilter: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))", + UserFilter: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + UserAttributeFilter: "(&(objectclass=posixAccount)({{attr}}={{value}}))", + UserFindFilter: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + UserGroupFilter: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", + GroupFilter: "(&(objectclass=posixGroup)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + GroupAttributeFilter: "(&(objectclass=posixGroup)({{attr}}={{value}}))", + GroupFindFilter: "(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + GroupMemberFilter: "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))", + BindDN: "cn=reva,ou=sysusers,dc=ocis,dc=test", + BindPassword: "reva", + IDP: "https://localhost:9200", + UserSchema: LDAPUserSchema{ + UID: "ownclouduuid", + Mail: "mail", + DisplayName: "displayname", + CN: "cn", + UIDNumber: "uidnumber", + GIDNumber: "gidnumber", + }, + GroupSchema: LDAPGroupSchema{ + GID: "cn", + Mail: "mail", + DisplayName: "cn", + CN: "cn", + GIDNumber: "gidnumber", + }, + }, + UserGroupRest: UserGroupRest{ + RedisAddress: "localhost:6379", + }, + UserOwnCloudSQL: UserOwnCloudSQL{ + DBUsername: "owncloud", + DBPassword: "secret", + DBHost: "mysql", + DBPort: 3306, + DBName: "owncloud", + Idp: "https://localhost:9200", + Nobody: 90, + JoinUsername: false, + JoinOwnCloudUUID: false, + EnableMedialSearch: false, + }, + OCDav: OCDav{ + WebdavNamespace: "/home/", + DavFilesNamespace: "/users/", + }, + Archiver: Archiver{ + MaxNumFiles: 10000, + MaxSize: 1073741824, + ArchiverURL: "/archiver", + }, + UserStorage: StorageConfig{ + EOS: DriverEOS{ + DriverCommon: DriverCommon{ + Root: "/eos/dockertest/reva", + ShareFolder: "/Shares", + UserLayout: "{{substr 0 1 .Username}}/{{.Username}}", + }, + ShadowNamespace: "", // Defaults to path.Join(c.Namespace, ".shadow") + UploadsNamespace: "", // Defaults to path.Join(c.Namespace, ".uploads") + EosBinary: "/usr/bin/eos", + XrdcopyBinary: "/usr/bin/xrdcopy", + MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + CacheDirectory: os.TempDir(), + GatewaySVC: "127.0.0.1:9142", + }, + Local: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "local", "users"), + ShareFolder: "/Shares", + UserLayout: "{{.Username}}", + EnableHome: false, + }, + OwnCloud: DriverOwnCloud{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"), + ShareFolder: "/Shares", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"), + Redis: ":6379", + Scan: true, + }, + OwnCloudSQL: DriverOwnCloudSQL{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"), + ShareFolder: "/Shares", + UserLayout: "{{.Username}}", + EnableHome: false, + }, + UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"), + DBUsername: "owncloud", + DBPassword: "owncloud", + DBHost: "", + DBPort: 3306, + DBName: "owncloud", + }, + S3: DriverS3{ + DriverCommon: DriverCommon{}, + Region: "default", + AccessKey: "", + SecretKey: "", + Endpoint: "", + Bucket: "", + }, + S3NG: DriverS3NG{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "users"), + ShareFolder: "/Shares", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + Region: "default", + AccessKey: "", + SecretKey: "", + Endpoint: "", + Bucket: "", + }, + OCIS: DriverOCIS{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "users"), + ShareFolder: "/Shares", + UserLayout: "{{.Id.OpaqueId}}", + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + }, + }, + MetadataStorage: StorageConfig{ + EOS: DriverEOS{ + DriverCommon: DriverCommon{ + Root: "/eos/dockertest/reva", + ShareFolder: "/Shares", + UserLayout: "{{substr 0 1 .Username}}/{{.Username}}", + EnableHome: false, + }, + ShadowNamespace: "", + UploadsNamespace: "", + EosBinary: "/usr/bin/eos", + XrdcopyBinary: "/usr/bin/xrdcopy", + MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + GrpcURI: "", + SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + CacheDirectory: os.TempDir(), + EnableLogging: false, + ShowHiddenSysFiles: false, + ForceSingleUserMode: false, + UseKeytab: false, + SecProtocol: "", + Keytab: "", + SingleUsername: "", + GatewaySVC: "127.0.0.1:9142", + }, + Local: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "local", "metadata"), + }, + OwnCloud: DriverOwnCloud{}, + OwnCloudSQL: DriverOwnCloudSQL{}, + S3: DriverS3{ + DriverCommon: DriverCommon{}, + Region: "default", + }, + S3NG: DriverS3NG{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"), + ShareFolder: "", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + Region: "default", + AccessKey: "", + SecretKey: "", + Endpoint: "", + Bucket: "", + }, + OCIS: DriverOCIS{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"), + ShareFolder: "", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + }, + }, + Frontend: FrontendPort{ + Port: Port{ + MaxCPUs: "", + LogLevel: "", + GRPCNetwork: "", + GRPCAddr: "", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9140", + Protocol: "", + Endpoint: "", + DebugAddr: "127.0.0.1:9141", + Services: []string{"datagateway", "ocdav", "ocs", "appprovider"}, + Config: nil, + Context: nil, + Supervised: false, + }, + AppProviderInsecure: false, + AppProviderPrefix: "", + ArchiverInsecure: false, + ArchiverPrefix: "archiver", + DatagatewayPrefix: "data", + Favorites: false, + OCDavInsecure: false, + OCDavPrefix: "", + OCSPrefix: "ocs", + OCSSharePrefix: "/Shares", + OCSHomeNamespace: "/home", + PublicURL: "https://localhost:9200", + OCSCacheWarmupDriver: "", + OCSAdditionalInfoAttribute: "{{.Mail}}", + OCSResourceInfoCacheTTL: 0, + Middleware: Middleware{}, + }, + DataGateway: DataGatewayPort{ + Port: Port{}, + PublicURL: "", + }, + Gateway: Gateway{ + Port: Port{ + Endpoint: "127.0.0.1:9142", + DebugAddr: "127.0.0.1:9143", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9142", + }, + CommitShareToStorageGrant: true, + CommitShareToStorageRef: true, + DisableHomeCreationOnLogin: false, + ShareFolder: "Shares", + LinkGrants: "", + HomeMapping: "", + EtagCacheTTL: 0, + }, + StorageRegistry: StorageRegistry{ + Driver: "static", + HomeProvider: "/home", + JSON: "", + }, + AppRegistry: AppRegistry{ + Driver: "static", + MimetypesJSON: "", + }, + Users: Users{ + Port: Port{ + Endpoint: "localhost:9144", + DebugAddr: "127.0.0.1:9145", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9144", + Services: []string{"userprovider"}, + }, + Driver: "ldap", + UserGroupsCacheExpiration: 5, + }, + Groups: Groups{ + Port: Port{ + Endpoint: "localhost:9160", + DebugAddr: "127.0.0.1:9161", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9160", + Services: []string{"groupprovider"}, + }, + Driver: "ldap", + GroupMembersCacheExpiration: 5, + }, + AuthProvider: Users{ + Port: Port{}, + Driver: "ldap", + UserGroupsCacheExpiration: 0, + }, + AuthBasic: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9146", + DebugAddr: "127.0.0.1:9147", + Services: []string{"authprovider"}, + Endpoint: "localhost:9146", + }, + AuthBearer: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9148", + DebugAddr: "127.0.0.1:9149", + Services: []string{"authprovider"}, + Endpoint: "localhost:9148", + }, + AuthMachine: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9166", + DebugAddr: "127.0.0.1:9167", + Services: []string{"authprovider"}, + Endpoint: "localhost:9166", + }, + AuthMachineConfig: AuthMachineConfig{ + MachineAuthAPIKey: "change-me-please", + }, + Sharing: Sharing{ + Port: Port{ + Endpoint: "localhost:9150", + DebugAddr: "127.0.0.1:9151", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9150", + Services: []string{"usershareprovider", "publicshareprovider"}, + }, + UserDriver: "json", + UserJSONFile: path.Join(defaults.BaseDataPath(), "storage", "shares.json"), + UserSQLUsername: "", + UserSQLPassword: "", + UserSQLHost: "", + UserSQLPort: 1433, + UserSQLName: "", + PublicDriver: "json", + PublicJSONFile: path.Join(defaults.BaseDataPath(), "storage", "publicshares.json"), + PublicPasswordHashCost: 11, + PublicEnableExpiredSharesCleanup: true, + PublicJanitorRunInterval: 60, + UserStorageMountID: "", + }, + StorageHome: StoragePort{ + Port: Port{ + Endpoint: "localhost:9154", + DebugAddr: "127.0.0.1:9156", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9154", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9155", + }, + Driver: "ocis", + ReadOnly: false, + MountPath: "/home", + AlternativeID: "1284d238-aa92-42ce-bdc4-0b0000009154", + MountID: "1284d238-aa92-42ce-bdc4-0b0000009157", + DataServerURL: "http://localhost:9155/data", + HTTPPrefix: "data", + TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "home"), + }, + StorageUsers: StoragePort{ + Port: Port{ + Endpoint: "localhost:9157", + DebugAddr: "127.0.0.1:9159", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9157", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9158", + }, + MountPath: "/users", + MountID: "1284d238-aa92-42ce-bdc4-0b0000009157", + Driver: "ocis", + DataServerURL: "http://localhost:9158/data", + HTTPPrefix: "data", + TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "users"), + }, + StoragePublicLink: PublicStorage{ + StoragePort: StoragePort{ + Port: Port{ + Endpoint: "localhost:9178", + DebugAddr: "127.0.0.1:9179", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9178", + }, + MountPath: "/public", + MountID: "e1a73ede-549b-4226-abdf-40e69ca8230d", + }, + PublicShareProviderAddr: "", + UserProviderAddr: "", + }, + StorageMetadata: StoragePort{ + Port: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9215", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9216", + DebugAddr: "127.0.0.1:9217", + }, + Driver: "ocis", + ExposeDataServer: false, + DataServerURL: "http://localhost:9216/data", + TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "metadata"), + DataProvider: DataProvider{}, + }, + AppProvider: AppProvider{ + Port: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9164", + DebugAddr: "127.0.0.1:9165", + Endpoint: "localhost:9164", + Services: []string{"appprovider"}, + }, + ExternalAddr: "127.0.0.1:9164", + WopiDriver: WopiDriver{}, + AppsURL: "/app/list", + OpenURL: "/app/open", + NewURL: "/app/new", + }, + Configs: nil, + UploadMaxChunkSize: 1e+8, + UploadHTTPMethodOverride: "", + ChecksumSupportedTypes: []string{"sha1", "md5", "adler32"}, + ChecksumPreferredUploadType: "", + DefaultUploadProtocol: "tus", + }, + Tracing: Tracing{ + Service: "storage", + Type: "jaeger", + }, + Asset: Asset{}, + } +} + // StructMappings binds a set of environment variables to a destination on cfg. Iterating over this set and editing the // Destination value of a binding will alter the original value, as it is a pointer to its memory address. This lets // us propagate changes easier. diff --git a/storage/pkg/config/debug.go b/storage/pkg/config/debug.go deleted file mode 100644 index f9283a9b2..000000000 --- a/storage/pkg/config/debug.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"STORAGE_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"STORAGE_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"STORAGE_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"STORAGE_DEBUG_ZPAGES"` -} diff --git a/storage/pkg/config/defaultconfig.go b/storage/pkg/config/defaultconfig.go deleted file mode 100644 index 95cc57c1a..000000000 --- a/storage/pkg/config/defaultconfig.go +++ /dev/null @@ -1,443 +0,0 @@ -package config - -import ( - "os" - "path" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" -) - -func DefaultConfig() *Config { - return &Config{ - // log is inherited - Debug: Debug{ - Addr: "127.0.0.1:9109", - }, - Reva: Reva{ - JWTSecret: "Pive-Fumkiu4", - SkipUserGroupsInToken: false, - TransferSecret: "replace-me-with-a-transfer-secret", - TransferExpires: 24 * 60 * 60, - OIDC: OIDC{ - Issuer: "https://localhost:9200", - Insecure: false, - IDClaim: "preferred_username", - }, - LDAP: LDAP{ - Hostname: "localhost", - Port: 9126, - CACert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"), - Insecure: false, - BaseDN: "dc=ocis,dc=test", - LoginFilter: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))", - UserFilter: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", - UserAttributeFilter: "(&(objectclass=posixAccount)({{attr}}={{value}}))", - UserFindFilter: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", - UserGroupFilter: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", - GroupFilter: "(&(objectclass=posixGroup)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", - GroupAttributeFilter: "(&(objectclass=posixGroup)({{attr}}={{value}}))", - GroupFindFilter: "(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", - GroupMemberFilter: "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))", - BindDN: "cn=reva,ou=sysusers,dc=ocis,dc=test", - BindPassword: "reva", - IDP: "https://localhost:9200", - UserSchema: LDAPUserSchema{ - UID: "ownclouduuid", - Mail: "mail", - DisplayName: "displayname", - CN: "cn", - UIDNumber: "uidnumber", - GIDNumber: "gidnumber", - }, - GroupSchema: LDAPGroupSchema{ - GID: "cn", - Mail: "mail", - DisplayName: "cn", - CN: "cn", - GIDNumber: "gidnumber", - }, - }, - UserGroupRest: UserGroupRest{ - RedisAddress: "localhost:6379", - }, - UserOwnCloudSQL: UserOwnCloudSQL{ - DBUsername: "owncloud", - DBPassword: "secret", - DBHost: "mysql", - DBPort: 3306, - DBName: "owncloud", - Idp: "https://localhost:9200", - Nobody: 90, - JoinUsername: false, - JoinOwnCloudUUID: false, - EnableMedialSearch: false, - }, - OCDav: OCDav{ - WebdavNamespace: "/home/", - DavFilesNamespace: "/users/", - }, - Archiver: Archiver{ - MaxNumFiles: 10000, - MaxSize: 1073741824, - ArchiverURL: "/archiver", - }, - UserStorage: StorageConfig{ - EOS: DriverEOS{ - DriverCommon: DriverCommon{ - Root: "/eos/dockertest/reva", - ShareFolder: "/Shares", - UserLayout: "{{substr 0 1 .Username}}/{{.Username}}", - }, - ShadowNamespace: "", // Defaults to path.Join(c.Namespace, ".shadow") - UploadsNamespace: "", // Defaults to path.Join(c.Namespace, ".uploads") - EosBinary: "/usr/bin/eos", - XrdcopyBinary: "/usr/bin/xrdcopy", - MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094", - SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094", - CacheDirectory: os.TempDir(), - GatewaySVC: "127.0.0.1:9142", - }, - Local: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "local", "users"), - ShareFolder: "/Shares", - UserLayout: "{{.Username}}", - EnableHome: false, - }, - OwnCloud: DriverOwnCloud{ - DriverCommon: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"), - ShareFolder: "/Shares", - UserLayout: "{{.Id.OpaqueId}}", - EnableHome: false, - }, - UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"), - Redis: ":6379", - Scan: true, - }, - OwnCloudSQL: DriverOwnCloudSQL{ - DriverCommon: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"), - ShareFolder: "/Shares", - UserLayout: "{{.Username}}", - EnableHome: false, - }, - UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"), - DBUsername: "owncloud", - DBPassword: "owncloud", - DBHost: "", - DBPort: 3306, - DBName: "owncloud", - }, - S3: DriverS3{ - DriverCommon: DriverCommon{}, - Region: "default", - AccessKey: "", - SecretKey: "", - Endpoint: "", - Bucket: "", - }, - S3NG: DriverS3NG{ - DriverCommon: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "users"), - ShareFolder: "/Shares", - UserLayout: "{{.Id.OpaqueId}}", - EnableHome: false, - }, - ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - Region: "default", - AccessKey: "", - SecretKey: "", - Endpoint: "", - Bucket: "", - }, - OCIS: DriverOCIS{ - DriverCommon: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "users"), - ShareFolder: "/Shares", - UserLayout: "{{.Id.OpaqueId}}", - }, - ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - }, - }, - MetadataStorage: StorageConfig{ - EOS: DriverEOS{ - DriverCommon: DriverCommon{ - Root: "/eos/dockertest/reva", - ShareFolder: "/Shares", - UserLayout: "{{substr 0 1 .Username}}/{{.Username}}", - EnableHome: false, - }, - ShadowNamespace: "", - UploadsNamespace: "", - EosBinary: "/usr/bin/eos", - XrdcopyBinary: "/usr/bin/xrdcopy", - MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094", - GrpcURI: "", - SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094", - CacheDirectory: os.TempDir(), - EnableLogging: false, - ShowHiddenSysFiles: false, - ForceSingleUserMode: false, - UseKeytab: false, - SecProtocol: "", - Keytab: "", - SingleUsername: "", - GatewaySVC: "127.0.0.1:9142", - }, - Local: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "local", "metadata"), - }, - OwnCloud: DriverOwnCloud{}, - OwnCloudSQL: DriverOwnCloudSQL{}, - S3: DriverS3{ - DriverCommon: DriverCommon{}, - Region: "default", - }, - S3NG: DriverS3NG{ - DriverCommon: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"), - ShareFolder: "", - UserLayout: "{{.Id.OpaqueId}}", - EnableHome: false, - }, - ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - Region: "default", - AccessKey: "", - SecretKey: "", - Endpoint: "", - Bucket: "", - }, - OCIS: DriverOCIS{ - DriverCommon: DriverCommon{ - Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"), - ShareFolder: "", - UserLayout: "{{.Id.OpaqueId}}", - EnableHome: false, - }, - ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - }, - }, - Frontend: FrontendPort{ - Port: Port{ - MaxCPUs: "", - LogLevel: "", - GRPCNetwork: "", - GRPCAddr: "", - HTTPNetwork: "tcp", - HTTPAddr: "127.0.0.1:9140", - Protocol: "", - Endpoint: "", - DebugAddr: "127.0.0.1:9141", - Services: []string{"datagateway", "ocdav", "ocs", "appprovider"}, - Config: nil, - Context: nil, - Supervised: false, - }, - AppProviderInsecure: false, - AppProviderPrefix: "", - ArchiverInsecure: false, - ArchiverPrefix: "archiver", - DatagatewayPrefix: "data", - Favorites: false, - OCDavInsecure: false, - OCDavPrefix: "", - OCSPrefix: "ocs", - OCSSharePrefix: "/Shares", - OCSHomeNamespace: "/home", - PublicURL: "https://localhost:9200", - OCSCacheWarmupDriver: "", - OCSAdditionalInfoAttribute: "{{.Mail}}", - OCSResourceInfoCacheTTL: 0, - Middleware: Middleware{}, - }, - DataGateway: DataGatewayPort{ - Port: Port{}, - PublicURL: "", - }, - Gateway: Gateway{ - Port: Port{ - Endpoint: "127.0.0.1:9142", - DebugAddr: "127.0.0.1:9143", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9142", - }, - CommitShareToStorageGrant: true, - CommitShareToStorageRef: true, - DisableHomeCreationOnLogin: false, - ShareFolder: "Shares", - LinkGrants: "", - HomeMapping: "", - EtagCacheTTL: 0, - }, - StorageRegistry: StorageRegistry{ - Driver: "static", - HomeProvider: "/home", - JSON: "", - }, - AppRegistry: AppRegistry{ - Driver: "static", - MimetypesJSON: "", - }, - Users: Users{ - Port: Port{ - Endpoint: "localhost:9144", - DebugAddr: "127.0.0.1:9145", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9144", - Services: []string{"userprovider"}, - }, - Driver: "ldap", - UserGroupsCacheExpiration: 5, - }, - Groups: Groups{ - Port: Port{ - Endpoint: "localhost:9160", - DebugAddr: "127.0.0.1:9161", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9160", - Services: []string{"groupprovider"}, - }, - Driver: "ldap", - GroupMembersCacheExpiration: 5, - }, - AuthProvider: Users{ - Port: Port{}, - Driver: "ldap", - UserGroupsCacheExpiration: 0, - }, - AuthBasic: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9146", - DebugAddr: "127.0.0.1:9147", - Services: []string{"authprovider"}, - Endpoint: "localhost:9146", - }, - AuthBearer: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9148", - DebugAddr: "127.0.0.1:9149", - Services: []string{"authprovider"}, - Endpoint: "localhost:9148", - }, - AuthMachine: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9166", - DebugAddr: "127.0.0.1:9167", - Services: []string{"authprovider"}, - Endpoint: "localhost:9166", - }, - AuthMachineConfig: AuthMachineConfig{ - MachineAuthAPIKey: "change-me-please", - }, - Sharing: Sharing{ - Port: Port{ - Endpoint: "localhost:9150", - DebugAddr: "127.0.0.1:9151", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9150", - Services: []string{"usershareprovider", "publicshareprovider"}, - }, - UserDriver: "json", - UserJSONFile: path.Join(defaults.BaseDataPath(), "storage", "shares.json"), - UserSQLUsername: "", - UserSQLPassword: "", - UserSQLHost: "", - UserSQLPort: 1433, - UserSQLName: "", - PublicDriver: "json", - PublicJSONFile: path.Join(defaults.BaseDataPath(), "storage", "publicshares.json"), - PublicPasswordHashCost: 11, - PublicEnableExpiredSharesCleanup: true, - PublicJanitorRunInterval: 60, - UserStorageMountID: "", - }, - StorageHome: StoragePort{ - Port: Port{ - Endpoint: "localhost:9154", - DebugAddr: "127.0.0.1:9156", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9154", - HTTPNetwork: "tcp", - HTTPAddr: "127.0.0.1:9155", - }, - Driver: "ocis", - ReadOnly: false, - MountPath: "/home", - AlternativeID: "1284d238-aa92-42ce-bdc4-0b0000009154", - MountID: "1284d238-aa92-42ce-bdc4-0b0000009157", - DataServerURL: "http://localhost:9155/data", - HTTPPrefix: "data", - TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "home"), - }, - StorageUsers: StoragePort{ - Port: Port{ - Endpoint: "localhost:9157", - DebugAddr: "127.0.0.1:9159", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9157", - HTTPNetwork: "tcp", - HTTPAddr: "127.0.0.1:9158", - }, - MountPath: "/users", - MountID: "1284d238-aa92-42ce-bdc4-0b0000009157", - Driver: "ocis", - DataServerURL: "http://localhost:9158/data", - HTTPPrefix: "data", - TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "users"), - }, - StoragePublicLink: PublicStorage{ - StoragePort: StoragePort{ - Port: Port{ - Endpoint: "localhost:9178", - DebugAddr: "127.0.0.1:9179", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9178", - }, - MountPath: "/public", - MountID: "e1a73ede-549b-4226-abdf-40e69ca8230d", - }, - PublicShareProviderAddr: "", - UserProviderAddr: "", - }, - StorageMetadata: StoragePort{ - Port: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9215", - HTTPNetwork: "tcp", - HTTPAddr: "127.0.0.1:9216", - DebugAddr: "127.0.0.1:9217", - }, - Driver: "ocis", - ExposeDataServer: false, - DataServerURL: "http://localhost:9216/data", - TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "metadata"), - DataProvider: DataProvider{}, - }, - AppProvider: AppProvider{ - Port: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9164", - DebugAddr: "127.0.0.1:9165", - Endpoint: "localhost:9164", - Services: []string{"appprovider"}, - }, - ExternalAddr: "127.0.0.1:9164", - WopiDriver: WopiDriver{}, - AppsURL: "/app/list", - OpenURL: "/app/open", - NewURL: "/app/new", - }, - Configs: nil, - UploadMaxChunkSize: 1e+8, - UploadHTTPMethodOverride: "", - ChecksumSupportedTypes: []string{"sha1", "md5", "adler32"}, - ChecksumPreferredUploadType: "", - DefaultUploadProtocol: "tus", - }, - Tracing: Tracing{ - Service: "storage", - Type: "jaeger", - }, - Asset: Asset{}, - } -} diff --git a/storage/pkg/config/grpc.go b/storage/pkg/config/grpc.go deleted file mode 100644 index 016b61fa9..000000000 --- a/storage/pkg/config/grpc.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -// GRPC defines the available grpc configuration. -type GRPC struct { - Addr string `ocisConfig:"addr" env:"SETTINGS_GRPC_ADDR"` - Namespace string -} diff --git a/storage/pkg/config/http.go b/storage/pkg/config/http.go deleted file mode 100644 index f2099febf..000000000 --- a/storage/pkg/config/http.go +++ /dev/null @@ -1,18 +0,0 @@ -package config - -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"SETTINGS_HTTP_ADDR"` - Namespace string - Root string `ocisConfig:"root" env:"SETTINGS_HTTP_ROOT"` - CacheTTL int `ocisConfig:"cache_ttl" env:"SETTINGS_CACHE_TTL"` - CORS CORS `ocisConfig:"cors"` -} - -// CORS defines the available cors configuration. -type CORS struct { - AllowedOrigins []string `ocisConfig:"allowed_origins"` - AllowedMethods []string `ocisConfig:"allowed_methods"` - AllowedHeaders []string `ocisConfig:"allowed_headers"` - AllowCredentials bool `ocisConfig:"allowed_credentials"` -} diff --git a/storage/pkg/config/log.go b/storage/pkg/config/log.go deleted file mode 100644 index eb14a82e8..000000000 --- a/storage/pkg/config/log.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;STORAGE_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;STORAGE_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;STORAGE_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;STORAGE_LOG_FILE"` -} diff --git a/storage/pkg/config/reva.go b/storage/pkg/config/reva.go deleted file mode 100644 index 5427747df..000000000 --- a/storage/pkg/config/reva.go +++ /dev/null @@ -1,6 +0,0 @@ -package config - -// TokenManager is the config for using the reva token manager -type TokenManager struct { - JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;SETTINGS_JWT_SECRET"` -} diff --git a/storage/pkg/config/service.go b/storage/pkg/config/service.go deleted file mode 100644 index c12faf344..000000000 --- a/storage/pkg/config/service.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} diff --git a/storage/pkg/config/tracing.go b/storage/pkg/config/tracing.go deleted file mode 100644 index b5c955444..000000000 --- a/storage/pkg/config/tracing.go +++ /dev/null @@ -1,10 +0,0 @@ -package config - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;STORAGE_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;STORAGE_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;STORAGE_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;STORAGE_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"STORAGE_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} diff --git a/storage/pkg/logging/logging.go b/storage/pkg/logging/logging.go deleted file mode 100644 index c9d443321..000000000 --- a/storage/pkg/logging/logging.go +++ /dev/null @@ -1,17 +0,0 @@ -package logging - -import ( - "github.com/owncloud/ocis/ocis-pkg/log" - "github.com/owncloud/ocis/storage/pkg/config" -) - -// LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { - return log.NewLogger( - log.Name(name), - log.Level(cfg.Level), - log.Pretty(cfg.Pretty), - log.Color(cfg.Color), - log.File(cfg.File), - ) -} diff --git a/store/pkg/command/root.go b/store/pkg/command/root.go index 5c63f8a3e..e796cf590 100644 --- a/store/pkg/command/root.go +++ b/store/pkg/command/root.go @@ -60,17 +60,17 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { return err } - // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + // provide with defaults for shared logging, since we need a valid destination address for BindEnv. + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} diff --git a/store/pkg/config/config.go b/store/pkg/config/config.go index bb79327e8..c8b807bdb 100644 --- a/store/pkg/config/config.go +++ b/store/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` GRPC GRPC `ocisConfig:"grpc"` diff --git a/store/pkg/config/defaultconfig.go b/store/pkg/config/defaultconfig.go index 4ba99550c..66e44044d 100644 --- a/store/pkg/config/defaultconfig.go +++ b/store/pkg/config/defaultconfig.go @@ -26,7 +26,6 @@ func DefaultConfig() *Config { Type: "jaeger", Endpoint: "", Collector: "", - Service: "store", }, Datapath: path.Join(defaults.BaseDataPath(), "store"), } diff --git a/store/pkg/config/tracing.go b/store/pkg/config/tracing.go index a54001c94..7e1ba1821 100644 --- a/store/pkg/config/tracing.go +++ b/store/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;STORE_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;STORE_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;STORE_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"STORE_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/store/pkg/logging/logging.go b/store/pkg/logging/logging.go index e6183eb18..c5c6d4520 100644 --- a/store/pkg/logging/logging.go +++ b/store/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/store/pkg/tracing/tracing.go b/store/pkg/tracing/tracing.go index b6f66479f..54eef8ca3 100644 --- a/store/pkg/tracing/tracing.go +++ b/store/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "store", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/thumbnails/pkg/command/root.go b/thumbnails/pkg/command/root.go index 57428daac..eae5eed50 100644 --- a/thumbnails/pkg/command/root.go +++ b/thumbnails/pkg/command/root.go @@ -61,16 +61,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -93,7 +93,7 @@ type SutureService struct { // NewSutureService creates a new thumbnails.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Thumbnails.Commons = cfg.Commons + cfg.Thumbnails.Commons = cfg.Commons return SutureService{ cfg: cfg.Thumbnails, } diff --git a/thumbnails/pkg/config/config.go b/thumbnails/pkg/config/config.go index 30c225fac..ddc024d54 100644 --- a/thumbnails/pkg/config/config.go +++ b/thumbnails/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` GRPC GRPC `ocisConfig:"grpc"` diff --git a/thumbnails/pkg/config/defaultconfig.go b/thumbnails/pkg/config/defaultconfig.go index bc7bd36fa..7da4bac4f 100644 --- a/thumbnails/pkg/config/defaultconfig.go +++ b/thumbnails/pkg/config/defaultconfig.go @@ -26,7 +26,6 @@ func DefaultConfig() *Config { Type: "jaeger", Endpoint: "", Collector: "", - Service: "thumbnails", }, Thumbnail: Thumbnail{ Resolutions: []string{"16x16", "32x32", "64x64", "128x128", "1920x1080", "3840x2160", "7680x4320"}, diff --git a/thumbnails/pkg/config/tracing.go b/thumbnails/pkg/config/tracing.go index e118e1530..bbb13435c 100644 --- a/thumbnails/pkg/config/tracing.go +++ b/thumbnails/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;THUMBNAILS_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;THUMBNAILS_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;THUMBNAILS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"THUMBNAILS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/thumbnails/pkg/logging/logging.go b/thumbnails/pkg/logging/logging.go index e097814b2..41d558326 100644 --- a/thumbnails/pkg/logging/logging.go +++ b/thumbnails/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/thumbnails/pkg/tracing/tracing.go b/thumbnails/pkg/tracing/tracing.go index 6bbd7afc8..16db3bb6f 100644 --- a/thumbnails/pkg/tracing/tracing.go +++ b/thumbnails/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "thumbnails", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/web/pkg/command/root.go b/web/pkg/command/root.go index 0a7e731c6..11c6b5ffa 100644 --- a/web/pkg/command/root.go +++ b/web/pkg/command/root.go @@ -59,16 +59,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -91,7 +91,7 @@ type SutureService struct { // NewSutureService creates a new web.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Web.Commons = cfg.Commons + cfg.Web.Commons = cfg.Commons return SutureService{ cfg: cfg.Web, } diff --git a/web/pkg/config/config.go b/web/pkg/config/config.go index 6a1ef7eab..df0f7ab6d 100644 --- a/web/pkg/config/config.go +++ b/web/pkg/config/config.go @@ -1,13 +1,19 @@ package config -import "context" +import ( + "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" +) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/web/pkg/config/defaultconfig.go b/web/pkg/config/defaultconfig.go index a41d1af4d..42f22beda 100644 --- a/web/pkg/config/defaultconfig.go +++ b/web/pkg/config/defaultconfig.go @@ -22,7 +22,6 @@ func DefaultConfig() *Config { Type: "jaeger", Endpoint: "", Collector: "", - Service: "web", }, Asset: Asset{ Path: "", diff --git a/web/pkg/config/tracing.go b/web/pkg/config/tracing.go index c6bb6569a..6c54223d6 100644 --- a/web/pkg/config/tracing.go +++ b/web/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEB_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEB_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEB_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"WEB_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/web/pkg/logging/logging.go b/web/pkg/logging/logging.go index 6510b8c21..57616a43b 100644 --- a/web/pkg/logging/logging.go +++ b/web/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/web/pkg/tracing/tracing.go b/web/pkg/tracing/tracing.go index 1bd7caf66..cebc588bd 100644 --- a/web/pkg/tracing/tracing.go +++ b/web/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "web", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } } diff --git a/webdav/pkg/command/root.go b/webdav/pkg/command/root.go index 15d0db369..f2ec6221a 100644 --- a/webdav/pkg/command/root.go +++ b/webdav/pkg/command/root.go @@ -59,16 +59,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { } // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - //if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - // cfg.Log = &shared.Log{ - // Level: cfg.Commons.Log.Level, - // Pretty: cfg.Commons.Log.Pretty, - // Color: cfg.Commons.Log.Color, - // File: cfg.Commons.Log.File, - // } - //} else if cfg.Log == nil && cfg.Commons == nil { - // cfg.Log = &shared.Log{} - //} + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &config.Log{} + } // load all env variables relevant to the config in the current context. envCfg := config.Config{} @@ -91,7 +91,7 @@ type SutureService struct { // NewSutureService creates a new webdav.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { - //cfg.Proxy.Commons = cfg.Commons + cfg.Proxy.Commons = cfg.Commons return SutureService{ cfg: cfg.WebDAV, } diff --git a/webdav/pkg/config/config.go b/webdav/pkg/config/config.go index 9003f946e..9739198d3 100644 --- a/webdav/pkg/config/config.go +++ b/webdav/pkg/config/config.go @@ -2,14 +2,18 @@ package config import ( "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" ) // Config combines all available configuration parts. type Config struct { + *shared.Commons + Service Service Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` + Log *Log `ocisConfig:"log"` Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` diff --git a/webdav/pkg/config/defaultconfig.go b/webdav/pkg/config/defaultconfig.go index 6d0e82310..5edb962c4 100644 --- a/webdav/pkg/config/defaultconfig.go +++ b/webdav/pkg/config/defaultconfig.go @@ -27,7 +27,6 @@ func DefaultConfig() *Config { Type: "jaeger", Endpoint: "", Collector: "", - Service: "webdav", }, OcisPublicURL: "https://127.0.0.1:9200", WebdavNamespace: "/home", diff --git a/webdav/pkg/config/tracing.go b/webdav/pkg/config/tracing.go index f63b2480d..311e5fbc0 100644 --- a/webdav/pkg/config/tracing.go +++ b/webdav/pkg/config/tracing.go @@ -6,5 +6,4 @@ type Tracing struct { Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEBDAV_TRACING_TYPE"` Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEBDAV_TRACING_ENDPOINT"` Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEBDAV_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"WEBDAV_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? } diff --git a/webdav/pkg/logging/logging.go b/webdav/pkg/logging/logging.go index 11c8f85aa..ff82b1f6b 100644 --- a/webdav/pkg/logging/logging.go +++ b/webdav/pkg/logging/logging.go @@ -6,7 +6,7 @@ import ( ) // LoggerFromConfig initializes a service-specific logger instance. -func Configure(name string, cfg config.Log) log.Logger { +func Configure(name string, cfg *config.Log) log.Logger { return log.NewLogger( log.Name(name), log.Level(cfg.Level), diff --git a/webdav/pkg/tracing/tracing.go b/webdav/pkg/tracing/tracing.go index f3efeecd0..8a2c53929 100644 --- a/webdav/pkg/tracing/tracing.go +++ b/webdav/pkg/tracing/tracing.go @@ -14,7 +14,7 @@ var ( func Configure(cfg *config.Config) error { var err error if cfg.Tracing.Enabled { - if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, "webdav", cfg.Tracing.Type); err != nil { + if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil { return err } }