package helm_client

import (
	"kube-forge/internal/config"

	"helm.sh/helm/v3/pkg/repo"
)

func AddHelmRepo(namespace string, repoSettings config.RepoSettings) {
	helmClient := config.GetHelmClient(namespace)
	chartRepo := repo.Entry{
		Name:     repoSettings.Name,
		URL:      repoSettings.URL,
		Username: repoSettings.Username,
		Password: repoSettings.Password,
	}

	if err := helmClient.AddOrUpdateChartRepo(chartRepo); err != nil {
		panic(err)
	}
}

func AddHelmRepos(namespace string, helmRepos []config.RepoSettings) {
	for _, repoSettings := range helmRepos {
		AddHelmRepo(namespace, repoSettings)
	}
}
