Revert "refactor config values to constants"

This reverts commit f53504158b.
This commit is contained in:
A.Unger
2021-11-17 13:56:14 +01:00
parent f53504158b
commit a34f5b6434
5 changed files with 85 additions and 74 deletions

View File

@@ -226,6 +226,7 @@ func DefaultConfig() *Config {
OIDC: OIDC{
Issuer: "https://localhost:9200",
Insecure: true,
//Insecure: true,
UserinfoCache: Cache{
Size: 1024,
TTL: 10,
@@ -246,16 +247,15 @@ func DefaultConfig() *Config {
UserOIDCClaim: "email",
UserCS3Claim: "mail",
MachineAuthAPIKey: "change-me-please",
Context: nil,
Policies: defaultPolicies(),
//AutoprovisionAccounts: false,
//EnableBasicAuth: false,
//InsecureBackends: false,
Context: nil,
Policies: defaultPolicies(),
}
}
func defaultPolicies() []Policy {
const idpBackend = "http://localhost:9130"
const revaBackend = "http://localhost:9140"
const ingressBackendURL = "https://demo.owncloud.com"
return []Policy{
{
Name: "ocis",
@@ -266,19 +266,19 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/.well-known/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/konnect/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/signin/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/archiver",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Type: RegexRoute,
@@ -287,7 +287,7 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/ocs/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Type: QueryRoute,
@@ -296,31 +296,31 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/remote.php/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/dav/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/webdav/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/status.php",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/index.php/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/data",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/app/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/graph/",
@@ -335,6 +335,7 @@ func defaultPolicies() []Policy {
Endpoint: "/api/v0/accounts",
Backend: "http://localhost:9181",
},
// TODO the lookup needs a better mechanism
{
Endpoint: "/accounts.js",
Backend: "http://localhost:9181",
@@ -358,53 +359,53 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/.well-known/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/konnect/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/signin/",
Backend: revaBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/archiver",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/ocs/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/remote.php/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/dav/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/webdav/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/status.php",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/index.php/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/data",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
},

View File

@@ -27,12 +27,10 @@ func Server(opts ...Option) (*http.Server, error) {
), nil
}
const contentTypeHeader = "Content-Type"
// health implements the health check.
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(contentTypeHeader, "text/plain")
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running
@@ -46,7 +44,7 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
// ready implements the ready check.
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(contentTypeHeader, "text/plain")
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running

View File

@@ -518,17 +518,9 @@ func New() *Config {
return &Config{}
}
const (
defaultLocalIngressURL = "https://localhost:9200"
defaultSharesFolder = "/Shares"
defaultEOSMasterURL = "root://eos-mgm1.eoscluster.cern.ch:1094"
defaultGatewaySVCAddr = "127.0.0.1:9142"
defaultUserLayout = "{{.Id.OpaqueId}}"
)
func DefaultConfig() *Config {
return &Config{
// log is inherited
Debug: Debug{
Addr: "127.0.0.1:9109",
},
@@ -538,7 +530,7 @@ func DefaultConfig() *Config {
TransferSecret: "replace-me-with-a-transfer-secret",
TransferExpires: 24 * 60 * 60,
OIDC: OIDC{
Issuer: defaultLocalIngressURL,
Issuer: "https://localhost:9200",
Insecure: false,
IDClaim: "preferred_username",
},
@@ -559,7 +551,7 @@ func DefaultConfig() *Config {
GroupMemberFilter: "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))",
BindDN: "cn=reva,ou=sysusers,dc=ocis,dc=test",
BindPassword: "reva",
IDP: defaultLocalIngressURL,
IDP: "https://localhost:9200",
UserSchema: LDAPUserSchema{
UID: "ownclouduuid",
Mail: "mail",
@@ -585,7 +577,7 @@ func DefaultConfig() *Config {
DBHost: "mysql",
DBPort: 3306,
DBName: "owncloud",
Idp: defaultLocalIngressURL,
Idp: "https://localhost:9200",
Nobody: 90,
JoinUsername: false,
JoinOwnCloudUUID: false,
@@ -604,29 +596,29 @@ func DefaultConfig() *Config {
EOS: DriverEOS{
DriverCommon: DriverCommon{
Root: "/eos/dockertest/reva",
ShareFolder: defaultSharesFolder,
ShareFolder: "/Shares",
UserLayout: "{{substr 0 1 .Username}}/{{.Username}}",
},
ShadowNamespace: "", // Defaults to path.Join(c.Namespace, ".shadow")
UploadsNamespace: "", // Defaults to path.Join(c.Namespace, ".uploads")
EosBinary: "/usr/bin/eos",
XrdcopyBinary: "/usr/bin/xrdcopy",
MasterURL: defaultEOSMasterURL,
SlaveURL: defaultEOSMasterURL,
MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
CacheDirectory: os.TempDir(),
GatewaySVC: defaultGatewaySVCAddr,
GatewaySVC: "127.0.0.1:9142",
},
Local: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "local", "users"),
ShareFolder: defaultSharesFolder,
ShareFolder: "/Shares",
UserLayout: "{{.Username}}",
EnableHome: false,
},
OwnCloud: DriverOwnCloud{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"),
ShareFolder: defaultSharesFolder,
UserLayout: defaultUserLayout,
ShareFolder: "/Shares",
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"),
@@ -636,7 +628,7 @@ func DefaultConfig() *Config {
OwnCloudSQL: DriverOwnCloudSQL{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"),
ShareFolder: defaultSharesFolder,
ShareFolder: "/Shares",
UserLayout: "{{.Username}}",
EnableHome: false,
},
@@ -658,8 +650,8 @@ func DefaultConfig() *Config {
S3NG: DriverS3NG{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "users"),
ShareFolder: defaultSharesFolder,
UserLayout: defaultUserLayout,
ShareFolder: "/Shares",
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
Region: "default",
@@ -671,8 +663,8 @@ func DefaultConfig() *Config {
OCIS: DriverOCIS{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "users"),
ShareFolder: defaultSharesFolder,
UserLayout: defaultUserLayout,
ShareFolder: "/Shares",
UserLayout: "{{.Id.OpaqueId}}",
},
ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
},
@@ -681,7 +673,7 @@ func DefaultConfig() *Config {
EOS: DriverEOS{
DriverCommon: DriverCommon{
Root: "/eos/dockertest/reva",
ShareFolder: defaultSharesFolder,
ShareFolder: "/Shares",
UserLayout: "{{substr 0 1 .Username}}/{{.Username}}",
EnableHome: false,
},
@@ -689,9 +681,9 @@ func DefaultConfig() *Config {
UploadsNamespace: "",
EosBinary: "/usr/bin/eos",
XrdcopyBinary: "/usr/bin/xrdcopy",
MasterURL: defaultEOSMasterURL,
MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
GrpcURI: "",
SlaveURL: defaultEOSMasterURL,
SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
CacheDirectory: os.TempDir(),
EnableLogging: false,
ShowHiddenSysFiles: false,
@@ -700,7 +692,7 @@ func DefaultConfig() *Config {
SecProtocol: "",
Keytab: "",
SingleUsername: "",
GatewaySVC: defaultGatewaySVCAddr,
GatewaySVC: "127.0.0.1:9142",
},
Local: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "local", "metadata"),
@@ -715,7 +707,7 @@ func DefaultConfig() *Config {
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"),
ShareFolder: "",
UserLayout: defaultUserLayout,
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
Region: "default",
@@ -724,7 +716,7 @@ func DefaultConfig() *Config {
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"),
ShareFolder: "",
UserLayout: defaultUserLayout,
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
@@ -755,9 +747,9 @@ func DefaultConfig() *Config {
OCDavInsecure: false,
OCDavPrefix: "",
OCSPrefix: "ocs",
OCSSharePrefix: defaultSharesFolder,
OCSSharePrefix: "/Shares",
OCSHomeNamespace: "/home",
PublicURL: defaultLocalIngressURL,
PublicURL: "https://localhost:9200",
OCSCacheWarmupDriver: "",
OCSAdditionalInfoAttribute: "{{.Mail}}",
OCSResourceInfoCacheTTL: 0,
@@ -769,10 +761,10 @@ func DefaultConfig() *Config {
},
Gateway: Gateway{
Port: Port{
Endpoint: defaultGatewaySVCAddr,
Endpoint: "127.0.0.1:9142",
DebugAddr: "127.0.0.1:9143",
GRPCNetwork: "tcp",
GRPCAddr: defaultGatewaySVCAddr,
GRPCAddr: "127.0.0.1:9142",
},
CommitShareToStorageGrant: true,
CommitShareToStorageRef: true,

View File

@@ -3,6 +3,10 @@ package command
import (
"context"
gofig "github.com/gookit/config/v2"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/store/pkg/tracing"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -21,7 +25,26 @@ func Server(cfg *config.Config) *cli.Command {
Name: "server",
Usage: "Start integrated server",
Before: func(ctx *cli.Context) error {
return ParseConfig(ctx, cfg)
// remember shared logging info to prevent empty overwrites
inLog := cfg.Log
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
if (cfg.Log == shared.Log{}) && (inLog != shared.Log{}) {
// set the default to the parent config
cfg.Log = inLog
// and parse the environment
conf := &gofig.Config{}
conf.LoadOSEnv(config.GetEnv(), false)
bindings := config.StructMappings(cfg)
if err := ociscfg.BindEnv(conf, bindings); err != nil {
return err
}
}
return nil
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)

View File

@@ -6,8 +6,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/shared"
)
const defaultIngressURL = "https://localhost:9200"
// Debug defines the available debug configuration.
type Debug struct {
Addr string `mapstructure:"addr"`
@@ -108,7 +106,6 @@ func New() *Config {
}
func DefaultConfig() *Config {
return &Config{
Debug: Debug{
Addr: "127.0.0.1:9104",
@@ -134,15 +131,15 @@ func DefaultConfig() *Config {
},
Web: Web{
Path: "",
ThemeServer: defaultIngressURL,
ThemeServer: "https://localhost:9200",
ThemePath: "/themes/owncloud/theme.json",
Config: WebConfig{
Server: defaultIngressURL,
Server: "https://localhost:9200",
Theme: "",
Version: "0.1.0",
OpenIDConnect: OIDC{
MetadataURL: "",
Authority: defaultIngressURL,
Authority: "https://localhost:9200",
ClientID: "web",
ResponseType: "code",
Scope: "openid profile email",