Merge branch 'master' into StoreSettingsViaMetadata
This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/owncloud/ocis/audit/pkg/command"
|
"github.com/owncloud/ocis/audit/pkg/command"
|
||||||
"github.com/owncloud/ocis/audit/pkg/config"
|
"github.com/owncloud/ocis/audit/pkg/config/defaults"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := command.Execute(config.DefaultConfig()); err != nil {
|
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package config
|
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
|
||||||
return &Config{
|
|
||||||
Service: Service{
|
|
||||||
Name: "audit",
|
|
||||||
},
|
|
||||||
Events: Events{
|
|
||||||
Endpoint: "127.0.0.1:9233",
|
|
||||||
Cluster: "test-cluster",
|
|
||||||
ConsumerGroup: "audit",
|
|
||||||
},
|
|
||||||
Auditlog: Auditlog{
|
|
||||||
LogToConsole: true,
|
|
||||||
Format: "json",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package defaults
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/owncloud/ocis/audit/pkg/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func FullDefaultConfig() *config.Config {
|
||||||
|
cfg := DefaultConfig()
|
||||||
|
|
||||||
|
EnsureDefaults(cfg)
|
||||||
|
Sanitize(cfg)
|
||||||
|
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultConfig() *config.Config {
|
||||||
|
return &config.Config{
|
||||||
|
Service: config.Service{
|
||||||
|
Name: "audit",
|
||||||
|
},
|
||||||
|
Events: config.Events{
|
||||||
|
Endpoint: "127.0.0.1:9233",
|
||||||
|
Cluster: "test-cluster",
|
||||||
|
ConsumerGroup: "audit",
|
||||||
|
},
|
||||||
|
Auditlog: config.Auditlog{
|
||||||
|
LogToConsole: true,
|
||||||
|
Format: "json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func EnsureDefaults(cfg *config.Config) {
|
||||||
|
// 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.Log = &config.Log{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sanitize(cfg *config.Config) {
|
||||||
|
// sanitize config
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/owncloud/ocis/audit/pkg/config"
|
"github.com/owncloud/ocis/audit/pkg/config"
|
||||||
|
"github.com/owncloud/ocis/audit/pkg/config/defaults"
|
||||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||||
|
|
||||||
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
|
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
|
||||||
@@ -16,17 +17,7 @@ func ParseConfig(cfg *config.Config) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// provide with defaults for shared logging, since we need a valid destination address for BindEnv.
|
defaults.EnsureDefaults(cfg)
|
||||||
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.Log = &config.Log{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// load all env variables relevant to the config in the current context.
|
// load all env variables relevant to the config in the current context.
|
||||||
if err := envdecode.Decode(cfg); err != nil {
|
if err := envdecode.Decode(cfg); err != nil {
|
||||||
@@ -36,5 +27,7 @@ func ParseConfig(cfg *config.Config) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaults.Sanitize(cfg)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
accounts "github.com/owncloud/ocis/accounts/pkg/config/defaults"
|
accounts "github.com/owncloud/ocis/accounts/pkg/config/defaults"
|
||||||
audit "github.com/owncloud/ocis/audit/pkg/config"
|
audit "github.com/owncloud/ocis/audit/pkg/config/defaults"
|
||||||
glauth "github.com/owncloud/ocis/glauth/pkg/config/defaults"
|
glauth "github.com/owncloud/ocis/glauth/pkg/config/defaults"
|
||||||
graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/config/defaults"
|
graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/config/defaults"
|
||||||
graph "github.com/owncloud/ocis/graph/pkg/config/defaults"
|
graph "github.com/owncloud/ocis/graph/pkg/config/defaults"
|
||||||
|
|||||||
Reference in New Issue
Block a user