mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
split **/pkg/config/config.go up to multiple files
This commit is contained in:
@@ -1,46 +1,23 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
import "context"
|
||||
|
||||
// Debug defines the available debug configuration.
|
||||
type Debug struct {
|
||||
Addr string `ocisConfig:"addr" env:"WEB_DEBUG_ADDR"`
|
||||
Token string `ocisConfig:"token" env:"WEB_DEBUG_TOKEN"`
|
||||
Pprof bool `ocisConfig:"pprof" env:"WEB_DEBUG_PPROF"`
|
||||
Zpages bool `ocisConfig:"zpages" env:"WEB_DEBUG_ZPAGES"`
|
||||
}
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
Service Service
|
||||
|
||||
// HTTP defines the available http configuration.
|
||||
type HTTP struct {
|
||||
Addr string `ocisConfig:"addr" env:"WEB_HTTP_ADDR"`
|
||||
Namespace string
|
||||
Root string `ocisConfig:"root" env:"WEB_HTTP_ROOT"`
|
||||
CacheTTL int `ocisConfig:"cache_ttl" env:"WEB_CACHE_TTL"`
|
||||
}
|
||||
Tracing Tracing `ocisConfig:"tracing"`
|
||||
Log Log `ocisConfig:"log"`
|
||||
Debug Debug `ocisConfig:"debug"`
|
||||
|
||||
// Service defines the available service configuration.
|
||||
type Service struct {
|
||||
Name string
|
||||
Version string
|
||||
}
|
||||
HTTP HTTP `ocisConfig:"http"`
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;WEB_TRACING_ENABLED"`
|
||||
Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEB_TRACING_TYPE"`
|
||||
Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEB_TRACING_ENDPOINT"`
|
||||
Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEB_TRACING_COLLECTOR"`
|
||||
Service string `ocisConfig:"service" env:"WEB_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name?
|
||||
}
|
||||
Asset Asset `ocisConfig:"asset"`
|
||||
File string `ocisConfig:"file" env:"WEB_UI_CONFIG"` // TODO: rename this to a more self explaining string
|
||||
Web Web `ocisConfig:"web"`
|
||||
|
||||
// Log defines the available log configuration.
|
||||
type Log struct {
|
||||
Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;WEB_LOG_LEVEL"`
|
||||
Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;WEB_LOG_PRETTY"`
|
||||
Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;WEB_LOG_COLOR"`
|
||||
File string `mapstructure:"file" env:"OCIS_LOG_FILE;WEB_LOG_FILE"`
|
||||
Context context.Context
|
||||
Supervised bool
|
||||
}
|
||||
|
||||
// Asset defines the available asset configuration.
|
||||
@@ -95,69 +72,3 @@ type Web struct {
|
||||
ThemePath string `ocisConfig:"theme_path" env:"WEB_UI_THEME_PATH"` // used to build Theme in WebConfig
|
||||
Config WebConfig `ocisConfig:"config"`
|
||||
}
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
Service Service `ocisConfig:"service"`
|
||||
|
||||
Tracing Tracing `ocisConfig:"tracing"`
|
||||
Log Log `ocisConfig:"log"`
|
||||
Debug Debug `ocisConfig:"debug"`
|
||||
|
||||
HTTP HTTP `ocisConfig:"http"`
|
||||
|
||||
Asset Asset `ocisConfig:"asset"`
|
||||
File string `ocisConfig:"file" env:"WEB_UI_CONFIG"` // TODO: rename this to a more self explaining string
|
||||
Web Web `ocisConfig:"web"`
|
||||
|
||||
Context context.Context
|
||||
Supervised bool
|
||||
}
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Debug: Debug{
|
||||
Addr: "127.0.0.1:9104",
|
||||
Token: "",
|
||||
Pprof: false,
|
||||
Zpages: false,
|
||||
},
|
||||
HTTP: HTTP{
|
||||
Addr: "127.0.0.1:9100",
|
||||
Root: "/",
|
||||
Namespace: "com.owncloud.web",
|
||||
CacheTTL: 604800, // 7 days
|
||||
},
|
||||
Service: Service{
|
||||
Name: "web",
|
||||
},
|
||||
Tracing: Tracing{
|
||||
Enabled: false,
|
||||
Type: "jaeger",
|
||||
Endpoint: "",
|
||||
Collector: "",
|
||||
Service: "web",
|
||||
},
|
||||
Asset: Asset{
|
||||
Path: "",
|
||||
},
|
||||
Web: Web{
|
||||
Path: "",
|
||||
ThemeServer: "https://localhost:9200",
|
||||
ThemePath: "/themes/owncloud/theme.json",
|
||||
Config: WebConfig{
|
||||
Server: "https://localhost:9200",
|
||||
Theme: "",
|
||||
Version: "0.1.0",
|
||||
OpenIDConnect: OIDC{
|
||||
MetadataURL: "",
|
||||
Authority: "https://localhost:9200",
|
||||
ClientID: "web",
|
||||
ResponseType: "code",
|
||||
Scope: "openid profile email",
|
||||
},
|
||||
Apps: []string{"files", "search", "media-viewer", "external"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
9
web/pkg/config/debug.go
Normal file
9
web/pkg/config/debug.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// Debug defines the available debug configuration.
|
||||
type Debug struct {
|
||||
Addr string `ocisConfig:"addr" env:"WEB_DEBUG_ADDR"`
|
||||
Token string `ocisConfig:"token" env:"WEB_DEBUG_TOKEN"`
|
||||
Pprof bool `ocisConfig:"pprof" env:"WEB_DEBUG_PPROF"`
|
||||
Zpages bool `ocisConfig:"zpages" env:"WEB_DEBUG_ZPAGES"`
|
||||
}
|
||||
49
web/pkg/config/defaultconfig.go
Normal file
49
web/pkg/config/defaultconfig.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package config
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Debug: Debug{
|
||||
Addr: "127.0.0.1:9104",
|
||||
Token: "",
|
||||
Pprof: false,
|
||||
Zpages: false,
|
||||
},
|
||||
HTTP: HTTP{
|
||||
Addr: "127.0.0.1:9100",
|
||||
Root: "/",
|
||||
Namespace: "com.owncloud.web",
|
||||
CacheTTL: 604800, // 7 days
|
||||
},
|
||||
Service: Service{
|
||||
Name: "web",
|
||||
},
|
||||
Tracing: Tracing{
|
||||
Enabled: false,
|
||||
Type: "jaeger",
|
||||
Endpoint: "",
|
||||
Collector: "",
|
||||
Service: "web",
|
||||
},
|
||||
Asset: Asset{
|
||||
Path: "",
|
||||
},
|
||||
Web: Web{
|
||||
Path: "",
|
||||
ThemeServer: "https://localhost:9200",
|
||||
ThemePath: "/themes/owncloud/theme.json",
|
||||
Config: WebConfig{
|
||||
Server: "https://localhost:9200",
|
||||
Theme: "",
|
||||
Version: "0.1.0",
|
||||
OpenIDConnect: OIDC{
|
||||
MetadataURL: "",
|
||||
Authority: "https://localhost:9200",
|
||||
ClientID: "web",
|
||||
ResponseType: "code",
|
||||
Scope: "openid profile email",
|
||||
},
|
||||
Apps: []string{"files", "search", "media-viewer", "external"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
9
web/pkg/config/http.go
Normal file
9
web/pkg/config/http.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// HTTP defines the available http configuration.
|
||||
type HTTP struct {
|
||||
Addr string `ocisConfig:"addr" env:"WEB_HTTP_ADDR"`
|
||||
Namespace string
|
||||
Root string `ocisConfig:"root" env:"WEB_HTTP_ROOT"`
|
||||
CacheTTL int `ocisConfig:"cache_ttl" env:"WEB_CACHE_TTL"`
|
||||
}
|
||||
9
web/pkg/config/log.go
Normal file
9
web/pkg/config/log.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// Log defines the available log configuration.
|
||||
type Log struct {
|
||||
Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;WEB_LOG_LEVEL"`
|
||||
Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;WEB_LOG_PRETTY"`
|
||||
Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;WEB_LOG_COLOR"`
|
||||
File string `mapstructure:"file" env:"OCIS_LOG_FILE;WEB_LOG_FILE"`
|
||||
}
|
||||
7
web/pkg/config/service.go
Normal file
7
web/pkg/config/service.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package config
|
||||
|
||||
// Service defines the available service configuration.
|
||||
type Service struct {
|
||||
Name string
|
||||
Version string
|
||||
}
|
||||
10
web/pkg/config/tracing.go
Normal file
10
web/pkg/config/tracing.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package config
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;WEB_TRACING_ENABLED"`
|
||||
Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEB_TRACING_TYPE"`
|
||||
Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEB_TRACING_ENDPOINT"`
|
||||
Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEB_TRACING_COLLECTOR"`
|
||||
Service string `ocisConfig:"service" env:"WEB_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name?
|
||||
}
|
||||
Reference in New Issue
Block a user