From 67fba22bfef89c4015cf50a57dc425c21ae6411e Mon Sep 17 00:00:00 2001 From: atiratree Date: Thu, 5 Aug 2021 18:39:43 +0200 Subject: [PATCH] revert "fix wrong output when using jsonpath" This partially reverts commit 39cfe232325d66bcdbc935af7aaf7022562e7010and PR #98057 the original problem was caused by not using {end} at the end of the range Kubernetes-commit: 846910acab49681542a028668ebb818bf90df535 --- util/jsonpath/jsonpath.go | 3 --- util/jsonpath/jsonpath_test.go | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/util/jsonpath/jsonpath.go b/util/jsonpath/jsonpath.go index 0b1dc338bd..49ecd1465a 100644 --- a/util/jsonpath/jsonpath.go +++ b/util/jsonpath/jsonpath.go @@ -132,9 +132,6 @@ func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error) { } continue } - if len(results) == 0 { - break - } fullResult = append(fullResult, results) } return fullResult, nil diff --git a/util/jsonpath/jsonpath_test.go b/util/jsonpath/jsonpath_test.go index 58ad938456..c7714ee834 100644 --- a/util/jsonpath/jsonpath_test.go +++ b/util/jsonpath/jsonpath_test.go @@ -806,8 +806,8 @@ func TestRunningPodsJSONPathOutput(t *testing.T) { testJSONPath( []jsonpathTest{ { - "when range is used in a certain way in script, additional line is printed", - `{range .items[?(.status.phase=="Running")]}{.metadata.name}{" is Running\n"}`, + "range over pods without selecting the last one", + `{range .items[?(.status.phase=="Running")]}{.metadata.name}{" is Running\n"}{end}`, data, "pod1 is Running\npod2 is Running\npod3 is Running\n", false, // expect no error