laetho/metagraf

Add support for JSONPath expressions

Closed this issue · 1 comments

robof commented

Proposal
mg should support JSONPath expression so we can easily fetch field data from metagraf.json without relying on other tools.
By introducing a get command that supports valid JSONPath expression we can easily and concisely rely on mg as a single tool for working with metagraf.json files.

given a metagraf.json like

{
  "kind": "MetaGraf",
  "metadata": {
    "name": "myapp",
    "annotations": {
      "my/annotation-test": "The value",
    }
  },
  "spec": {
    ...
  }
} 

When we fetch the field "name", i.e. mg get "$.metadata.name" metagraf.json
Then the value returned should be "myapp"

@robof: This need should be covered by mg get jsonpath (gjson) in b08ec05.

Example:
mg get jsonpath "metadata.name" metagraf.json

Thanks for waiting :)