Files

39 lines
948 B
Go
Raw Permalink Normal View History

package parser
import (
"errors"
2022-05-04 14:49:59 +02:00
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
2022-06-20 16:49:06 +02:00
"github.com/owncloud/ocis/v2/services/thumbnails/pkg/config"
"github.com/owncloud/ocis/v2/services/thumbnails/pkg/config/defaults"
2022-05-04 14:49:59 +02:00
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
)
2022-04-29 20:21:14 +00:00
// ParseConfig loads configuration from known paths.
func ParseConfig(cfg *config.Config) error {
err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg)
if err != nil {
return err
}
2022-03-08 17:35:55 +01:00
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
2022-03-08 17:35:55 +01:00
defaults.Sanitize(cfg)
return Validate(cfg)
}
// Validate can validate the configuration
func Validate(_ *config.Config) error {
return nil
}