Search code examples
yamljq

parse error while passing helm show chart to jq


Hi I am getting a parse error when i perform the following command

helm show chart https://artifactory.vvr.com/artifactory/helm-release-local/jaeger/jaeger-assembly/jaeger-assembly-1.0.0.tgz -n test | jq .

parse error: Invalid numeric literal at line 1, column 11

the output of helm show command is below

apiVersion: v1
appVersion: 1.0.0
dependencies:
- name: jaeger
  repository: https://dependencies.vvr.com/artifactory/helm//jaegertracing
  version: 0.44.0
description: aeger Assembly
name: jaeger-assembly
version: 1.0.0

any idea why it is showing a parse error and how can i fix so that the helm show chart output can be parsed to json as i need to retrieve the version attribute


Solution

  • jq is a lightweight and flexible command-line JSON processor akin to sed,awk,grep, and friends for JSON data.

    While YAML is a superset of JSON (any JSON document is also a valid YAML document), the reverse is not true. This means you cannot process generic YAML files with jq, but you need a tool that can handle YAML. One such tool is yq:

    a lightweight and portable command-line YAML, JSON and XML processor. yq uses jq like syntax but works with yaml files as well as json, xml, properties, csv and tsv.

    Since it uses a jq like syntax, you can simply swap the command:

    helm show chart … -n test | yq .