当前位置:   article > 正文

容器编排技术 -- Kubernetes JSONpath Support_容器编排平台管理哪三个函数类型

容器编排平台管理哪三个函数类型

容器编排技术 -- Kubernetes JSONpath Support

 

JSONPath模板是由{}大括号括起来的JSONPath表达式组成。除了原始的JSONPath语法之外,我们还添加了三个函数:

  • 可选的$操作符,因为表达式总是默认从根对象开始。
  • 用""双引号来引用JSONPath表达式中的文本
  • 使用range操作符来迭代List。

result对象被打印成String()函数。

输出结果:

  1. {
  2. "kind": "List",
  3. "items":[
  4. {
  5. "kind":"None",
  6. "metadata":{"name":"127.0.0.1"},
  7. "status":{
  8. "capacity":{"cpu":"4"},
  9. "addresses":[{"type": "LegacyHostIP", "address":"127.0.0.1"}]
  10. }
  11. },
  12. {
  13. "kind":"None",
  14. "metadata":{"name":"127.0.0.2"},
  15. "status":{
  16. "capacity":{"cpu":"8"},
  17. "addresses":[
  18. {"type": "LegacyHostIP", "address":"127.0.0.2"},
  19. {"type": "another", "address":"127.0.0.3"}
  20. ]
  21. }
  22. }
  23. ],
  24. "users":[
  25. {
  26. "name": "myself",
  27. "user": {}
  28. },
  29. {
  30. "name": "e2e",
  31. "user": {"username": "admin", "password": "secret"}
  32. }
  33. ]
  34. }
FunctionDescriptionExampleResult
textthe plain textkind is {.kind}kind is List
@the current object{@}the same as input
. or []child operator{.kind} or {[‘kind’]}List
..recursive descent{..name}127.0.0.1 127.0.0.2 myself e2e
*wildcard. Get all objects{.items[*].metadata.name}[127.0.0.1 127.0.0.2]
[start:end :step]subscript operator{.users[0].name}myself
[,]union operator{.items[*][‘metadata.name’, ‘status.capacity’]}127.0.0.1 127.0.0.2 map[cpu:4] map[cpu:8]
?()filter{.users[?(@.name==”e2e”)].user.password}secret
range, enditerate list{range .items[*]}[{.metadata.name}, {.status.capacity}] {end}[127.0.0.1, map[cpu:4]] [127.0.0.2, map[cpu:8]]
””quote interpreted string{range .items[*]}{.metadata.name}{“\t”}{end}127.0.0.1 127.0.0.2

 

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号