From 2a33dfdcd6f83b7d03036c2a2ddbab7dcc2e960d Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Fri, 14 Aug 2020 11:31:00 +0200 Subject: [PATCH 1/6] Update jsonpath.md Adding note that JSONPath in kubectl cli does not currently support RegEx. --- content/en/docs/reference/kubectl/jsonpath.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index 50c051c9f4..e7087bbdea 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -98,4 +98,24 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status. ``` {{< /note >}} +{{< note >}} + +JSONPath RegEx are currently not supported. You must use jq or similar. +Example currently not supported + +```shell +kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' +``` +{{< /note >}} + +{{< note >}} + +JSONPath RegEx are currently not supported. You must use jq or similar. +Example currently not supported + +```shell +kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' +``` +{{< /note >}} + From 869817b56c5e6d53991d4610331baa2d6efbd702 Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Fri, 14 Aug 2020 11:40:11 +0200 Subject: [PATCH 2/6] Update jsonpath.md --- content/en/docs/reference/kubectl/jsonpath.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index e7087bbdea..9e483e443c 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -108,14 +108,4 @@ kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata. ``` {{< /note >}} -{{< note >}} - -JSONPath RegEx are currently not supported. You must use jq or similar. -Example currently not supported - -```shell -kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' -``` -{{< /note >}} - From 5247eaccc3ddfe3b0aed533e40723d040904a976 Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Fri, 14 Aug 2020 14:55:00 +0200 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Tim Bannister --- content/en/docs/reference/kubectl/jsonpath.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index 9e483e443c..6ca252082d 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -100,12 +100,16 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status. {{< note >}} -JSONPath RegEx are currently not supported. You must use jq or similar. +JSONPath regular expressions are not supported. If you want to match using regular expressions, you can use a tool such as `jq`. Example currently not supported ```shell +# kubectl does not suport regular expressions +# The following command does not work kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' + +# The following command achieves the same result +kubectl get secrets -o json | jq '[needs actual example code writing before merge]' ``` {{< /note >}} - From 6262a5dae36c6b459dfe403acc12d984c298266a Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Tue, 18 Aug 2020 19:59:10 +0200 Subject: [PATCH 4/6] Update jsonpath.md --- content/en/docs/reference/kubectl/jsonpath.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index 6ca252082d..acb9d9e9e9 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -101,15 +101,14 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status. {{< note >}} JSONPath regular expressions are not supported. If you want to match using regular expressions, you can use a tool such as `jq`. -Example currently not supported ```shell # kubectl does not suport regular expressions # The following command does not work -kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' +kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' # The following command achieves the same result -kubectl get secrets -o json | jq '[needs actual example code writing before merge]' +kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image' ``` {{< /note >}} From 5a4c534e5703c5b2016abafdbc021dd722cc9da8 Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Wed, 26 Aug 2020 19:55:26 +0200 Subject: [PATCH 5/6] Update content/en/docs/reference/kubectl/jsonpath.md Co-authored-by: Tim Bannister --- content/en/docs/reference/kubectl/jsonpath.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index acb9d9e9e9..cc4628a1c7 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -103,7 +103,7 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status. JSONPath regular expressions are not supported. If you want to match using regular expressions, you can use a tool such as `jq`. ```shell -# kubectl does not suport regular expressions +# kubectl does not support regular expressions for JSONpath output # The following command does not work kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' @@ -111,4 +111,3 @@ kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.nam kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image' ``` {{< /note >}} - From 691ca62bb3288ce472174458b2ae19f1e137f282 Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Wed, 26 Aug 2020 19:55:51 +0200 Subject: [PATCH 6/6] Update content/en/docs/reference/kubectl/jsonpath.md Co-authored-by: Daniel Smith --- content/en/docs/reference/kubectl/jsonpath.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index cc4628a1c7..d26c110cee 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -107,7 +107,7 @@ JSONPath regular expressions are not supported. If you want to match using regul # The following command does not work kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' -# The following command achieves the same result +# The following command achieves the desired result kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image' ``` {{< /note >}}