mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-30 07:49:41 -05:00
split **/pkg/config/config.go up to multiple files
This commit is contained in:
+13
-115
@@ -2,58 +2,26 @@ package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
|
||||
)
|
||||
|
||||
// Debug defines the available debug configuration.
|
||||
type Debug struct {
|
||||
Addr string `ocisConfig:"addr" env:"GLAUTH_DEBUG_ADDR"`
|
||||
Token string `ocisConfig:"token" env:"GLAUTH_DEBUG_TOKEN"`
|
||||
Pprof bool `ocisConfig:"pprof" env:"GLAUTH_DEBUG_PPROF"`
|
||||
Zpages bool `ocisConfig:"zpages" env:"GLAUTH_DEBUG_ZPAGES"`
|
||||
}
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
Service Service
|
||||
|
||||
// Service defines the available service configuration.
|
||||
type Service struct {
|
||||
Name string
|
||||
Version string
|
||||
}
|
||||
Tracing Tracing `ocisConfig:"tracing"`
|
||||
Log Log `ocisConfig:"log"`
|
||||
Debug Debug `ocisConfig:"debug"`
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GLAUTH_TRACING_ENABLED"`
|
||||
Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GLAUTH_TRACING_TYPE"`
|
||||
Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GLAUTH_TRACING_ENDPOINT"`
|
||||
Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GLAUTH_TRACING_COLLECTOR"`
|
||||
Service string `ocisConfig:"service" env:"GLAUTH_TRACING_SERVICE"` // TODO:
|
||||
}
|
||||
Ldap Ldap `ocisConfig:"ldap"`
|
||||
Ldaps Ldaps `ocisConfig:"ldaps"`
|
||||
|
||||
// Log defines the available log configuration.
|
||||
type Log struct {
|
||||
Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GLAUTH_LOG_LEVEL"`
|
||||
Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GLAUTH_LOG_PRETTY"`
|
||||
Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GLAUTH_LOG_COLOR"`
|
||||
File string `mapstructure:"file" env:"OCIS_LOG_FILE;GLAUTH_LOG_FILE"`
|
||||
}
|
||||
Backend Backend `ocisConfig:"backend"`
|
||||
Fallback FallbackBackend `ocisConfig:"fallback"`
|
||||
|
||||
// Ldap defined the available LDAP configuration.
|
||||
type Ldap struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAP_ENABLED"`
|
||||
Addr string `ocisConfig:"addr" env:"GLAUTH_LDAP_ADDR"`
|
||||
Namespace string
|
||||
}
|
||||
RoleBundleUUID string `ocisConfig:"role_bundle_uuid" env:"GLAUTH_ROLE_BUNDLE_ID"`
|
||||
|
||||
// Ldaps defined the available LDAPS configuration.
|
||||
type Ldaps struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAPS_ENABLED"`
|
||||
Addr string `ocisConfig:"addr" env:"GLAUTH_LDAPS_ADDR"`
|
||||
Namespace string
|
||||
Cert string `ocisConfig:"cert" env:"GLAUTH_LDAPS_CERT"`
|
||||
Key string `ocisConfig:"key" env:"GLAUTH_LDAPS_KEY"`
|
||||
Context context.Context
|
||||
Supervised bool
|
||||
}
|
||||
|
||||
// Backend defined the available backend configuration.
|
||||
@@ -79,73 +47,3 @@ type FallbackBackend struct {
|
||||
SSHKeyAttr string `ocisConfig:"ssh_key_attr" env:"GLAUTH_FALLBACK_SSH_KEY_ATTR"`
|
||||
UseGraphAPI bool `ocisConfig:"use_graph_api" env:"GLAUTH_FALLBACK_USE_GRAPHAPI"`
|
||||
}
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
*shared.Commons
|
||||
|
||||
Service Service `ocisConfig:"service"`
|
||||
|
||||
Tracing Tracing `ocisConfig:"tracing"`
|
||||
Log Log `ocisConfig:"log"`
|
||||
Debug Debug `ocisConfig:"debug"`
|
||||
|
||||
Ldap Ldap `ocisConfig:"ldap"`
|
||||
Ldaps Ldaps `ocisConfig:"ldaps"`
|
||||
|
||||
Backend Backend `ocisConfig:"backend"`
|
||||
Fallback FallbackBackend `ocisConfig:"fallback"`
|
||||
|
||||
RoleBundleUUID string `ocisConfig:"role_bundle_uuid" env:"GLAUTH_ROLE_BUNDLE_ID"`
|
||||
|
||||
Context context.Context
|
||||
Supervised bool
|
||||
}
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Debug: Debug{
|
||||
Addr: "127.0.0.1:9129",
|
||||
},
|
||||
Tracing: Tracing{
|
||||
Type: "jaeger",
|
||||
Service: "glauth",
|
||||
},
|
||||
Service: Service{
|
||||
Name: "glauth",
|
||||
},
|
||||
Ldap: Ldap{
|
||||
Enabled: true,
|
||||
Addr: "127.0.0.1:9125",
|
||||
Namespace: "com.owncloud.ldap",
|
||||
},
|
||||
Ldaps: Ldaps{
|
||||
Enabled: true,
|
||||
Addr: "127.0.0.1:9126",
|
||||
Namespace: "com.owncloud.ldaps",
|
||||
Cert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"),
|
||||
Key: path.Join(defaults.BaseDataPath(), "ldap", "ldap.key"),
|
||||
},
|
||||
Backend: Backend{
|
||||
Datastore: "accounts",
|
||||
BaseDN: "dc=ocis,dc=test",
|
||||
Insecure: false,
|
||||
NameFormat: "cn",
|
||||
GroupFormat: "ou",
|
||||
Servers: nil,
|
||||
SSHKeyAttr: "sshPublicKey",
|
||||
UseGraphAPI: true,
|
||||
},
|
||||
Fallback: FallbackBackend{
|
||||
Datastore: "",
|
||||
BaseDN: "dc=ocis,dc=test",
|
||||
Insecure: false,
|
||||
NameFormat: "cn",
|
||||
GroupFormat: "ou",
|
||||
Servers: nil,
|
||||
SSHKeyAttr: "sshPublicKey",
|
||||
UseGraphAPI: true,
|
||||
},
|
||||
RoleBundleUUID: "71881883-1768-46bd-a24d-a356a2afdf7f", // BundleUUIDRoleAdmin
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// Debug defines the available debug configuration.
|
||||
type Debug struct {
|
||||
Addr string `ocisConfig:"addr" env:"GLAUTH_DEBUG_ADDR"`
|
||||
Token string `ocisConfig:"token" env:"GLAUTH_DEBUG_TOKEN"`
|
||||
Pprof bool `ocisConfig:"pprof" env:"GLAUTH_DEBUG_PPROF"`
|
||||
Zpages bool `ocisConfig:"zpages" env:"GLAUTH_DEBUG_ZPAGES"`
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
|
||||
)
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Debug: Debug{
|
||||
Addr: "127.0.0.1:9129",
|
||||
},
|
||||
Tracing: Tracing{
|
||||
Type: "jaeger",
|
||||
Service: "glauth",
|
||||
},
|
||||
Service: Service{
|
||||
Name: "glauth",
|
||||
},
|
||||
Ldap: Ldap{
|
||||
Enabled: true,
|
||||
Addr: "127.0.0.1:9125",
|
||||
Namespace: "com.owncloud.ldap",
|
||||
},
|
||||
Ldaps: Ldaps{
|
||||
Enabled: true,
|
||||
Addr: "127.0.0.1:9126",
|
||||
Namespace: "com.owncloud.ldaps",
|
||||
Cert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"),
|
||||
Key: path.Join(defaults.BaseDataPath(), "ldap", "ldap.key"),
|
||||
},
|
||||
Backend: Backend{
|
||||
Datastore: "accounts",
|
||||
BaseDN: "dc=ocis,dc=test",
|
||||
Insecure: false,
|
||||
NameFormat: "cn",
|
||||
GroupFormat: "ou",
|
||||
Servers: nil,
|
||||
SSHKeyAttr: "sshPublicKey",
|
||||
UseGraphAPI: true,
|
||||
},
|
||||
Fallback: FallbackBackend{
|
||||
Datastore: "",
|
||||
BaseDN: "dc=ocis,dc=test",
|
||||
Insecure: false,
|
||||
NameFormat: "cn",
|
||||
GroupFormat: "ou",
|
||||
Servers: nil,
|
||||
SSHKeyAttr: "sshPublicKey",
|
||||
UseGraphAPI: true,
|
||||
},
|
||||
RoleBundleUUID: "71881883-1768-46bd-a24d-a356a2afdf7f", // BundleUUIDRoleAdmin
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package config
|
||||
|
||||
// Ldap defines the available LDAP configuration.
|
||||
type Ldap struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAP_ENABLED"`
|
||||
Addr string `ocisConfig:"addr" env:"GLAUTH_LDAP_ADDR"`
|
||||
Namespace string
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package config
|
||||
|
||||
// Ldaps defined the available LDAPS configuration.
|
||||
type Ldaps struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAPS_ENABLED"`
|
||||
Addr string `ocisConfig:"addr" env:"GLAUTH_LDAPS_ADDR"`
|
||||
Namespace string
|
||||
Cert string `ocisConfig:"cert" env:"GLAUTH_LDAPS_CERT"`
|
||||
Key string `ocisConfig:"key" env:"GLAUTH_LDAPS_KEY"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// Log defines the available log configuration.
|
||||
type Log struct {
|
||||
Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GLAUTH_LOG_LEVEL"`
|
||||
Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GLAUTH_LOG_PRETTY"`
|
||||
Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GLAUTH_LOG_COLOR"`
|
||||
File string `mapstructure:"file" env:"OCIS_LOG_FILE;GLAUTH_LOG_FILE"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package config
|
||||
|
||||
// Service defines the available service configuration.
|
||||
type Service struct {
|
||||
Name string
|
||||
Version string
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package config
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GLAUTH_TRACING_ENABLED"`
|
||||
Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GLAUTH_TRACING_TYPE"`
|
||||
Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GLAUTH_TRACING_ENDPOINT"`
|
||||
Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GLAUTH_TRACING_COLLECTOR"`
|
||||
Service string `ocisConfig:"service" env:"GLAUTH_TRACING_SERVICE"` // TODO:
|
||||
}
|
||||
Reference in New Issue
Block a user