normalize graph-explorer
This commit is contained in:
@@ -6,16 +6,9 @@ import (
|
||||
"reflect"
|
||||
|
||||
gofig "github.com/gookit/config/v2"
|
||||
"github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
)
|
||||
|
||||
// Log defines the available logging configuration.
|
||||
type Log struct {
|
||||
Level string `mapstructure:"level"`
|
||||
Pretty bool `mapstructure:"pretty"`
|
||||
Color bool `mapstructure:"color"`
|
||||
File string `mapstructure:"file"`
|
||||
}
|
||||
|
||||
// Debug defines the available debug configuration.
|
||||
type Debug struct {
|
||||
Addr string `mapstructure:"addr"`
|
||||
@@ -57,7 +50,7 @@ type GraphExplorer struct {
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
File string `mapstructure:"file"`
|
||||
Log Log `mapstructure:"log"`
|
||||
Log shared.Log `mapstructure:"log"`
|
||||
Debug Debug `mapstructure:"debug"`
|
||||
HTTP HTTP `mapstructure:"http"`
|
||||
Server Server `mapstructure:"server"`
|
||||
@@ -76,7 +69,7 @@ func New() *Config {
|
||||
// DefaultConfig provides with a working version of a config.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Log: Log{},
|
||||
Log: shared.Log{},
|
||||
Debug: Debug{
|
||||
Addr: "127.0.0.1:9136",
|
||||
Token: "",
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package config
|
||||
|
||||
type mapping struct {
|
||||
EnvVars []string // name of the EnvVars var.
|
||||
Destination interface{} // memory address of the original config value to modify.
|
||||
import "github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
|
||||
// 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.
|
||||
func StructMappings(cfg *Config) []shared.EnvBinding {
|
||||
return structMappings(cfg)
|
||||
}
|
||||
|
||||
// structMappings binds a set of environment variables to a destination on cfg.
|
||||
func structMappings(cfg *Config) []mapping {
|
||||
return []mapping{
|
||||
func structMappings(cfg *Config) []shared.EnvBinding {
|
||||
return []shared.EnvBinding{
|
||||
{
|
||||
EnvVars: []string{"GRAPH_EXPLORER_LOG_LEVEL", "OCIS_LOG_LEVEL"},
|
||||
Destination: &cfg.Log.Level,
|
||||
Reference in New Issue
Block a user