feat(cmd): add --all-namespaces to list

pull/3948/head
Adam Reese 6 years ago
parent d6afa4a403
commit 341e6f4f45
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -61,7 +61,7 @@ func newDeleteCmd(c helm.Interface, out io.Writer) *cobra.Command {
if len(args) == 0 {
return errors.New("command 'delete' requires a release name")
}
del.client = ensureHelmClient(del.client)
del.client = ensureHelmClient(del.client, false)
for i := 0; i < len(args); i++ {
del.name = args[i]

@ -62,7 +62,7 @@ func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
return errReleaseRequired
}
get.release = args[0]
get.client = ensureHelmClient(get.client)
get.client = ensureHelmClient(get.client, false)
return get.run()
},
}

@ -52,7 +52,7 @@ func newGetHooksCmd(client helm.Interface, out io.Writer) *cobra.Command {
return errReleaseRequired
}
ghc.release = args[0]
ghc.client = ensureHelmClient(ghc.client)
ghc.client = ensureHelmClient(ghc.client, false)
return ghc.run()
},
}

@ -54,7 +54,7 @@ func newGetManifestCmd(client helm.Interface, out io.Writer) *cobra.Command {
return errReleaseRequired
}
get.release = args[0]
get.client = ensureHelmClient(get.client)
get.client = ensureHelmClient(get.client, false)
return get.run()
},
}

@ -52,7 +52,7 @@ func newGetValuesCmd(client helm.Interface, out io.Writer) *cobra.Command {
return errReleaseRequired
}
get.release = args[0]
get.client = ensureHelmClient(get.client)
get.client = ensureHelmClient(get.client, false)
return get.run()
},
}

@ -151,14 +151,14 @@ func checkArgsLength(argsReceived int, requiredArgs ...string) error {
}
// ensureHelmClient returns a new helm client impl. if h is not nil.
func ensureHelmClient(h helm.Interface) helm.Interface {
func ensureHelmClient(h helm.Interface, allNamespaces bool) helm.Interface {
if h != nil {
return h
}
return newClient()
return newClient(allNamespaces)
}
func newClient() helm.Interface {
func newClient(allNamespaces bool) helm.Interface {
kc := kube.New(kubeConfig())
kc.Log = logf
@ -167,13 +167,17 @@ func newClient() helm.Interface {
// TODO return error
log.Fatal(err)
}
var namespace string
if !allNamespaces {
namespace = getNamespace()
}
// TODO add other backends
cfgmaps := driver.NewSecrets(clientset.CoreV1().Secrets(getNamespace()))
cfgmaps.Log = logf
d := driver.NewSecrets(clientset.CoreV1().Secrets(namespace))
d.Log = logf
return helm.NewClient(
helm.KubeClient(kc),
helm.Driver(cfgmaps),
helm.Driver(d),
helm.Discovery(clientset.Discovery()),
)
}

@ -77,7 +77,7 @@ func newHistoryCmd(c helm.Interface, w io.Writer) *cobra.Command {
if len(args) == 0 {
return errReleaseRequired
}
his.helmc = ensureHelmClient(his.helmc)
his.helmc = ensureHelmClient(his.helmc, false)
his.rls = args[0]
return his.run()
},

@ -176,7 +176,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
return err
}
inst.chartPath = cp
inst.client = ensureHelmClient(inst.client)
inst.client = ensureHelmClient(inst.client, false)
return inst.run()
},
}

@ -57,22 +57,23 @@ flag with the '--offset' flag allows you to page through results.
`
type listCmd struct {
filter string
short bool
limit int
offset string
byDate bool
sortDesc bool
out io.Writer
all bool
deleted bool
deleting bool
deployed bool
failed bool
superseded bool
pending bool
client helm.Interface
colWidth uint
filter string
short bool
limit int
offset string
byDate bool
sortDesc bool
out io.Writer
all bool
deleted bool
deleting bool
deployed bool
failed bool
superseded bool
pending bool
client helm.Interface
colWidth uint
allNamespaces bool
}
func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -90,7 +91,7 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
if len(args) > 0 {
list.filter = strings.Join(args, " ")
}
list.client = ensureHelmClient(list.client)
list.client = ensureHelmClient(list.client, list.allNamespaces)
return list.run()
},
}
@ -108,9 +109,7 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
f.BoolVar(&list.failed, "failed", false, "show failed releases")
f.BoolVar(&list.pending, "pending", false, "show pending releases")
f.UintVar(&list.colWidth, "col-width", 60, "specifies the max column width of output")
// TODO: Do we want this as a feature of 'helm list'?
//f.BoolVar(&list.superseded, "history", true, "show historical releases")
f.BoolVar(&list.allNamespaces, "all-namespaces", false, "list releases across all namespaces")
return cmd
}

@ -57,7 +57,7 @@ func newReleaseTestCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
rlsTest.name = args[0]
rlsTest.client = ensureHelmClient(rlsTest.client)
rlsTest.client = ensureHelmClient(rlsTest.client, false)
return rlsTest.run()
},
}

@ -70,7 +70,7 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
rollback.revision = int(v64)
rollback.client = ensureHelmClient(rollback.client)
rollback.client = ensureHelmClient(rollback.client, false)
return rollback.run()
},
}

@ -67,7 +67,7 @@ func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
return errReleaseRequired
}
status.release = args[0]
status.client = ensureHelmClient(status.client)
status.client = ensureHelmClient(status.client, false)
return status.run()
},
}

@ -106,7 +106,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
upgrade.release = args[0]
upgrade.chart = args[1]
upgrade.client = ensureHelmClient(upgrade.client)
upgrade.client = ensureHelmClient(upgrade.client, false)
return upgrade.run()
},

Loading…
Cancel
Save