mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-01 10:30:40 -06:00
new config framework in proxy
This commit is contained in:
@@ -5,11 +5,14 @@ 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/proxy/pkg/command"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var globalLog shared.Log
|
||||
|
||||
// ProxyCommand is the entry point for the proxy command.
|
||||
func ProxyCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
@@ -20,10 +23,20 @@ func ProxyCommand(cfg *config.Config) *cli.Command {
|
||||
command.PrintVersion(cfg.Proxy),
|
||||
},
|
||||
Before: func(ctx *cli.Context) error {
|
||||
return ParseConfig(ctx, cfg)
|
||||
if err := ParseConfig(ctx, cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
globalLog = cfg.Log
|
||||
|
||||
return nil
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
cfg.Proxy.Log = cfg.Log
|
||||
// if proxy logging is empty in ocis.yaml
|
||||
if (cfg.Proxy.Log == shared.Log{}) && (globalLog != shared.Log{}) {
|
||||
// we can safely inherit the global logging values.
|
||||
cfg.Proxy.Log = globalLog
|
||||
}
|
||||
origCmd := command.Server(cfg.Proxy)
|
||||
return handleOriginalAction(c, origCmd)
|
||||
},
|
||||
|
||||
@@ -62,7 +62,7 @@ func NewLogger(cfg *config.Config) log.Logger {
|
||||
)
|
||||
}
|
||||
|
||||
// ParseConfig loads ocis configuration from known paths.
|
||||
// ParseConfig loads ocis configuration.
|
||||
func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
conf, err := ociscfg.BindSourcesToStructs("ocis", cfg)
|
||||
if err != nil {
|
||||
@@ -71,9 +71,6 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
|
||||
conf.LoadOSEnv(config.GetEnv(), false)
|
||||
|
||||
if err = cfg.UnmapEnv(conf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
bindings := config.StructMappings(cfg)
|
||||
return ociscfg.BindEnv(conf, bindings)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user