package service

import (
	cloudv1 "github.com/tidbcloud/infra-api/api/v1"
	"k8s.io/apimachinery/pkg/labels"
)

// buildLabelsForCreatingTiCDC add the labels need when create the cr.
func buildLabelsForCreatingTiCDC(infraProviderType, region, cid string) map[string]string {
	labelMap := make(map[string]string)
	labelMap[cloudv1.LabelServiceType] = cloudv1.ServiceTypeDedicated
	labelMap[cloudv1.ProviderTypeLabel] = infraProviderType
	labelMap[cloudv1.RegionLabel] = region
	labelMap["creator"] = "ticdc-service-server"
	labelMap[cloudv1.ClusterTagKey] = cid
	return labelMap
}

// buildLabelSetForQuery builds the label set for querying the cdc related resources. like TiCDCSinkEndpoint, TiCDC etc.
// projectId, tenantId, clusterID are the filter conditions only if they are not empty.
func buildLabelSetForQuery(clusterID string) labels.Set {
	labelSet := labels.Set{}
	if clusterID != "" {
		labelSet[cloudv1.ClusterTagKey] = clusterID
	}
	return labelSet
}
