mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-27 22:41:10 -05:00
124 lines
3.3 KiB
Go
124 lines
3.3 KiB
Go
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.
|
|
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) []shared.EnvBinding {
|
|
return []shared.EnvBinding{
|
|
{
|
|
EnvVars: []string{"OCIS_LOG_FILE", "OCS_LOG_FILE"},
|
|
Destination: &cfg.Log.File,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_LOG_LEVEL", "OCS_LOG_LEVEL"},
|
|
Destination: &cfg.Log.Level,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_LOG_PRETTY", "OCS_LOG_PRETTY"},
|
|
Destination: &cfg.Log.Pretty,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_LOG_COLOR", "OCS_LOG_COLOR"},
|
|
Destination: &cfg.Log.Color,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_CONFIG_FILE"},
|
|
Destination: &cfg.File,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_TRACING_ENABLED", "OCS_TRACING_ENABLED"},
|
|
Destination: &cfg.Tracing.Enabled,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_TRACING_TYPE", "OCS_TRACING_TYPE"},
|
|
Destination: &cfg.Tracing.Type,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_TRACING_ENDPOINT", "OCS_TRACING_ENDPOINT"},
|
|
Destination: &cfg.Tracing.Endpoint,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_TRACING_COLLECTOR", "OCS_TRACING_COLLECTOR"},
|
|
Destination: &cfg.Tracing.Collector,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_TRACING_SERVICE"},
|
|
Destination: &cfg.Tracing.Service,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_DEBUG_ADDR"},
|
|
Destination: &cfg.Debug.Addr,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_DEBUG_TOKEN"},
|
|
Destination: &cfg.Debug.Token,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_DEBUG_PPROF"},
|
|
Destination: &cfg.Debug.Pprof,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_DEBUG_ZPAGES"},
|
|
Destination: &cfg.Debug.Zpages,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_HTTP_ADDR"},
|
|
Destination: &cfg.HTTP.Addr,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_NAMESPACE"},
|
|
Destination: &cfg.Service.Namespace,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_NAME"},
|
|
Destination: &cfg.Service.Name,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_HTTP_ROOT"},
|
|
Destination: &cfg.HTTP.Root,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_JWT_SECRET", "OCS_JWT_SECRET"},
|
|
Destination: &cfg.TokenManager.JWTSecret,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCS_ACCOUNT_BACKEND_TYPE"},
|
|
Destination: &cfg.AccountBackend,
|
|
},
|
|
{
|
|
EnvVars: []string{"REVA_GATEWAY"},
|
|
Destination: &cfg.Reva.Address,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_MACHINE_AUTH_API_KEY", "OCS_MACHINE_AUTH_API_KEY"},
|
|
Destination: &cfg.MachineAuthAPIKey,
|
|
},
|
|
{
|
|
EnvVars: []string{"OCIS_URL", "OCS_IDM_ADDRESS"},
|
|
Destination: &cfg.IdentityManagement.Address,
|
|
},
|
|
{
|
|
EnvVars: []string{"STORAGE_USERS_DRIVER", "OCS_STORAGE_USERS_DRIVER"},
|
|
Destination: &cfg.StorageUsersDriver,
|
|
},
|
|
}
|
|
}
|