// Copyright (c) 2023 Volvo Car Corporation
// SPDX-License-Identifier: Apache-2.0

// Code generated by lingon. EDIT AS MUCH AS YOU LIKE.

package vmk8s

import (
	_ "embed"

	ku "github.com/golingon/lingon/pkg/kubeutil"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func LoadDashAsCM(
	filename, dashJSON, folder string,
	o metav1.ObjectMeta,
) *corev1.ConfigMap {
	if folder != FolderGeneral {
		o = PatchDashFolder(o, folder)
	}
	return &corev1.ConfigMap{
		TypeMeta:   ku.TypeConfigMapV1,
		ObjectMeta: PatchDashLabels(o),
		Data: map[string]string{
			filename: dashJSON,
		},
	}
}

const (
	FolderGeneral    = ""
	FolderKubernetes = "Kubernetes"
	FolderVM         = "VictoriaMetrics"
	FolderNats       = "NATS"
	FolderKarpenter  = "Karpeneter"
)

var (

	//go:embed dashboards/grafana-overview.json
	grafanaOverviewDash   string
	GrafanaOverviewDashCM = LoadDashAsCM(
		"grafana-overview.json",
		grafanaOverviewDash, FolderGeneral,
		Graf.ObjectMetaNameSuffix("dash-overview"),
	)

	// KUBERNETES

	//go:embed dashboards/k8s-views-global.json
	k8sGlobalDash        string
	DashboardK8SGlobalCM = LoadDashAsCM(
		"k8s-views-global.json",
		k8sGlobalDash, FolderKubernetes,
		Graf.ObjectMetaNameSuffix("k8s-global"),
	)

	//go:embed dashboards/k8s-views-namespaces.json
	k8sNSDash                string
	DashboardK8SNamespacesCM = LoadDashAsCM(
		"k8s-views-namespaces.json",
		k8sNSDash, FolderKubernetes,
		Graf.ObjectMetaNameSuffix("k8s-namespaces"),
	)

	//go:embed dashboards/k8s-views-pods.json
	k8sPodsDash        string
	DashboardK8SPodsCM = LoadDashAsCM(
		"k8s-views-pods.json",
		k8sPodsDash, FolderKubernetes,
		Graf.ObjectMetaNameSuffix("k8s-pods"),
	)

	//go:embed dashboards/k8s-system-coredns.json
	corednsDash        string
	CoreDNSDashboardCM = LoadDashAsCM(
		"k8s-coredns.json",
		corednsDash, FolderKubernetes,
		CDNS.ObjectMetaNameSuffix("dash"),
	)

	//go:embed dashboards/k8s-resources-node.json
	k8sResourcesNode  string
	DashboardK8sNodes = LoadDashAsCM(
		"k8s-node.json",
		k8sResourcesNode,
		FolderKubernetes,
		Graf.ObjectMetaNameSuffix("k8s-nodes"),
	)

	// VICTORIA METRICS

	//go:embed dashboards/vm-operator.json
	vmOperatorDash      string
	DashboardVMOperator = LoadDashAsCM(
		"vm-operator.json",
		vmOperatorDash, FolderVM,
		Graf.ObjectMetaNameSuffix("vm-operator-dash"),
	)

	// //go:embed dashboards/backupmanager.json
	// backupmanagerDash        string
	// DashboardBackupManagerCM = LoadDashAsCM(
	// 	"backupmanager.json",
	// 	backupmanagerDash, FolderVM,
	// 	Graf.ObjectMetaNameSuffix("backup-manager-dash"),
	// )

	//go:embed dashboards/vmagent.json
	vmAgentDash      string
	DashboardAgentCM = LoadDashAsCM(
		"vmagent.json",
		vmAgentDash, FolderVM,
		Graf.ObjectMetaNameSuffix("vmagent"),
	)

	//go:embed dashboards/alertmanager-overview.json
	alertManagerOverviewDash   string
	AlertManagerOverviewDashCM = LoadDashAsCM(
		"alertmanager-overview.json",
		alertManagerOverviewDash, FolderVM,
		AM.ObjectMetaNameSuffix("vmalert-overview-dash"),
	)

	//go:embed dashboards/vmalert.json
	alertManagerDash        string
	AlertManagerDashboardCM = LoadDashAsCM(
		"vmalert.json",
		alertManagerDash, FolderVM,
		AM.ObjectMetaNameSuffix("vmalert-dash"),
	)

	//go:embed dashboards/vmsingle.json
	victoriaMetricsDash        string
	DashboardVictoriaMetricsCM = LoadDashAsCM(
		"vmsingle.json",
		victoriaMetricsDash, FolderVM,
		Single.ObjectMetaNameSuffix("vmsingle-dash"),
	)

	// NATS

	//go:embed dashboards/nats-dash.json
	natsDash        string
	DashboardNatsCM = LoadDashAsCM(
		"nats.json",
		natsDash, FolderNats,
		Graf.ObjectMetaNameSuffix("nats-dash"),
	)

	//go:embed dashboards/nats-jetstream-dash.json
	natsJSDash        string
	DashboardNatsJSCM = LoadDashAsCM(
		"nats-jetstream.json",
		natsJSDash, FolderNats,
		Graf.ObjectMetaNameSuffix("nats-jetstream-dash"),
	)

	// KARPENTER

	//go:embed dashboards/karpenter-performance-dashboard.json
	karpenterPerfDash        string
	DashboardKarpenterPerfCM = LoadDashAsCM(
		"karpenter-performance.json",
		karpenterPerfDash, FolderKarpenter,
		Graf.ObjectMetaNameSuffix("karpenter-perf-dash"),
	)

	//go:embed dashboards/karpenter-controllers.json
	karpenterControllersDash        string
	DashboardKarpenterControllersCM = LoadDashAsCM(
		"karpenter-controllers.json",
		karpenterControllersDash, FolderKarpenter,
		Graf.ObjectMetaNameSuffix("karpenter-controller-dash"),
	)

	//go:embed dashboards/karpenter-controllers-allocation.json
	karpenterCtrlAllocationDash        string
	DashboardKarpenterCtrlAllocationCM = LoadDashAsCM(
		"karpenter-controllers-allocation.json",
		karpenterCtrlAllocationDash, FolderKarpenter,
		Graf.ObjectMetaNameSuffix("karpenter-allocation-dash"),
	)

	//go:embed dashboards/karpenter-capacity-dashboard.json
	karpenterCapacityDash        string
	DashboardKarpenterCapacityCM = LoadDashAsCM(
		"karpenter-capacity.json",
		karpenterCapacityDash, FolderKarpenter,
		Graf.ObjectMetaNameSuffix("karpenter-capacity-dash"),
	)
)
