add ocis-pkg/config default config + fix logging inheritance

This commit is contained in:
A.Unger
2021-11-08 11:14:26 +01:00
parent 835928b29b
commit 74dae6dad9
11 changed files with 152 additions and 249 deletions

View File

@@ -141,10 +141,10 @@ type OIDC struct {
// PolicySelector is the toplevel-configuration for different selectors
type PolicySelector struct {
Static *StaticSelectorConf
Migration *MigrationSelectorConf
Claims *ClaimsSelectorConf
Regex *RegexSelectorConf
Static *StaticSelectorConf `mapstructure:"static"`
Migration *MigrationSelectorConf `mapstructure:"migration"`
Claims *ClaimsSelectorConf `mapstructure:"claims"`
Regex *RegexSelectorConf `mapstructure:"regex"`
}
// StaticSelectorConf is the config for the static-policy-selector

View File

@@ -1,17 +0,0 @@
package config
type mapping struct {
EnvVars []string // name of the EnvVars var.
Destination interface{} // memory address of the original config value to modify.
}
// 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
}

View File

@@ -2,7 +2,20 @@ package config
import "github.com/owncloud/ocis/ocis-pkg/shared"
// StructMappings binds a set of environment variables to a destination on cfg.
// 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
}
// 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)
}