package util

import (
	"strings"

	"github.com/tidbcloud/metrics-integration/pipeline/pkg/tidb/component"
)

// TODO(chenfei): opt,move to better place

// CoreComponentType2componentName converts the configured component type name
// (for example "COMPONENT_TYPE_TIDB") to a component.Name.
func CoreComponentType2componentName(tp string) (component.Name, bool) {
	switch strings.ToUpper(strings.TrimSpace(tp)) {
	case "COMPONENT_TYPE_TIDB":
		return component.TiDB, true
	case "COMPONENT_TYPE_PD":
		return component.PD, true
	case "COMPONENT_TYPE_TIKV":
		return component.TiKV, true
	case "COMPONENT_TYPE_TIFLASH":
		return component.TiFlash, true
	default:
		return "", false
	}
}
