Skip to content

Commit

Permalink
Use StringArrayVarP for --include and --exclude flags (#196)
Browse files Browse the repository at this point in the history
* Use StringArrayVarP for --include/--exclude

Replace `StringSliceVarP` with `StringArrayVarP` for the --include and
--exclude flags so regex strings can contain colons.

* Update README.md

Co-authored-by: Kazuki Suda <kazuki.suda@gmail.com>
  • Loading branch information
partcyborg and superbrothers committed Dec 24, 2022
1 parent f6e76ba commit 80a68a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ The `pod` query is a regular expression so you could provide `"web-\w"` to tail
`--container-state` | `running` | Tail containers with state in running, waiting or terminated. To specify multiple states, repeat this or set comma-separated value.
`--context` | | Kubernetes context to use. Default to current context configured in kubeconfig.
`--ephemeral-containers` | `true` | Include or exclude ephemeral containers.
`--exclude`, `-e` | | Log lines to exclude. (regular expression)
`--exclude`, `-e` | `[]` | Log lines to exclude. (regular expression)
`--exclude-container`, `-E` | | Container name to exclude when multiple containers in pod. (regular expression)
`--exclude-pod` | | Pod name to exclude. (regular expression)
`--field-selector` | | Selector (field query) to filter on. If present, default to ".*" for the pod-query.
`--include`, `-i` | | Log lines to include. (regular expression)
`--include`, `-i` | `[]` | Log lines to include. (regular expression)
`--init-containers` | `true` | Include or exclude init containers.
`--kubeconfig` | | Path to kubeconfig file to use. Default to KUBECONFIG variable then ~/.kube/config path.
`--namespace`, `-n` | | Kubernetes namespace to use. Default to namespace configured in kubernetes context. To specify multiple namespaces, repeat this or set comma-separated value.
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ func (o *options) AddFlags(fs *pflag.FlagSet) {
fs.StringVarP(&o.container, "container", "c", o.container, "Container name when multiple containers in pod. (regular expression)")
fs.StringSliceVar(&o.containerStates, "container-state", o.containerStates, "Tail containers with state in running, waiting or terminated. To specify multiple states, repeat this or set comma-separated value.")
fs.StringVar(&o.context, "context", o.context, "Kubernetes context to use. Default to current context configured in kubeconfig.")
fs.StringSliceVarP(&o.exclude, "exclude", "e", o.exclude, "Log lines to exclude. (regular expression)")
fs.StringArrayVarP(&o.exclude, "exclude", "e", o.exclude, "Log lines to exclude. (regular expression)")
fs.StringVarP(&o.excludeContainer, "exclude-container", "E", o.excludeContainer, "Container name to exclude when multiple containers in pod. (regular expression)")
fs.StringVar(&o.excludePod, "exclude-pod", o.excludePod, "Pod name to exclude. (regular expression)")
fs.StringSliceVarP(&o.include, "include", "i", o.include, "Log lines to include. (regular expression)")
fs.StringArrayVarP(&o.include, "include", "i", o.include, "Log lines to include. (regular expression)")
fs.BoolVar(&o.initContainers, "init-containers", o.initContainers, "Include or exclude init containers.")
fs.BoolVar(&o.ephemeralContainers, "ephemeral-containers", o.ephemeralContainers, "Include or exclude ephemeral containers.")
fs.StringVar(&o.kubeConfig, "kubeconfig", o.kubeConfig, "Path to kubeconfig file to use. Default to KUBECONFIG variable then ~/.kube/config path.")
Expand Down

0 comments on commit 80a68a9

Please sign in to comment.