fix ocis startup with debugging config / environment variables only

This commit is contained in:
Willy Kloucek
2022-04-28 16:28:12 +02:00
parent ed1c459d98
commit 4e531ca442
5 changed files with 40 additions and 12 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ type Config struct {
Registry string `yaml:"registry"`
TokenManager *shared.TokenManager `yaml:"token_manager"`
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY"`
TransferSecret string `yaml:"transfer_secret"`
TransferSecret string `yaml:"transfer_secret" env:"STORAGE_TRANSFER_SECRET"`
Runtime Runtime `yaml:"runtime"`
Audit *audit.Config `yaml:"audit"`
+19 -7
View File
@@ -18,7 +18,7 @@ func ParseConfig(cfg *config.Config) error {
return err
}
EnsureDefaultsAndCommons(cfg)
EnsureDefaults(cfg)
// load all env variables relevant to the config in the current context.
if err := envdecode.Decode(cfg); err != nil {
@@ -28,12 +28,27 @@ func ParseConfig(cfg *config.Config) error {
}
}
EnsureCommons(cfg)
return Validate(cfg)
}
// EnsureDefaultsAndCommons copies applicable parts of the oCIS config into the commons part
// and also ensure that all pointers in the oCIS config (not the extensions configs) are initialized
func EnsureDefaultsAndCommons(cfg *config.Config) {
// EnsureDefaults, ensures that all pointers in the
// oCIS config (not the extensions configs) are initialized
func EnsureDefaults(cfg *config.Config) {
if cfg.Tracing == nil {
cfg.Tracing = &shared.Tracing{}
}
if cfg.Log == nil {
cfg.Log = &shared.Log{}
}
if cfg.TokenManager == nil {
cfg.TokenManager = &shared.TokenManager{}
}
}
// EnsureCommons copies applicable parts of the oCIS config into the commons part
func EnsureCommons(cfg *config.Config) {
// ensure the commons part is initialized
if cfg.Commons == nil {
cfg.Commons = &shared.Commons{}
@@ -49,7 +64,6 @@ func EnsureDefaultsAndCommons(cfg *config.Config) {
}
} else {
cfg.Commons.Log = &shared.Log{}
cfg.Log = &shared.Log{}
}
// copy tracing to the commons part if set
@@ -62,7 +76,6 @@ func EnsureDefaultsAndCommons(cfg *config.Config) {
}
} else {
cfg.Commons.Tracing = &shared.Tracing{}
cfg.Tracing = &shared.Tracing{}
}
// copy token manager to the commons part if set
@@ -70,7 +83,6 @@ func EnsureDefaultsAndCommons(cfg *config.Config) {
cfg.Commons.TokenManager = cfg.TokenManager
} else {
cfg.Commons.TokenManager = &shared.TokenManager{}
cfg.TokenManager = cfg.Commons.TokenManager
}
// copy machine auth api key to the commons part if set