Skip to content

Commit

Permalink
Add --namespace to align with common k8s CLI flags
Browse files Browse the repository at this point in the history
Closes boz#38.
  • Loading branch information
ivankovnatsky committed Jan 23, 2025
1 parent ec131e2 commit 02b8503
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Flag | Selection
--- | ---
`-l, --label LABEL-SELECTOR` | match pods based on a [standard label selector](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/)
`-p, --pod NAME` | match pods by name
`-n, --ns NAMESPACE-NAME` | match pods in the given namespace
`-n, --ns, --namespace NAMESPACE-NAME` | match pods in the given namespace
`--svc NAME` | match pods belonging to the given service
`--rc NAME` | match pods belonging to the given replication controller
`--rs NAME` | match pods belonging to the given replica set
Expand Down
8 changes: 6 additions & 2 deletions cmd/kail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
flagLabel = kingpin.Flag("label", "label").Short('l').PlaceHolder("SELECTOR").Strings()
flagPod = kingpin.Flag("pod", "pod").Short('p').PlaceHolder("NAME").Strings()
flagNs = kingpin.Flag("ns", "namespace").Short('n').PlaceHolder("NAME").Strings()
flagNamespace = kingpin.Flag("namespace", "namespace (same as --ns)").PlaceHolder("NAME").Strings()
flagIgnoreNs = kingpin.Flag("ignore-ns", "ignore namespace").PlaceHolder("NAME").Default("kube-system").Strings()
flagSvc = kingpin.Flag("svc", "service").PlaceHolder("NAME").Strings()
flagRc = kingpin.Flag("rc", "replication controller").PlaceHolder("NAME").Strings()
Expand Down Expand Up @@ -245,8 +246,11 @@ func createDSBuilder() kail.DSBuilder {
dsb = dsb.WithNamespace(currentNS)
}

if len(*flagNs) > 0 {
dsb = dsb.WithNamespace(*flagNs...)
if len(*flagNs) > 0 || len(*flagNamespace) > 0 {
// Combine both namespace flags
namespaces := append([]string{}, *flagNs...)
namespaces = append(namespaces, *flagNamespace...)
dsb = dsb.WithNamespace(namespaces...)
}

if len(*flagIgnoreNs) > 0 {
Expand Down

0 comments on commit 02b8503

Please sign in to comment.