package config

var globalConf = &CentralConfig{}

type CentralConfig struct {
	GrpcConfig   GrpcConfig   `mapstructure:"grpc"`
	ServerConfig ServerConfig `mapstructure:"server"`
	SentryConfig SentryConfig `mapstructure:"sentry"`
	MysqlConfig  MysqlConfig  `mapstructure:"mysql"`
	Oauth2Config Oauth2Config `mapstructure:"oauth2"`
}
type GrpcConfig struct {
	AccountProviderSvcAddr string `mapstructure:"accountProviderSvcAddr" default:"account-provider-grpc:10000"`
}

type ServerConfig struct {
	GrpcPort    string `mapstructure:"grpcPort" default:"10000"`
	HttpPort    string `mapstructure:"httpPort" default:"10010"`
	MetricsPort string `mapstructure:"metricsPort" default:"9090"`
	LogLevel    string `mapstructure:"logLevel" default:"info"`
	Env         string `mapstructure:"env"`
}

type SentryConfig struct {
	DSN         string `mapstructure:"dsn"`
	Environment string `mapstructure:"env"`
	LogLevel    string `mapstructure:"logLevel" default:"warn"`
}

type MysqlConfig struct {
	Host      string `mapstructure:"host"  required:"true"`
	User      string `mapstructure:"user" default:"sqleditor"`
	Port      uint   `mapstructure:"port" default:"4000"`
	Password  string `mapstructure:"password" required:"false"`
	Database  string `mapstructure:"database" default:"sqleditor"`
	CharSet   string `mapstructure:"charset"  default:"utf8mb4"`
	Collation string `mapstructure:"collation"  default:"utf8mb4_bin"`
	TimeZone  string `mapstructure:"timezone"  default:"UTC"`
}

type Oauth2Config struct {
	VerificationURI string `mapstructure:"verificationURI" default:"https://tidbcloud.com/oauth/device"`
}
