I wondered if anyone had ever successfully used the Go Helm provider. I’ve been in a very frustrating day trying to get my Argo-CD helm chart to download and install using the go helm provider:
https://pkg.go.dev/github.com/mittwald/go-helm-client#ChartSpec
I have this code. I got some of it from Stack Overflow. (I’ve tried stuff that’s commented out, and I end up at the same spot each time.)
package main
import (
"fmt"
"os"
//helmclient "github.com/mittwald/go-helm-client"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/kube"
_ "k8s.io/client-go/plugin/pkg/client/auth"
)
func main() {
//chartname := "argo-cd"
mychartOptions := &action.ChartPathOptions{
RepoURL: "https://argoproj.github.io/argo-helm",
Version: "6.9.1",
}
//var outputBuffer bytes.Buffer
settings := cli.New()
/*
opt := &helmclient.Options{
Namespace: "argo-cd", // Change this to the namespace you wish the client to operate in.
RepositoryCache: "/tmp/.helmcache",
RepositoryConfig: "/tmp/.helmrepo",
Debug: true,
Linting: true,
DebugLog: func(format string, v ...interface{}) {},
Output: &outputBuffer, // Not mandatory, leave open for default os.Stdout
}
*/
//myHelmClient, err := helmclient.New(opt)
//if err != nil {
// panic(err)
//}
//myHelmChart, _, err := myHelmClient.GetChart(chartname, mychartOptions)
//if err != nil {
// panic(err)
//}
getChart, err := action.NewPull().LocateChart(mychartOptions.RepoURL, settings)
if err != nil {
panic(err)
}
//chartPath := myHelmChart.ChartFullPath()
//myChartName := myHelmChart.Name()
//fmt.Printf("%vn", chartPath)
//fmt.Printf("%vn", myChartName)
fmt.Printf("%vn", getChart)
chart, err := loader.Load(getChart)
if err != nil {
panic(err)
}
kubeconfigPath := "C:\Users\jcontent\.kube\config"
releaseName := "argo-cd"
releaseNamespace := "argo-cd"
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(kubeconfigPath, "", releaseNamespace), releaseNamespace, os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
fmt.Sprintf(format, v)
}); err != nil {
panic(err)
}
iCli := action.NewInstall(actionConfig)
iCli.Namespace = releaseNamespace
iCli.ReleaseName = releaseName
rel, err := iCli.Run(chart, nil)
if err != nil {
panic(err)
}
fmt.Println("Successfully installed release: ", rel.Name)
}
Yet all I keep getting to is this error no matter what I try when trying to download the helm chart and put it into a helm repo.
panic: file 'C:UsersjcontentAppDataLocalTemphelmrepositoryargo-helm' does not appear to be a gzipped archive; got 'text/html; charset=utf-8'
goroutine 1 [running]:
main.main()
C:/DevOps/argo-cd-demo/deployHelm/deployhelm.go:56 +0x2ee
exit status 2
I’m trying to download the helm chart using various helm Go libraries. The Stackoverflow page that I’ve looked at is Samples on kubernetes helm golang client
Yet I can’t get any examples to work when you try and download the helm chart dynamically.
Any help would be amazing at this point, as I want to throw my machine out the window.