Skip to content

Commit

Permalink
Merge pull request #6798 from aaronmell/Make_Namespace_Public
Browse files Browse the repository at this point in the history
Allow namespace to be set by programs consuming helm.
  • Loading branch information
Matthew Fisher committed Oct 28, 2019
2 parents 2c79118 + 31f2fea commit f1dc847
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func main() {
actionConfig := new(action.Configuration)
cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])

if err := actionConfig.Init(settings, false, os.Getenv("HELM_DRIVER"), debug); err != nil {
if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil {
debug("%+v", err)
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if client.AllNamespaces {
if err := cfg.Init(settings, true, os.Getenv("HELM_DRIVER"), debug); err != nil {
if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil {
return err
}
}
Expand Down
10 changes: 2 additions & 8 deletions pkg/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/discovery"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/kube"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/storage"
Expand Down Expand Up @@ -210,20 +210,14 @@ func (c *Configuration) recordRelease(r *release.Release) {
}

// InitActionConfig initializes the action configuration
func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, helmDriver string, log DebugLog) error {
getter := envSettings.RESTClientGetter()

func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace string, helmDriver string, log DebugLog) error {
kc := kube.New(getter)
kc.Log = log

clientset, err := kc.Factory.KubernetesClientSet()
if err != nil {
return err
}
var namespace string
if !allNamespaces {
namespace = envSettings.Namespace()
}

var store *storage.Storage
switch helmDriver {
Expand Down

0 comments on commit f1dc847

Please sign in to comment.