Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
cmd: add more details in --help flag
Browse files Browse the repository at this point in the history
  • Loading branch information
najeal committed Sep 27, 2019
1 parent 5434bd1 commit ddfaa0d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions cmd/ignite/cmd/vmcmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ func NewCmdPs(out io.Writer) *cobra.Command {
Long: dedent.Dedent(`
List all running VMs. By specifying the all flag (-a, --all),
also list VMs that are not currently running.
Using the -f (--filter) flag, you can give conditions VMs should fullfilled to be displayed.
You can filter on all the underlying fields of the VM struct, see the documentation:
https://ignite.readthedocs.io/en/stable/api/ignite_v1alpha2.html#VM.
Different operators can be used:
- "=" and "==" for the equal
- "!=" for the is not equal
- "=~" for the contains
- "!~" for the not contains
Non-exhaustive list of identifiers to apply filter on:
- the VM name
- CPUs usage
- Labels
- Image
- Kernel
- Memory
Example usage:
$ ignite ps -f "{{.ObjectMeta.Name}}=my-vm2,{{.Spec.CPUs}}!=3,{{.Spec.Image.OCI}}=~weaveworks/ignite-ubuntu"
$ ignite ps -f "{{.Spec.Memory}}=~1024,{{.Status.Running}}=true"
`),
Run: func(cmd *cobra.Command, args []string) {
// If `ps` is called via any of its aliases
Expand Down
2 changes: 1 addition & 1 deletion cmd/ignite/run/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Ps(po *psOptions) error {
for _, vm := range po.allVMs {
isExpectedVM := true
if filtering {
isExpectedVM, err = filters.AreExpected(vm.GetObjectMeta())
isExpectedVM, err = filters.AreExpected(vm)
if err != nil {
return err
}
Expand Down

0 comments on commit ddfaa0d

Please sign in to comment.