package config import ( "context" "github.com/owncloud/ocis/ocis-pkg/shared" ) // Debug defines the available debug configuration. type Debug struct { Addr string `mapstructure:"addr"` Token string `mapstructure:"token"` Pprof bool `mapstructure:"pprof"` Zpages bool `mapstructure:"zpages"` } // CORS defines the available cors configuration. type CORS struct { AllowedOrigins []string `mapstructure:"allowed_origins"` AllowedMethods []string `mapstructure:"allowed_methods"` AllowedHeaders []string `mapstructure:"allowed_headers"` AllowCredentials bool `mapstructure:"allow_credentials"` } // HTTP defines the available http configuration. type HTTP struct { Addr string `mapstructure:"addr"` Root string `mapstructure:"root"` CORS CORS `mapstructure:"cors"` } // Service defines the available service configuration. type Service struct { Name string `mapstructure:"name"` Namespace string `mapstructure:"namespace"` Version string `mapstructure:"version"` } // Tracing defines the available tracing configuration. type Tracing struct { Enabled bool `mapstructure:"enabled"` Type string `mapstructure:"type"` Endpoint string `mapstructure:"endpoint"` Collector string `mapstructure:"collector"` Service string `mapstructure:"service"` } // Config combines all available configuration parts. type Config struct { *shared.Commons File string `mapstructure:"file"` Log *shared.Log `mapstructure:"log"` Debug Debug `mapstructure:"debug"` HTTP HTTP `mapstructure:"http"` Tracing Tracing `mapstructure:"tracing"` Service Service `mapstructure:"service"` OcisPublicURL string `mapstructure:"ocis_public_url"` WebdavNamespace string `mapstructure:"webdav_namespace"` Context context.Context Supervised bool } // New initializes a new configuration with or without defaults. func New() *Config { return &Config{} } func DefaultConfig() *Config { return &Config{ Debug: Debug{ Addr: "127.0.0.1:9119", Token: "", Pprof: false, Zpages: false, }, HTTP: HTTP{ Addr: "127.0.0.1:9115", Root: "/", CORS: CORS{ AllowedOrigins: []string{"*"}, AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, AllowCredentials: true, }, }, Tracing: Tracing{ Enabled: false, Type: "jaeger", Endpoint: "", Collector: "", Service: "webdav", }, Service: Service{ Name: "webdav", Namespace: "com.owncloud.web", }, OcisPublicURL: "https://127.0.0.1:9200", WebdavNamespace: "/home", } }