2023-07-17 10:08:20 +02:00
|
|
|
package ready
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
2023-10-25 17:10:45 +02:00
|
|
|
internal_authz "github.com/zitadel/zitadel/internal/api/authz"
|
2023-07-17 10:08:20 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/config/hook"
|
2023-11-09 11:30:15 +01:00
|
|
|
"github.com/zitadel/zitadel/internal/config/network"
|
2023-07-17 10:08:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Log *logging.Config
|
|
|
|
Port uint16
|
2023-11-09 11:30:15 +01:00
|
|
|
TLS network.TLS
|
2023-07-17 10:08:20 +02: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 17:10:45 +02:00
|
|
|
hook.EnumHookFunc(internal_authz.MemberTypeString),
|
2023-07-17 10:08:20 +02:00
|
|
|
)),
|
|
|
|
)
|
|
|
|
logging.OnError(err).Fatal("unable to read default config")
|
|
|
|
|
|
|
|
err = config.Log.SetLogger()
|
|
|
|
logging.OnError(err).Fatal("unable to set logger")
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|