package consts

const (
	ProviderTypeLabel = "cloud.pingcap.com/provider-type"
	RegionLabel       = "cloud.pingcap.com/region"
	TenantLabel       = "cloud.pingcap.com/tenant"

	CrossplaneProviderConfigLabel = "crossplane.io/provider-config"

	// namespace type label for network policy filter
	LabelKeyNamespaceType = "cloud.pingcap.com/namespace-type"
	// it means that namespace is for customer's tidb
	LabelValNamespaceTypeTiDB = "tidb"

	// OverProvisioningComponentLabelValue is used as the value of `ComponentLabelKey` for over-provisioning pods
	OverProvisioningComponentLabelValue string = "over-provisioning"
	// OverProvisioningComponentLabelKey is used as the component type key for over-provisioning pods
	// It's value is just like `ComponentLabelKey`
	OverProvisioningComponentLabelKey string = "over-provisioning.infra.pingcap.com/component"

	// OverProvisioningUsedForLabelKey represents what this over provision deployment is used for
	OverProvisioningUsedForLabelKey string = "over-provisioning.infra.pingcap.com/used-for"
	// OverProvisioningUsedForStandbyNode represents this over provision deployment is used for creating standby nodes
	OverProvisioningUsedForStandbyNode string = "standby-node"

	// TagLabelPrefix is a label namespace for tagging resources, all labels started under this domain will be
	// used as the resource tag if possible
	// e.g. `tags.tidbcloud.com/tenant: 123` will tag all the resources belonged to the API object with `tenant: 123`
	TagLabelPrefix      = "tags.tidbcloud.com/"
	ClusterLabelKey     = "tags.tidbcloud.com/cluster"
	TenantLabelKey      = "tags.tidbcloud.com/tenant"
	SharedPoolLabelKey  = "tags.tidbcloud.com/shared-pool" // shared pool OR resource pool
	ServiceTypeLabelKey = "tags.tidbcloud.com/servicetype"
	ProjectLabelKey     = "tags.tidbcloud.com/project"
	DataplaneLabelKey   = "tags.tidbcloud.com/dataplane-id"
	BucketLabelKey      = "tags.tidbcloud.com/bucket-id"
	TiDBGroupLabelKey   = "tags.tidbcloud.com/tidb-group"
	// business type label for o11y cluster CR
	LabelO11yBizType = "tags.tidbcloud.com/biztype"

	// BR
	BackupModeLabelKey = "tags.tidbcloud.com/backupmode"

	// Cluster Server Label
	ClusterServerCreatorLabelKey   = "creator"
	ClusterServerCreatorLabelValue = "cluster-controller-server"

	NodeGroupZonesLabelKey = "tidbcloud-nodegroup-zones"

	ClusterNameLabelKey         = "cluster.cloud.pingcap.com/name"
	ClusterNamespaceLabelKey    = "cluster.cloud.pingcap.com/namespace"
	ClusterTicdcLabelKey        = "cluster.cloud.pingcap.com/cdcname"
	ClusterNetworkLabelKey      = "cluster.cloud.pingcap.com/networkname"
	UpstreamClusterNameLabelKey = "cluster.cloud.pingcap.com/upstreamcluster"

	// Used to distinguish nodegroup(nodepool) type in cloud, control-plane or data-plane
	// The key is the same on both aws and gcp
	LabelKeyNodeGroupType             = "cloud.pingcap.com/node-group-type"
	LabelValNodeGroupTypeControlPlane = "control-plane"
	LabelValNodeGroupTypeDataPlane    = "data-plane"

	// Label of k8s node version
	K8sVersionLabelKey = "tidbcloud.com/node-pool-k8s-version"

	// LabelKeyFor3LayerArch means this resource is for 3 layer arch
	// Now it's only used in nodepool and some workloads' nodeSelector(e.g. tc)
	LabelKeyFor3LayerArch = "cloud.pingcap.com/for-3-layer-arch"
	LabelValTrue          = "true"

	// KeyPrefix defines prefix of label and annotation key.
	KeyPrefix = "infra.tidbcloud.com/"

	LabelKeyUID       = KeyPrefix + "uid"
	LabelKeyOwnedBy   = KeyPrefix + "owned-by"
	LabelKeyNamespace = KeyPrefix + "namespace"
	LabelKeyName      = KeyPrefix + "name"

	GardenerWorkerNodeLabelName   = "gardener.wg.name"
	GardenerWorkerPrefixLabelName = "gardener.wg.prefix.name"
	GardenerNodeAvailableZoneInfo = "gardener.node.az.info"
	GardenerNodeInstanceType      = "gardener.node.machine.type"

	tidbCloudPrefix = "tidbcloud.com/"

	// NodePool Related Labels
	LabelKeyHasLocalDisk  = tidbCloudPrefix + "has-local-disk"
	LabelKeyLocalDiskSize = tidbCloudPrefix + "local-disk-size"

	LabelKeyFastDiskNode = "fast-disk-node"

	LabelKeyNodeSpec        = "node-spec"
	LabelKeyComponent       = tidbCloudPrefix + "component"
	LabelValComponentShared = "shared"
	LabelValComponentO11y   = "o11y"
)

// IsPlatformManagedNodeComponent reports whether the node component label identifies an
// APPBox-managed platform pool (admin/shared or dedicated o11y), as opposed to a TiDB worker pool.
// Platform pools share APPBox lifecycle (in-place k8s version updates) and must not be counted
// or deleted as blue/green worker node pools during K8s upgrades.
func IsPlatformManagedNodeComponent(component string) bool {
	return component == LabelValComponentShared || component == LabelValComponentO11y
}
