mittwald / go-helm-client

Go client for accessing the Helm package manager
MIT License
240 stars 100 forks source link

Options.Namespace takes priority over ChartSpec.Namespace #104

Open elonsalfati opened 2 years ago

elonsalfati commented 2 years ago

My use case: I have initialized a helm client, and I'm iterating through multiple charts and installing them one by one. Different charts go to different namespaces.

I've initialized the helm client like this:

        opt := &helmclient.KubeConfClientOptions{
            Options: &helmclient.Options{
                Namespace:        "default",
                RepositoryCache:  "/tmp/.helmcache",
                RepositoryConfig: "/tmp/.helmrepo",
                Debug:            true,
                Linting:          true,
                DebugLog: func(format string, v ...interface{}) {
                    fmt.Printf(format, v...)
                    fmt.Printf("\n")
                },
            },
            KubeContext: kubecontext,
            KubeConfig: kubeconfig,
        }

        // initialize helm client with the correct kube context
        helmClient, err := helmclient.NewClientFromKubeConf(opt, helmclient.Burst(100), helmclient.Timeout(time.Duration(time.Minute*15)))
        if err != nil {
            return err
        }

and my ChartSpec looks like:

    chartSpec := helmclient.ChartSpec{
        ReleaseName: m.Name,
        ChartName: m.HelmPackage,
        Version: "0.1.0",
        ValuesYaml: string(buf),
        DryRun: m.dryRun,
        Wait: false,
        Timeout: time.Duration(time.Minute*15),
        Namespace: m.Namespace,
        CreateNamespace: true
    }

I've set the ChartSpec.Namespace = "nopeus" and ChartSpec.CreateNamespace = true accordingly and ran InstallOrUpgradeChart with the chart.

Yet when I run this, the charts are deployed to the default namespace instead of the intended nopeus namespace. Which isn't a behavior I would expect.

I would love your help on this. Am I missing something? Is it a bug? Should I just create a new client every time (sounds weird)?

g3kk0 commented 1 year ago

I too would like to know how best to handle this.

Should you create a new client each time you change namespace?

drish commented 1 year ago

👍 for this issue, having the same problem

KaimingWan commented 1 year ago

same issue here...

Aniurm commented 1 year ago

I really hope that the problem reflected in this issue can be fixed as soon as possible

nxtcoder17 commented 1 year ago

just rolled into the same issue