mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-29 17:17:55 -05:00
40 lines
958 B
Go
40 lines
958 B
Go
package parser
|
|
|
|
import (
|
|
"errors"
|
|
|
|
occfg "github.com/opencloud-eu/opencloud/pkg/config"
|
|
"github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config"
|
|
"github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config/defaults"
|
|
|
|
"github.com/opencloud-eu/opencloud/pkg/config/envdecode"
|
|
)
|
|
|
|
// ParseConfig loads configuration from known paths.
|
|
func ParseConfig(cfg *config.Config) error {
|
|
err := occfg.BindSourcesToStructs(cfg.Service.Name, cfg)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
defaults.EnsureDefaults(cfg)
|
|
|
|
// load all env variables relevant to the config in the current context.
|
|
if err := envdecode.Decode(cfg); err != nil {
|
|
// no environment variable set for this config is an expected "error"
|
|
if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// sanitize config
|
|
defaults.Sanitize(cfg)
|
|
|
|
return Validate(cfg)
|
|
}
|
|
|
|
// Validate can validate the configuration
|
|
func Validate(_ *config.Config) error {
|
|
return nil
|
|
}
|