From 6295ded5fe2f47d71fedd683ff322b543fe33b79 Mon Sep 17 00:00:00 2001 From: Sonali Srivastava <srivastava.sonali1@gmail.com> Date: Wed, 25 Dec 2024 18:12:57 +0530 Subject: [PATCH] Updated sum function docs to mention array should not be empty Signed-off-by: Sonali Srivastava <srivastava.sonali1@gmail.com> --- content/en/docs/writing-policies/jmespath.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/writing-policies/jmespath.md b/content/en/docs/writing-policies/jmespath.md index 92be54ea3..177109d24 100644 --- a/content/en/docs/writing-policies/jmespath.md +++ b/content/en/docs/writing-policies/jmespath.md @@ -2053,7 +2053,7 @@ spec: <details><summary>Expand</summary> <p> -The `sum()` filter takes an array of numbers, durations, or quantities and sums them together. This is a customized version of `sum()` found in the [upstream JMESPath specification](https://jmespath.org/specification.html#sum) but augmented to support inputs common to Kubernetes workloads, specifically durations and quantities. `sum()` is similar to `add()` with the difference that `sum()` accepts an array as an input while `add()` does not. Inputs must be of a homogenous type. For example, the query `echo '{"input":['2Ki','5Gi','8Mi']}' | kyverno jp query "sum(input)"` results in the value `"5251074Ki"`. The query `echo '{"input":['2h','50s','90s']}' | kyverno jp query "sum(input)"` results in the value `"2h2m20s"`. And the query `echo '{"input":[6,3,8]}' | kyverno jp query "sum(input)"` results in the value of `17`. +The `sum()` filter takes an array of numbers, durations, or quantities and sums them together. This is a customized version of `sum()` found in the [upstream JMESPath specification](https://jmespath.org/specification.html#sum) but augmented to support inputs common to Kubernetes workloads, specifically durations and quantities. `sum()` is similar to `add()` with the difference that `sum()` accepts an array as an input while `add()` does not. This `sum()` function requires at least one element in the array. Inputs must be of a homogenous type. For example, the query `echo '{"input":['2Ki','5Gi','8Mi']}' | kyverno jp query "sum(input)"` results in the value `"5251074Ki"`. The query `echo '{"input":['2h','50s','90s']}' | kyverno jp query "sum(input)"` results in the value `"2h2m20s"`. And the query `echo '{"input":[6,3,8]}' | kyverno jp query "sum(input)"` results in the value of `17`. Arithmetic filters like `sum()` currently accept inputs in the following formats.