kubernetes: Regular expressions not working in json-path

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

Trying to use the following json-path expression:

kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}'

resulted in the following error:

error: error parsing jsonpath {.items[?(@.metadata.name=~/^test$/)].metadata.name}, unrecognized character in action: U+007E '~'

What you expected to happen:

Getting the list of secret names that match the regular expression.

How to reproduce it (as minimally and precisely as possible):

kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^default-/)]}'

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): 1.8.6 (client) / 1.7.12-gke.1 (server)
  • Cloud provider or hardware configuration: MacBook Pro
  • OS (e.g. from /etc/os-release): MacOS 10.13
  • Kernel (e.g. uname -a): Darwin MacBook-Pro-3.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
  • Install tools:
  • Others:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 19
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Any plans on tackling this one?