Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-14844

Use a newer version of yq

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • CL170 - RHOSO18.0-en-1-20241127
    • CL170
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • en-US (English)

      Please fill in the following information:


      URL:  
      Reporter RHNID:  
      Section Title:                                                                        

      Issue description

      I thought I created this bug, but I can't find it, so maybe it was just discussions on Slack.

      We are using an old version of yq in the classroom lab environment:

      yq --version

      yq version 3.3.0.

      That was released in 2020:

      https://github.com/mikefarah/yq/releases/tag/3.3.0{}{}

       

      The latest version is https://github.com/mikefarah/yq/releases/tag/v4.45.1

       

      We should be using a later version because it can do things that we are using jq/jsonpath for in this course.  I hate to see when we pipe to a JSON tool, then pipe to yq when we can just use a newer version of yq to get the same result.

       

      For instance, in ch07s01, we show a jq command then piping it into yq:

      {{[user@host ~]$ DECLARATION=oc get OpenStackControlPlane \
      openstack-control-plane -o json | jq ".spec.${SERVICE}"
      The result is saved to the cinder.patch.yml file:
      [user@host ~]$ echo "{'spec':{'${SERVICE}':${DECLARATION}}}" | \
      yq r - --prettyPrint > ${SERVICE}.patch.yml}}

       

      With a newer version of yq, you can do the same sort of thing:

      {{oc get oscp openstack-control-plane }}
      -o yaml | yq-4.45.1 '.spec|keys[]'

      I did that in the video classroom if you want to see it.  It is much better than having to go through jq first.

       

      In fact, many things in the course would be easier.  For instance, I was just looking at ch06s02: Control Plane and Data Plane Access to Storage GE

      Step 2 says to look for cinder, so you could use this instead:

      {{oc get OpenStackControlPlane \
      openstack-control-plane -o yaml | yq-4.45.1 '.metadata, .spec.cinder'}}

      (since it actually showed metadata and spec.cinder.  This does remove the top-level item (metadata or cinder in this case), but it can be shown with a little work.

      In fact, it looks really like you want to show the NFS section, so you could do this:

      {{oc get OpenStackControlPlane }}
      openstack-control-plane -o yaml | yq-4.45.1 '.spec.cinder.template.cinderVolumes.nfs'

       

      Anyway...there are lots of places where we ask them to parse a massive amount of output to find something small and using yq could be beneficial.

      The following places we use jq|jsonpath to manipulate output and this can all be done by a newer version of yq.

      ch03s01

      ch03s03

      ch03s04 GE

      ch05s02 GE

      ch07s01

       

       

       

              rhn-gps-adandrea Ashley D’Andrea
              gls-ftaylor Forrest Taylor (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: