2023-07-17 08:08:20 +00:00
|
|
|
package ready
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
2023-10-25 15:10:45 +00:00
|
|
|
internal_authz "github.com/zitadel/zitadel/internal/api/authz"
|
2023-07-17 08:08:20 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/config/hook"
|
2023-11-09 10:30:15 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/config/network"
|
2023-10-25 15:10:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2023-07-17 08:08:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Log *logging.Config
|
|
|
|
Port uint16
|
2023-11-09 10:30:15 +00:00
|
|
|
TLS network.TLS
|
2023-07-17 08:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func MustNewConfig(v *viper.Viper) *Config {
|
|
|
|
config := new(Config)
|
|
|
|
err := v.Unmarshal(config,
|
|
|
|
viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(
|
|
|
|
hook.Base64ToBytesHookFunc(),
|
|
|
|
mapstructure.StringToTimeDurationHookFunc(),
|
|
|
|
mapstructure.StringToTimeHookFunc(time.RFC3339),
|
|
|
|
mapstructure.StringToSliceHookFunc(","),
|
2023-10-25 15:10:45 +00:00
|
|
|
hook.EnumHookFunc(domain.FeatureString),
|
|
|
|
hook.EnumHookFunc(internal_authz.MemberTypeString),
|
2023-07-17 08:08:20 +00:00
|
|
|
)),
|
|
|
|
)
|
|
|
|
logging.OnError(err).Fatal("unable to read default config")
|
|
|
|
|
|
|
|
err = config.Log.SetLogger()
|
|
|
|
logging.OnError(err).Fatal("unable to set logger")
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|