This commit is contained in:
A.Unger
2021-11-11 13:14:19 +01:00
parent 0d1c8accf2
commit 6391d94516
6 changed files with 44 additions and 58 deletions
+13 -23
View File
@@ -61,17 +61,19 @@ type Backend struct {
// Config combines all available configuration parts.
type Config struct {
File string `mapstructure:"file"`
Log shared.Log `mapstructure:"log"`
Debug Debug `mapstructure:"debug"`
HTTP HTTP `mapstructure:"http"`
Tracing Tracing `mapstructure:"tracing"`
Ldap Ldap `mapstructure:"ldap"`
Ldaps Ldaps `mapstructure:"ldaps"`
Backend Backend `mapstructure:"backend"`
Fallback Backend `mapstructure:"fallback"`
Version string `mapstructure:"version"`
RoleBundleUUID string `mapstructure:"role_bundle_uuid"`
*shared.Commons
File string `mapstructure:"file"`
Log *shared.Log `mapstructure:"log"`
Debug Debug `mapstructure:"debug"`
HTTP HTTP `mapstructure:"http"`
Tracing Tracing `mapstructure:"tracing"`
Ldap Ldap `mapstructure:"ldap"`
Ldaps Ldaps `mapstructure:"ldaps"`
Backend Backend `mapstructure:"backend"`
Fallback Backend `mapstructure:"fallback"`
Version string `mapstructure:"version"`
RoleBundleUUID string `mapstructure:"role_bundle_uuid"`
Context context.Context
Supervised bool
@@ -84,7 +86,6 @@ func New() *Config {
func DefaultConfig() *Config {
return &Config{
Log: shared.Log{},
Debug: Debug{
Addr: "127.0.0.1:9129",
},
@@ -126,14 +127,3 @@ func DefaultConfig() *Config {
RoleBundleUUID: "71881883-1768-46bd-a24d-a356a2afdf7f", // BundleUUIDRoleAdmin
}
}
// 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
}
+11
View File
@@ -2,6 +2,17 @@ package config
import "github.com/owncloud/ocis/ocis-pkg/shared"
// 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(cfg *Config) []string {
var r = make([]string, len(structMappings(cfg)))
for i := range structMappings(cfg) {
r = append(r, structMappings(cfg)[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.