diff --git a/docs/cli/ignite/ignite_ps.md b/docs/cli/ignite/ignite_ps.md index 1439668aa..b24b1d346 100644 --- a/docs/cli/ignite/ignite_ps.md +++ b/docs/cli/ignite/ignite_ps.md @@ -7,6 +7,28 @@ List running VMs 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" ``` diff --git a/docs/cli/ignite/ignite_vm_ps.md b/docs/cli/ignite/ignite_vm_ps.md index 3272a80c1..0f7c9b4ae 100644 --- a/docs/cli/ignite/ignite_vm_ps.md +++ b/docs/cli/ignite/ignite_vm_ps.md @@ -7,6 +7,28 @@ List running VMs 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" ``` diff --git a/pkg/filter/meta_test.go b/pkg/filter/meta_test.go index 9d8e7e259..30b65be37 100644 --- a/pkg/filter/meta_test.go +++ b/pkg/filter/meta_test.go @@ -405,12 +405,12 @@ func TestExtractMultipleKeyValueFiltering(t *testing.T) { str: "{{.Name}}=target1,{{.Age}}=38", res: []metaFilter{ - metaFilter{ + { identifier: "{{.Name}}", expectedValue: "target1", operator: "=", }, - metaFilter{ + { identifier: "{{.Age}}", expectedValue: "38", operator: "=",