package config

type WrapperConfig struct {
	Grpc             GrpcConfig              `yaml:"grpc"`
	CorePortal       CorePortalConfig        `yaml:"corePortal"`
	AllowAndLockList *AllowAndLockListConfig `yaml:"allowAndLockList"`
	Biz              BizConfig               `yaml:"biz"`
	Cors             CorsConfig              `yaml:"cors"`
}

type CorePortalConfig struct {
	CorePortalEndpoint string `yaml:"corePortalEndpoint" default:"dbaas-core-portal-server-http.nightly-ms:11000"`
}

type GrpcConfig struct {
	CorePortalAddr         string `yaml:"corePortalAddr"         default:"kubernetes:///dbaas-core-portal-server-grpc.nightly-ms:10000"`
	AccountProviderSvcAddr string `yaml:"accountProviderSvcAddr" default:"kubernetes:///account-provider-grpc.nightly-ms:10000"`
	AccountACLSvcAddr      string `yaml:"accountAclSvcAddr"      default:"kubernetes:///account-acl-grpc.nightly-ms:10000"`
	MgmtSvcAddr            string `yaml:"mgmtSvcAddr"            default:"kubernetes:///tidb-mgmt-service:10001"`
	// ServerlessGlobalAddr   string `yaml:"serverlessGlobalAddr" default:"kubernetes:///serverless-global-service:10000"` // deprecated
	DedicatedGlobalAddr string `yaml:"dedicatedGlobalAddr" default:"kubernetes:///dedicated-global-service:10000"`
	Timeout             int    `yaml:"timeout"             default:"10"`
}

type AllowAndLockListConfig struct {
	Enable         bool   `yaml:"enable"         default:"true"`
	OneConfigName  string `yaml:"oneConfigName"  default:"oneconfig-allow-lock-list/list.yaml"`
	ReloadInterval int    `yaml:"reloadInterval" default:"600"` // unit: second

	// if true, cache the allow list and lock list,
	// you can change the value of allow list and lock list in the configMap,
	// and the cache will be cleaned up after the reloadInterval
	// so should set the reloadInterval to a reasonable value
	EnableCache bool `yaml:"cache" default:"true"`
}

type BizConfig struct {
	CreateClusterV3 bool `yaml:"createClusterV3" default:"false"`
}

type CorsConfig struct {
	AllowOrigins []string `yaml:"allowOrigins"`
}
