mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 11:51:16 -06:00
losing my mind
This commit is contained in:
@@ -5,7 +5,6 @@ package command
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
"github.com/owncloud/ocis/ocis/pkg/register"
|
||||
"github.com/owncloud/ocis/settings/pkg/command"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -13,8 +12,6 @@ import (
|
||||
|
||||
// SettingsCommand is the entry point for the settings command.
|
||||
func SettingsCommand(cfg *config.Config) *cli.Command {
|
||||
var globalLog shared.Log
|
||||
|
||||
return &cli.Command{
|
||||
Name: "settings",
|
||||
Usage: "Start settings server",
|
||||
@@ -27,16 +24,13 @@ func SettingsCommand(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
globalLog = cfg.Log
|
||||
if cfg.Commons != nil {
|
||||
cfg.Settings.Commons = cfg.Commons
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
// if accounts logging is empty in ocis.yaml
|
||||
if (cfg.Settings.Log == shared.Log{}) && (globalLog != shared.Log{}) {
|
||||
// we can safely inherit the global logging values.
|
||||
cfg.Settings.Log = globalLog
|
||||
}
|
||||
origCmd := command.Server(cfg.Settings)
|
||||
return handleOriginalAction(c, origCmd)
|
||||
},
|
||||
|
||||
@@ -159,6 +159,11 @@ func Start(o ...Option) error {
|
||||
FailureBackoff: 3 * time.Second,
|
||||
})
|
||||
|
||||
s.cfg.Storage.Log.Color = s.cfg.Log.Color
|
||||
s.cfg.Storage.Log.Level = s.cfg.Log.Level
|
||||
s.cfg.Storage.Log.Pretty = s.cfg.Log.Pretty
|
||||
s.cfg.Storage.Log.File = s.cfg.Log.File
|
||||
|
||||
if err = rpc.Register(s); err != nil {
|
||||
if s != nil {
|
||||
s.Log.Fatal().Err(err)
|
||||
|
||||
@@ -71,7 +71,20 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
conf.LoadOSEnv(config.GetEnv(), false)
|
||||
|
||||
// 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{}
|
||||
}
|
||||
|
||||
conf.LoadOSEnv(config.GetEnv(cfg), false)
|
||||
bindings := config.StructMappings(cfg)
|
||||
return ociscfg.BindEnv(conf, bindings)
|
||||
}
|
||||
@@ -83,9 +96,7 @@ type SutureService struct {
|
||||
|
||||
// NewSutureService creates a new settings.SutureService
|
||||
func NewSutureService(cfg *ociscfg.Config) suture.Service {
|
||||
if (cfg.Settings.Log == shared.Log{}) {
|
||||
cfg.Settings.Log = cfg.Log
|
||||
}
|
||||
cfg.Settings.Commons = cfg.Commons
|
||||
return SutureService{
|
||||
cfg: cfg.Settings,
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
gofig "github.com/gookit/config/v2"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
@@ -25,9 +21,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Name: "server",
|
||||
Usage: "Start integrated server",
|
||||
Before: func(ctx *cli.Context) error {
|
||||
// remember shared logging info to prevent empty overwrites
|
||||
inLog := cfg.Log
|
||||
|
||||
if cfg.HTTP.Root != "/" {
|
||||
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
|
||||
}
|
||||
@@ -36,19 +29,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
if (cfg.Log == shared.Log{}) && (inLog != shared.Log{}) {
|
||||
// set the default to the parent config
|
||||
cfg.Log = inLog
|
||||
|
||||
// and parse the environment
|
||||
conf := &gofig.Config{}
|
||||
conf.LoadOSEnv(config.GetEnv(), false)
|
||||
bindings := config.StructMappings(cfg)
|
||||
if err := ociscfg.BindEnv(conf, bindings); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
|
||||
@@ -68,9 +68,11 @@ type TokenManager struct {
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
*shared.Commons
|
||||
|
||||
File string
|
||||
Service Service
|
||||
Log shared.Log
|
||||
Log *shared.Log
|
||||
Debug Debug
|
||||
HTTP HTTP
|
||||
GRPC GRPC
|
||||
@@ -90,7 +92,6 @@ func New() *Config {
|
||||
// DefaultConfig provides sane bootstrapping defaults.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Log: shared.Log{},
|
||||
Service: Service{
|
||||
Name: "settings",
|
||||
DataPath: path.Join(defaults.BaseDataPath(), "settings"),
|
||||
@@ -132,14 +133,3 @@ func DefaultConfig() *Config {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetEnv fetches a list of known env variables for this extension. It is to be used by gookit, as it provides a list
|
||||
// with all the environment variables an extension supports.
|
||||
func GetEnv() []string {
|
||||
var r = make([]string, len(structMappings(&Config{})))
|
||||
for i := range structMappings(&Config{}) {
|
||||
r = append(r, structMappings(&Config{})[i].EnvVars...)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -2,6 +2,17 @@ package config
|
||||
|
||||
import "github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
|
||||
// GetEnv fetches a list of known env variables for this extension. It is to be used by gookit, as it provides a list
|
||||
// with all the environment variables an extension supports.
|
||||
func GetEnv(cfg *Config) []string {
|
||||
var r = make([]string, len(structMappings(cfg)))
|
||||
for i := range structMappings(cfg) {
|
||||
r = append(r, structMappings(cfg)[i].EnvVars...)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -24,17 +24,17 @@ type Store struct {
|
||||
// New creates a new store
|
||||
func New(cfg *config.Config) settings.Manager {
|
||||
s := Store{
|
||||
Logger: olog.NewLogger(
|
||||
olog.Color(cfg.Log.Color),
|
||||
olog.Pretty(cfg.Log.Pretty),
|
||||
olog.Level(cfg.Log.Level),
|
||||
olog.File(cfg.Log.File),
|
||||
),
|
||||
//Logger: olog.NewLogger(
|
||||
// olog.Color(cfg.Log.Color),
|
||||
// olog.Pretty(cfg.Log.Pretty),
|
||||
// olog.Level(cfg.Log.Level),
|
||||
// olog.File(cfg.Log.File),
|
||||
//),
|
||||
}
|
||||
|
||||
if _, err := os.Stat(cfg.Service.DataPath); err != nil {
|
||||
s.Logger.Info().Msgf("creating container on %v", cfg.Service.DataPath)
|
||||
err := os.MkdirAll(cfg.Service.DataPath, 0700)
|
||||
err = os.MkdirAll(cfg.Service.DataPath, 0700)
|
||||
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("providing container on %v", cfg.Service.DataPath)
|
||||
|
||||
@@ -132,7 +132,7 @@ type AppProviderSutureService struct {
|
||||
|
||||
// NewAppProvider creates a new store.AppProviderSutureService
|
||||
func NewAppProvider(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return AppProviderSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ type AuthBasicSutureService struct {
|
||||
|
||||
// NewAuthBasicSutureService creates a new store.AuthBasicSutureService
|
||||
func NewAuthBasic(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return AuthBasicSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ type AuthBearerSutureService struct {
|
||||
|
||||
// NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService
|
||||
func NewAuthBearer(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return AuthBearerSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ type AuthMachineSutureService struct {
|
||||
|
||||
// NewAuthMachineSutureService creates a new gateway.AuthMachineSutureService
|
||||
func NewAuthMachine(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return AuthMachineSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ type FrontendSutureService struct {
|
||||
|
||||
// NewFrontend creates a new frontend.FrontendSutureService
|
||||
func NewFrontend(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return FrontendSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ type GatewaySutureService struct {
|
||||
|
||||
// NewGatewaySutureService creates a new gateway.GatewaySutureService
|
||||
func NewGateway(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return GatewaySutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ type GroupSutureService struct {
|
||||
|
||||
// NewGroupProviderSutureService creates a new storage.GroupProvider
|
||||
func NewGroupProvider(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return GroupSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ type SharingSutureService struct {
|
||||
|
||||
// NewSharingSutureService creates a new store.SharingSutureService
|
||||
func NewSharing(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return SharingSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ type StorageHomeSutureService struct {
|
||||
|
||||
// NewStorageHomeSutureService creates a new storage.StorageHomeSutureService
|
||||
func NewStorageHome(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return StorageHomeSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ type MetadataSutureService struct {
|
||||
|
||||
// NewSutureService creates a new storagemetadata.SutureService
|
||||
func NewStorageMetadata(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return MetadataSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ type StoragePublicLinkSutureService struct {
|
||||
|
||||
// NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService
|
||||
func NewStoragePublicLink(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return StoragePublicLinkSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ type StorageUsersSutureService struct {
|
||||
|
||||
// NewStorageUsersSutureService creates a new storage.StorageUsersSutureService
|
||||
func NewStorageUsers(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return StorageUsersSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ type UserProviderSutureService struct {
|
||||
|
||||
// NewUserProviderSutureService creates a new storage.UserProvider
|
||||
func NewUserProvider(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Log = cfg.Commons.Log
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return UserProviderSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
|
||||
@@ -500,6 +500,8 @@ type Asset struct {
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
*shared.Commons
|
||||
|
||||
File string
|
||||
Log *shared.Log
|
||||
Debug Debug
|
||||
|
||||
Reference in New Issue
Block a user