Skip to content

Commit

Permalink
Merge pull request #8 from juicedata/feature/allnamespace
Browse files Browse the repository at this point in the history
feat: add all-namespaces flag
  • Loading branch information
zwwhdls authored Aug 2, 2024
2 parents cadd793 + 4e4e400 commit abf7fb5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/tools/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
func init() {
KubernetesConfigFlags = genericclioptions.NewConfigFlags(true)
RootCmd.PersistentFlags().StringVarP(&config.MountNamespace, "mount-namespace", "m", "kube-system", "namespace of juicefs csi driver")
RootCmd.PersistentFlags().BoolVarP(&config.AllNamespaces, "all-namespaces", "A", config.AllNamespaces, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.")
KubernetesConfigFlags.AddFlags(RootCmd.PersistentFlags())
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/tools/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package tools
import (
"github.com/spf13/cobra"

"github.com/juicedata/kubectl-jfs-plugin/pkg/config"
"github.com/juicedata/kubectl-jfs-plugin/pkg/list"
"github.com/juicedata/kubectl-jfs-plugin/pkg/util"
)
Expand All @@ -32,6 +33,9 @@ var podCmd = &cobra.Command{
if ns == "" {
ns = "default"
}
if config.AllNamespaces {
ns = ""
}
clientSet, err := util.ClientSet(KubernetesConfigFlags)
cobra.CheckErr(err)

Expand Down
4 changes: 4 additions & 0 deletions cmd/tools/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package tools
import (
"github.com/spf13/cobra"

"github.com/juicedata/kubectl-jfs-plugin/pkg/config"
"github.com/juicedata/kubectl-jfs-plugin/pkg/list"
"github.com/juicedata/kubectl-jfs-plugin/pkg/util"
)
Expand All @@ -31,6 +32,9 @@ var pvcCmd = &cobra.Command{
if ns == "" {
ns = "default"
}
if config.AllNamespaces {
ns = ""
}
clientSet, err := util.ClientSet(KubernetesConfigFlags)
cobra.CheckErr(err)

Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package config

var (
MountNamespace string
AllNamespaces bool
)

const (
Expand Down
4 changes: 2 additions & 2 deletions pkg/list/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func (pa *PVCAnalyzer) ListPVC() error {
func (pa *PVCAnalyzer) printPVCs() (string, error) {
return util.TabbedString(func(out io.Writer) error {
w := kdescribe.NewPrefixWriter(out)
w.Write(kdescribe.LEVEL_0, "NAME\tVOLUME\tSTORAGECLASS\tSTATUS\tAGE\n")
w.Write(kdescribe.LEVEL_0, "NAME\tNAMESPACE\tVOLUME\tSTORAGECLASS\tSTATUS\tAGE\n")
for _, pvc := range pa.pvcShows {
w.Write(kdescribe.LEVEL_0, "%s\t%s\t%s\t%s\t%s\n", pvc.name, pvc.pv, pvc.sc, pvc.status, util.TranslateTimestampSince(pvc.createAt))
w.Write(kdescribe.LEVEL_0, "%s\t%s\t%s\t%s\t%s\t%s\n", pvc.name, pvc.namespace, pvc.pv, pvc.sc, pvc.status, util.TranslateTimestampSince(pvc.createAt))
}
return nil
})
Expand Down

0 comments on commit abf7fb5

Please sign in to comment.