package templates

import (
	"kube-forge/internal/config"
	"kube-forge/internal/resources"
	"strings"
)

var HELM_APPS_TEMPLATES = [...]string{
	"templates/helm-apps/releases/additional-modules/docker-secrets-generator.yml.tmpl",
	"templates/helm-apps/releases/additional-modules/longhorn.yml.tmpl",
	"templates/helm-apps/releases/additional-modules/cert-manager.yml.tmpl",
	"templates/helm-apps/releases/additional-modules/ingress-nginx.yml.tmpl",
	"templates/helm-apps/releases/additional-modules/secrets-store-csi-driver.yml.tmpl",
	"templates/helm-apps/releases/observability/fluent-operator.yml.tmpl",
	"templates/helm-apps/releases/observability/opentelemetry-operator.yml.tmpl",
	"templates/helm-apps/releases/observability/metrics-server.yml.tmpl",
	"templates/helm-apps/releases/observability/tempo.yml.tmpl",
	"templates/helm-apps/releases/observability/loki.yml.tmpl",
	"templates/helm-apps/releases/observability/observability.yml.tmpl",
	"templates/helm-apps/releases/registry/harbor-certificate-generator.yml.tmpl",
	"templates/helm-apps/releases/registry/harbor.yml.tmpl",
	"templates/helm-apps/releases/cicd/argo-cd.yml.tmpl",
	"templates/helm-apps/releases/cicd/argo-rollouts.yml.tmpl",
	"templates/helm-apps/releases/cicd/keel.yml.tmpl",
	"templates/helm-apps/releases/cicd/argo-cd-ingress.yml.tmpl",
	"templates/helm-apps/releases/secrets-storage/vault.yml.tmpl",
}
var HELM_REPOSITORIES_TEMPLATES = [...]string{
	"templates/helm-apps/repositories/repositories.yml.tmpl",
}

func GetHelmAppsConfigData() (string, string) {
	cfg := config.GetConfig()
	helmAppsTemplateResults := []string{}
	for _, templateFile := range HELM_APPS_TEMPLATES {
		template := getTemplateFromEmbedFSFolder(resources.Templates, templateFile)
		helmAppsTemplateResults = append(helmAppsTemplateResults, executeTemplateToString(template, cfg))
	}
	repositoriesTemplateResults := []string{}
	for _, templateFile := range HELM_REPOSITORIES_TEMPLATES {
		template := getTemplateFromEmbedFSFolder(resources.Templates, templateFile)
		repositoriesTemplateResults = append(repositoriesTemplateResults, executeTemplateToString(template, cfg))
	}
	return strings.Join(repositoriesTemplateResults, "\n"), strings.Join(helmAppsTemplateResults, "\n")
}
