Use literals in jsonpath examples (#15775)
It's very difficult to figure out e.g. the correct quotes to use from regular text that is subject to being converted for typographers quotes. Use code literals instead to ensure that nothing is modified, and to distinguish literals from accompanying text. Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
5c41bb0482
commit
8344dda2f6
@@ -65,18 +65,18 @@ Given the JSON input:
|
||||
}
|
||||
```
|
||||
|
||||
Function | Description | Example | Result
|
||||
------------------|---------------------------|---------------------------------------------------------------|------------------
|
||||
text | the plain text | kind is {.kind} | kind is List
|
||||
@ | the current object | {@} | the same as input
|
||||
. or [] | child operator | {.kind} or {['kind']} | List
|
||||
.. | recursive descent | {..name} | 127.0.0.1 127.0.0.2 myself e2e
|
||||
\* | wildcard. Get all objects | {.items[*].metadata.name} | [127.0.0.1 127.0.0.2]
|
||||
[start:end :step] | subscript operator | {.users[0].name} | myself
|
||||
[,] | union operator | {.items[*]['metadata.name', 'status.capacity']} | 127.0.0.1 127.0.0.2 map[cpu:4] map[cpu:8]
|
||||
?() | filter | {.users[?(@.name=="e2e")].user.password} | secret
|
||||
range, end | iterate list | {range .items[*]}[{.metadata.name}, {.status.capacity}] {end} | [127.0.0.1, map[cpu:4]] [127.0.0.2, map[cpu:8]]
|
||||
'' | quote interpreted string | {range .items[*]}{.metadata.name}{'\t'}{end} | 127.0.0.1 127.0.0.2
|
||||
Function | Description | Example | Result
|
||||
--------------------|---------------------------|-----------------------------------------------------------------|------------------
|
||||
`text` | the plain text | `kind is {.kind}` | `kind is List`
|
||||
`@` | the current object | `{@}` | the same as input
|
||||
`.` or `[]` | child operator | `{.kind}` or `{['kind']}` | `List`
|
||||
`..` | recursive descent | `{..name}` | `127.0.0.1 127.0.0.2 myself e2e`
|
||||
`*` | wildcard. Get all objects | `{.items[*].metadata.name}` | `[127.0.0.1 127.0.0.2]`
|
||||
`[start:end :step]` | subscript operator | `{.users[0].name}` | `myself`
|
||||
`[,]` | union operator | `{.items[*]['metadata.name', 'status.capacity']}` | `127.0.0.1 127.0.0.2 map[cpu:4] map[cpu:8]`
|
||||
`?()` | filter | `{.users[?(@.name=="e2e")].user.password}` | `secret`
|
||||
`range`, `end` | iterate list | `{range .items[*]}[{.metadata.name}, {.status.capacity}] {end}` | `[127.0.0.1, map[cpu:4]] [127.0.0.2, map[cpu:8]]`
|
||||
`''` | quote interpreted string | `{range .items[*]}{.metadata.name}{'\t'}{end}` | `127.0.0.1 127.0.0.2`
|
||||
|
||||
Examples using `kubectl` and JSONPath expressions:
|
||||
|
||||
@@ -95,4 +95,4 @@ C:\> kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{'\t'}{.stat
|
||||
C:\> kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status.startTime}{\"\n\"}{end}"
|
||||
```
|
||||
|
||||
{{% /capture %}}
|
||||
{{% /capture %}}
|
||||
|
||||
Reference in New Issue
Block a user