Skip to content

Commit

Permalink
Merge branch 'master' into StoreSettingsViaMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kobergj committed Mar 14, 2022
2 parents 2d4d90a + 51d1eb0 commit 65b3c97
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
4 changes: 2 additions & 2 deletions audit/cmd/notifications/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"os"

"github.com/owncloud/ocis/audit/pkg/command"
"github.com/owncloud/ocis/audit/pkg/config"
"github.com/owncloud/ocis/audit/pkg/config/defaults"
)

func main() {
if err := command.Execute(config.DefaultConfig()); err != nil {
if err := command.Execute(defaults.DefaultConfig()); err != nil {
os.Exit(1)
}
}
18 changes: 0 additions & 18 deletions audit/pkg/config/defaultconfig.go

This file was deleted.

49 changes: 49 additions & 0 deletions audit/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 4 additions & 11 deletions audit/pkg/config/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

"github.com/owncloud/ocis/audit/pkg/config"
"github.com/owncloud/ocis/audit/pkg/config/defaults"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"

"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
Expand All @@ -16,17 +17,7 @@ func ParseConfig(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 = &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{}
}
defaults.EnsureDefaults(cfg)

// load all env variables relevant to the config in the current context.
if err := envdecode.Decode(cfg); err != nil {
Expand All @@ -36,5 +27,7 @@ func ParseConfig(cfg *config.Config) error {
}
}

defaults.Sanitize(cfg)

return nil
}
2 changes: 1 addition & 1 deletion ocis-pkg/config/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import (
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"
graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/config/defaults"
graph "github.com/owncloud/ocis/graph/pkg/config/defaults"
Expand Down

0 comments on commit 65b3c97

Please sign in to comment.