diff --git a/cmd/ignite/cmd/vmcmd/ps.go b/cmd/ignite/cmd/vmcmd/ps.go index d0c62a901..e9982a4f7 100644 --- a/cmd/ignite/cmd/vmcmd/ps.go +++ b/cmd/ignite/cmd/vmcmd/ps.go @@ -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 diff --git a/cmd/ignite/run/ps.go b/cmd/ignite/run/ps.go index 4bba21fb7..fd4a768b3 100644 --- a/cmd/ignite/run/ps.go +++ b/cmd/ignite/run/ps.go @@ -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 }