package types

const (
	// CommentSkipSetToFreeCache is used to skip setting to free cache in tidbmanager
	CommentSkipSetToFreeCache = "skip setting to free cache"
	CommentConnectionIdle     = "connection idle for too long"

	// O11yGlobalReadURL defines the o11y url environment variable
	O11yGlobalReadURL          = "O11Y_GLOBAL_READ_URL"
	O11yGlobalClusterID        = "O11Y_GLOBAL_CLUSTER_ID"
	O11yGlobalControlPlaneInfo = "O11Y_GLOBAL_CONTROL_PLANE_INFO"
	O11yGlobalVMAccountID      = "O11Y_GLOBAL_VM_ACCOUNTID"

	// TidbMinReplicas defines min replicas for tidb in infra spec.cluster.tidb.replicas
	TidbMinReplicas = 1

	// TidbResourceGroupMinReplicas defines min replicas for tidb in infra spec.cluster.tidb.resource_groups[].replicas
	TidbResourceGroupMinReplicas = 1

	// TidbMinReplicas defines min replicas for essential plan tidb in infra spec.cluster.tidb.replicas
	TidbMinReplicas_EssentialPlan = 1

	// TidbMaxIdleSeconds_EssentialPlan defines max idle seconds for essential plan
	TidbMaxIdleSeconds_EssentialPlan = 86400 // 1 days

	// MaxAbnormalTidbPods defines max abnormal tidb pods for scaler or upgrader
	MaxAbnormalTidbPods = 256 // In the worst case, abnormal pods will take {{MaxAbnormalTidbPods}} nodes.

	// ProviderTypeAWSFreeTier defines provider which provides
	// implementation of free tier infra on AWS.
	ProviderTypeAWSFreeTier = "aws-free-tier"

	ProviderTypeAliCloudFreeTier = "alicloud-free-tier"

	// KeyPrefix defines prefix of label and annotation key. (Deprecated, use ServerlessKeyPrefix instead)
	KeyPrefix = "free-tier.tidbcloud.com/"

	// ServerlessKeyPrefix defines prefix of label and annotation key for serverless.
	ServerlessKeyPrefix = "serverless.tidbcloud.com/"

	// DefaultStorageClassName defines default StorageClass for provider.
	DefaultStorageClassName = "ebs-sc"

	// S3BackupServiceAccount defines ServiceAccount name for s3 backup.
	S3BackupServiceAccount = "tidb-backup-manager"

	// AnnoKeyTidbPoolChanging defines tidb pool changing flag.
	AnnoKeyTidbPoolChanging = ServerlessKeyPrefix + "tidb-pool-changing"

	// AnnoKeyResumeEtcdToken defines resume etcd token annotation key.
	AnnoKeyResumeEtcdToken = ServerlessKeyPrefix + "resume-etcd-token"

	// GatewayService consts
	AnnoGatewayDnsName = "gateway.tidbcloud.com/dnsName"

	// Annotations for Autoscaling
	AnnoKeyTidbAutoscaling = KeyPrefix + "tidbautoscaling-time"

	// Annotations for Restore Branch Keyspace
	AnnoKeyBranchRestoreId        = KeyPrefix + "branch-restore-id"
	AnnoKeyBranchErrorAndRecreate = KeyPrefix + "branch-error-and-recreate"

	TidbServerNamePrefix    = "tidb-server-"
	TidbServerPodTemplateCm = "tidb-server-pod-template"
	TidbServerRevision      = KeyPrefix + "revision"
	TidbPoolFinalizer       = "tidb-pool.tidbcloud.com/finalizer"

	AnnoTidbScalerLock   = KeyPrefix + "scaler-lock"
	AnnoTidbPoolSelector = KeyPrefix + "tidb-pool-selector"
	AnnoTidbRuLimitMode  = KeyPrefix + "ru-limit-mode"
	AnnoTidbServicePlan  = KeyPrefix + "service-plan"

	AnnoTidbRemoveAfterRun    = ServerlessKeyPrefix + "remove-after-run"
	AnnoTidbStatusRunSlow     = ServerlessKeyPrefix + "status-run-slow"
	AnnoTidbReschedule        = ServerlessKeyPrefix + "reschedule"
	AnnoTidbCreatedByTManager = ServerlessKeyPrefix + "created-by-tidb-manager"

	CASafeToEvict   = "cluster-autoscaler.kubernetes.io/safe-to-evict"
	GoatSafeToEvict = "goatscaler.io/safe-to-evict"

	AnnoVolumeSelectedNode = "volume.kubernetes.io/selected-node"

	// NodeScoreMap defines the only name for NodeScore CR
	NodeScoreMap = "node-score-map"
	// AnnoNodeEvictCountPeriodPrefix defines the evict count prefix for node annotations
	AnnoNodeEvictCountPeriodPrefix = "evict-count-period.tidbcloud.com/"
	// AnnoNodeEvictTimestampPrefix defines the evict timestamp prefix for node annotations
	AnnoNodeEvictTimestampPrefix = "evict-timestamp.tidbcloud.com/"
	// AnnoNodeForceEvictTimestamp defines the force evict timestamp by tidbpodevicter
	AnnoNodeForceEvictTimestamp = "force-evict.tidbcloud.com/timestamp"
	// AnnoNodeScaleDownDisabledTimestamp defines the scale down disabled timestamp by tidbnodescaler
	AnnoNodeScaleDownDisabledTimestamp = "scale-down-disabled.tidbcloud.com/timestamp"
	// AnnoNodeDrainTimestamp defines the drain timestamp by nodedrainer
	AnnoNodeDrainTimestamp = "drain.tidbcloud.com/timestamp"
	// AnnoNodeRescheduleFailTimestamp defines the rescheduled fail timestamp by tidbpodrescheduler
	AnnoNodeRescheduleFailTimestamp = "reschedule-fail.tidbcloud.com/timestamp"
	// CAScaleDownDisabledKey is the name of annotation marking node as not eligible for cluster-autoscaler scale down.
	CAScaleDownDisabledKey = "cluster-autoscaler.kubernetes.io/scale-down-disabled"
	// GoatScaleDownDisabledKey is the name of annotation marking node as not eligible for goat scale down.
	GoatScaleDownDisabledKey = "goatscaler.io/scale-down-disabled"

	// Annotation for Serverless keyspace restore
	AnnoKeyKeyspaceRestore       = KeyPrefix + "keyspace-restore-status"
	AnnoKeyspaceRestoreStart     = "RestoreStart"
	AnnoKeyspaceRestartTiDB      = "RestoreRestartTiDB"
	AnnoKeyspaceRestoreFinish    = "RestoreFinish"
	AnnoKeyRestoreStartTimestamp = KeyPrefix + "restore-start-timestamp"
	// AnnoKeyRestoreToNewCluster used by restoring to new cluster
	AnnoKeyRestoreToNewCluster = KeyPrefix + "restore-to-new-cluster"
	// AnnoKeyRestoreToNewClusterWait wait for restore(executed in control plane)
	AnnoKeyRestoreToNewClusterWait = "RestoreWait"
	// AnnoKeyRestoreToNewClusterFinish restore has finished
	AnnoKeyRestoreToNewClusterFinish = "RestoreFinish"

	// Label for create from restore. The value is 'true'.
	CreateFromRestore = "tags.tidbcloud.com/create-from-restore"

	// Label for tidb that enables VPA. The value is 'true'.
	UseVPALabelKey = KeyPrefix + "use-vpa"

	// MTLSLabelKey indicates if the pod enables the TLS
	MTLSLabelKey = KeyPrefix + "mtls"

	// Labels for tidb-worker
	// KeyspaceNameLabelKey indicates the keyspace name of the tidb worker
	KeyspaceNameLabelKey = KeyPrefix + "keyspace-name"
	// TiDBPoolLabelKey indicates the tidb pool of the master of the tidb worker
	TiDBPoolLabelKey = KeyPrefix + "tidb-pool"
	// JobTypeLabelKey indicates the job type of the tidb worker
	JobTypeLabelKey = KeyPrefix + "job-type"
	// RevisionLabelKey indicates the revision of the tidb worker
	RevisionLabelKey = KeyPrefix + "revision"
	// WorkerLabelKey indicates the worker of the tidb worker
	WorkerLabelKey = KeyPrefix + "worker"
	// WorkerPoolLabelKey indicates the worker pool of the tidb worker
	WorkerPoolLabelKey = KeyPrefix + "worker-pool"

	// Annotation for export
	AnnoExportCancel           = KeyPrefix + "export-cancel"
	AnnoExportEtcdKey          = KeyPrefix + "export-etcd-key"
	AnnoExportResourceGroup    = KeyPrefix + "export-resource-group"
	AnnoExportTiDBPod          = KeyPrefix + "export-tidb-pod"
	AnnoExportDumplingJob      = KeyPrefix + "export-dumpling-job"
	AnnoExportJobStatus        = KeyPrefix + "export-job-status"
	AnnoExportJobFailedMessage = KeyPrefix + "export-job-failed-message"
	AnnoExportMetering         = KeyPrefix + "export-metering"
	AnnoExportConsoleMetric    = KeyPrefix + "export-console-metric"
	AnnoExportFinishTime       = KeyPrefix + "export-finish-time"
	AnnoExportMeta             = "export.tidbcloud.com/metadata"
	AnnoExportSuperVip         = "export.tidbcloud.com/super-vip"
	AnnoExportType             = KeyPrefix + "export-type"
	AnnoExportSendToMetering   = KeyPrefix + "export-send-to-metering"
	LabelJobType               = KeyPrefix + "job-type"
	LabelJobName               = "batch.kubernetes.io/job-name"
	LabelKeyProviderType       = "cloud.pingcap.com/provider-type"
	LabelKeyRegion             = "cloud.pingcap.com/region"

	PreventCAScaleUpTaintKey = ServerlessKeyPrefix + "prevent-ca-scale-up"

	StatusTaintClusterAutoscalerPrefix = "status-taint.cluster-autoscaler.kubernetes.io/"
	ZoneRedundantEvicterTaintKey       = StatusTaintClusterAutoscalerPrefix + "zr-evicter"
	RebalanceSignalTaintKey            = StatusTaintClusterAutoscalerPrefix + "rebalance-signal"

	// Annotations for rcu config
	AnnoKeyPrevMinRCU    = KeyPrefix + "prev-min-rcu"
	AnnoKeyPrevMaxRCU    = KeyPrefix + "prev-max-rcu"
	AnnoKeyPrevRuVersion = KeyPrefix + "prev-ru-version"

	// Annotations for customer alert config
	AnnoKeyEnableCustomerAlert     = KeyPrefix + "enable-customer-alert"
	AnnoKeyPrevEnableCustomerAlert = KeyPrefix + "prev-enable-customer-alert"

	KeyspaceNameLabel = "tags.tidbcloud.com/keyspace-name"
)

type ExportMeta struct {
	ID               string `json:"id,omitempty"`
	TenantID         string `json:"tenant-id,omitempty"`
	ProjectID        string `json:"project-id,omitempty"`
	ClusterID        string `json:"cluster-id,omitempty"`
	CreatedBy        string `json:"created-by,omitempty"`
	KeyspaceToken    string `json:"keyspace-token,omitempty"`
	KeyspaceID       uint32 `json:"keyspace-id,omitempty"`
	TiDBPoolSelector string `json:"tidb-pool-selector,omitempty"`
}
