You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Helm is built on top of kubernetes and doesn't actually create kubernetes objects. In order to read helm info we will need to use the helm Go libraries: https://pkg.go.dev/helm.sh/helm
GPT-4 suggests that we can query helm releases as follows:
package main
import (
"log""os""helm.sh/helm/v3/pkg/action""helm.sh/helm/v3/pkg/cli""k8s.io/client-go/tools/clientcmd""fmt"
)
funcmain() {
helmDriver:=os.Getenv("HELM_DRIVER")
settings:=cli.New()
actionConfig:=new(action.Configuration)
kubeconfig:=clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
clientcmd.NewDefaultClientConfigLoadingRules(),
&clientcmd.ConfigOverrides{},
)
namespace, _, _:=kubeconfig.Namespace()
err:=actionConfig.Init(settings.RESTClientGetter(), namespace, helmDriver, func(formatstring, v...interface{}) {
fmt.Sprintf(format, v)
})
iferr!=nil {
log.Fatalf("Failed to connect to Kubernetes: %v", err)
}
// create a new List actionlistAction:=action.NewList(actionConfig)
// set the namespace if needed - default it's "", which lists releases across all namespaceslistAction.AllNamespaces=true// retrieve releasesreleases, err:=listAction.Run()
iferr!=nil {
log.Fatalf("Failed to retrieve releases: %v", err)
}
// print release namefor_, rls:=rangereleases {
fmt.Println(rls.Name)
}
}
The text was updated successfully, but these errors were encountered:
Helm is built on top of kubernetes and doesn't actually create kubernetes objects. In order to read helm info we will need to use the helm Go libraries: https://pkg.go.dev/helm.sh/helm
GPT-4 suggests that we can query helm releases as follows:
The text was updated successfully, but these errors were encountered: