package config

import "fmt"

const (
	// TODO: use image in private registry
	// RegistryPrefix is the default public docker image registry prefix
	RegistryPrefix = "gcr.io/pingcap-public/dbaas"

	// GottyImage is the name of gotty image
	GottyImage = "gotty"

	// BusyboxImage is the name of busybox image
	BusyboxImage = "busybox"

	// HealthCheckerImage is the name of tidb health-checker sidecar image
	HealthCheckerImage = "health-checker"

	// GracefulShutdownTiDBWebhookImage is the name of graceful-shutdown-tidb-webhook image
	GracefulShutdownTiDBWebhookImage = "graceful-shutdown-tidb-webhook"

	// GrafanaImage is the name of grafana image
	GrafanaImage = "grafana"

	// PrometheusImage is the name of prometheus image
	PrometheusImage = "prometheus"

	// TiDBMonitorReloaderImage is the name of tidb-monitor-reloader image
	TiDBMonitorReloaderImage = "tidb-monitor-reloader"

	// TiDBMonitorInitializerImage is the name of tidb-monitor-initializer image
	TiDBMonitorInitializerImage = "tidb-monitor-initializer"

	// TiDBBackupManagerImage is the name of tidb backup manager image
	TiDBBackupManagerImage = "tidb-backup-manager"

	// TiDBOperatorImage is the name of TiDB Operator image
	TiDBOperatorImage = "tidb-operator"

	// AdvancedStatefulsetImage is the name of AdvancedStatefulSet controller image
	AdvancedStatefulsetImage = "advanced-statefulset"
)

var (
	// GottyVersion is the version of GottyImage
	GottyVersion = "20201216"

	// BusyboxVersion is the version of BusyboxImage
	BusyboxVersion = "1.31.1"

	// HealthCheckerVersion is the version of HealthCheckerImage
	HealthCheckerVersion = "20201224"

	// GracefulShutdownTiDBWebhookVersion is the version of GracefulShutdownTiDBWebhookImage
	GracefulShutdownTiDBWebhookVersion = "20210107"

	// GrafanaVersion is the version of grafana image
	GrafanaVersion = "6.0.1"

	// PrometheusVersion is the version of prometheus image
	PrometheusVersion = "v2.11.1"

	// TiDBMonitorReloaderVersion is the version of tidb-monitor-reloader image
	TiDBMonitorReloaderVersion = "v1.0.1"

	// TiDBOperatorVersion is the version of TiDB Operator image
	TiDBOperatorVersion = "v1.2.3"

	// AdvancedStatefulsetVersion is the version of AdvancedStatefulsetImage
	AdvancedStatefulsetVersion = "v0.4.0"

	// BR status addr
	BRStatusAddr = "0.0.0.0:8089"
)

func GetImage(image, version string) string {
	return fmt.Sprintf("%s:%s", GetBaseImage(image), version)
}

func GetBaseImage(image string) string {
	return fmt.Sprintf("%s/%s", RegistryPrefix, image)
}

func GetGottyImage() string {
	return GetImage(GottyImage, GottyVersion)
}

func GetBusyboxImage() string {
	return GetImage(BusyboxImage, BusyboxVersion)
}

func GetHealthCheckerImage() string {
	return GetImage(HealthCheckerImage, HealthCheckerVersion)
}

func GetGracefulShutdownTiDBWebhookImage() string {
	return GetImage(GracefulShutdownTiDBWebhookImage, GracefulShutdownTiDBWebhookVersion)
}

func GetTiDBBackupManagerImage() string {
	return GetImage(TiDBBackupManagerImage, TiDBOperatorVersion)
}

func GetTiDBOperatorImage() string {
	return GetImage(TiDBOperatorImage, TiDBOperatorVersion)
}

func GetAdvancedStatefulsetImage() string {
	return GetImage(AdvancedStatefulsetImage, AdvancedStatefulsetVersion)
}
