GithubHelp home page GithubHelp logo

Comments (5)

zvonkok avatar zvonkok commented on July 21, 2024 1

You haven't created a helmclient.Options object. Since it is a pointer a dereference to read its values will fail. Start with a full example and remove parts that you do not need. https://pkg.go.dev/github.com/mittwald/[email protected]#example-NewClientFromKubeConf

This is how I use it:

        // Either provide path or read from default location
	if path == "" {
		homeDir, err := os.UserHomeDir()
		if err != nil {
			return errors.Wrap(err, "GetClientWithKubeConf: cannot read user home dir")
		}
		path = homeDir + "/.kube/config"
	}

	kubeConfig, err := os.ReadFile(path)
	if err != nil {
		return errors.Wrapf(err, "GetClientWithKubeConf cannot read kubeConfig from path %s:%v", path, err)
	}

	opt := &helmclient.KubeConfClientOptions{
		Options: &helmclient.Options{
			Namespace:        h.ChartSpec.Namespace, // Change this to the namespace you wish to install the chart in.
			RepositoryCache:  "/tmp/.helmcache",
			RepositoryConfig: "/tmp/.helmrepo",
			Debug:            true,
			Linting:          false, // Change this to false if you don't want linting.
			DebugLog:         klog.Infof,
		},
		KubeContext: kubeContext,
		KubeConfig:  kubeConfig,
	}

	h.HelmClient, err = helmclient.NewClientFromKubeConf(opt)
	if err != nil {
		return errors.Wrap(err, "GetClientWithKubeConf cannot create client from kubeConfig")
	}
	return nil

from go-helm-client.

zvonkok avatar zvonkok commented on July 21, 2024 1

Add this to your imports:

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // register GCP auth provider

from go-helm-client.

masus04 avatar masus04 commented on July 21, 2024 1

Great, thank you very much!

from go-helm-client.

masus04 avatar masus04 commented on July 21, 2024

@zvonkok That did the trick, thank you 👍

Now I'm running into the next error that I don't know how to solve:

panic: Kubernetes cluster unreachable: no Auth Provider found for name "gcp"

Is there any chance you have a solution for that as well?

from go-helm-client.

masus04 avatar masus04 commented on July 21, 2024

I think error handling messages could be slightly improved: Similar to how a readable error is thrown when KubeConfig is not passed, the same could be donw for Options. Or simply use a reasonable default instead of the current error that is hard to interpret.

from go-helm-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.