Skip to content

Commit

Permalink
chore: updated JMESPath function
Browse files Browse the repository at this point in the history
  • Loading branch information
A-5ingh authored Sep 30, 2024
1 parent a78e003 commit 325e6ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions content/en/blog/general/why-chainsaw-is-unique/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ spec:
template:
spec:
(containers[?securityContext == null]):
(len(@)): 0
(length(@)): 0
```

In the assertion above, the first three fields `spec`, `template`, and `spec` are basic projections that simply take the content of their respective fields and pass that to descendants.

`(containers[?securityContext == null])` is a JMESPath expression filtering the `containers` array, selecting only the element where `securityContext` is `null`. This projection results in a new array that is passed to the descendant (`(len(@))` in this case).
`(containers[?securityContext == null])` is a JMESPath expression filtering the `containers` array, selecting only the element where `securityContext` is `null`. This projection results in a new array that is passed to the descendant (`(length(@))` in this case).

`(len(@))` is another JMESPath expression that computes the length of the array. There's no more descendant at this point. We're at a leaf of the YAML tree and the array length we just computed is then compared against 0.
`(length(@))` is another JMESPath expression that computes the length of the array. There's no more descendant at this point. We're at a leaf of the YAML tree and the array length we just computed is then compared against 0.

If the comparison matches, the assertion will be considered valid; if not, it will be considered failed.

Expand Down

0 comments on commit 325e6ac

Please sign in to comment.