Coder Social home page Coder Social logo

go-yq's Introduction

go-yq

Build Status Go Report Card DevOps SE Questions Docker Pulls Issues Pull requests Total downloads License Repository Size Contributors Commit activity Last commit Release date Latest Production Release Version Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities CII Best Practices codecov BCH compliance GolangCI

jq-style golang equivalent of yq.

rationale

go-yq was created to prevent that pip has to be installed in order to install yq

installation

curl -L https://github.com/030/go-yq/releases/download/x.y.z/go-yq_x.y.z-0.deb -o go-yq.deb && \
sudo apt -y install ./go-yq.deb

usage

help

[user@localhost go-yq]$ ./go-yq -h
2018/11/13 12:07:39 Usage: go-yq <key e.g. .foo.bar> <filename e.g. input.yaml>
exit status 1

examples

[user@localhost go-yq]$ ./go-yq go run main.go .firefox_version ~/dev/ansible-firefox/defaults/main.yml

or

dockeri.co

docker run -v /home/ben/dev/ansible-firefox:/ansible-firefox \
       -it utrecht/go-yq:x.y.z .firefox_version \
       /ansible-firefox/defaults/main.yml

returns:

66.0.3

go-yq's People

Contributors

030 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rob05c

go-yq's Issues

programmatically yaml test file

replace the test.yaml by constructing a yaml file using a yaml parser and cleaning it up when the test has been completed

Lists separated as hyphens do not work

In this example yaml file (taken from Wikipedia)

men: [John Smith, Bill Jones]
women:
  - Mary Smith
  - Susan Williams

I get the unexpected output:

$ go-yq-1.1.1-darwin -yamlFile women.yml -key women
2018/11/12 12:09:35 File: women.yml does not contain key: women

For the key men it does work:

$ go-yq-1.1.1-darwin -yamlFile women.yml -key men
[John Smith, Bill Jones]

Duplicate keys overwrite older version

When I search for kid1 in the following yaml:

men: [John Smith, Bill Jones]
women:
  - Mary Smith
  - Susan Williams

kid:
  kid1: jan

kid1: piet

The output is piet. I'm not sure what to expect, but at least this behaviour should be documented.

Partial match

[user@localhost go-yq]$ go run main.go firefox_checksum ~/dev/ansible-firefox/defaults/main.yml 
sha512:49d776cfb5f42c6e5ea1a55a80d9f6bad223080b16baa0d39de63534c25e68340091b4e16be5355d565f81291cb94fb996f03ae7e3e4c7a28021b0a0929daf58

partial match

[user@localhost go-yq]$ go run main.go irefox_checksum ~/dev/ansible-firefox/defaults/main.yml 
sha512:49d776cfb5f42c6e5ea1a55a80d9f6bad223080b16baa0d39de63534c25e68340091b4e16be5355d565f81291cb94fb996f03ae7e3e4c7a28021b0a0929daf58

if a key contains a digit the tool will exit

./go-yq -yamlFile defaults/main.yml -key checksum3

results in:

2018/11/11 13:14:35 Cannot extract value for key, but was: 'checksum3: 7e3e4c7a28021b0a0929daf58' please check whether the regex matches the key

jq compliant

Tool should comply to the jq policy, i.e. using dots, e.g. yq .foo.bar input.yml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.