yq | portable command-line YAML | YAML Processing library

 by   mikefarah Go Version: v4.34.1 License: MIT

kandi X-RAY | yq Summary

kandi X-RAY | yq Summary

yq is a Go library typically used in Utilities, YAML Processing applications. yq has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

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 and xml. It doesn't yet support everything jq does - but it does support the most common operations and functions, and more is being added continuously.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              yq has a medium active ecosystem.
              It has 8766 star(s) with 465 fork(s). There are 56 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 75 open issues and 1060 have been closed. On average issues are closed in 98 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of yq is v4.34.1

            kandi-Quality Quality

              yq has 0 bugs and 0 code smells.

            kandi-Security Security

              yq has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              yq code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              yq is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              yq releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              It has 15071 lines of code, 508 functions and 149 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of yq
            Get all kandi verified functions for this library.

            yq Key Features

            No Key Features are available at this moment for yq.

            yq Examples and Code Snippets

            No Code Snippets are available at this moment for yq.

            Community Discussions

            QUESTION

            How to install Python 2 on macOS 12.3+
            Asked 2022-Apr-04 at 18:29

            macOS 12.3 update drops Python 2 and replaces it with version 3:

            https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes

            Python Deprecations Python 2.7 was removed from macOS in this update. Developers should use Python 3 or an alternative language instead. (39795874)

            I understand we need to migrate to version 3, but in the meantime we still need version 2. Homebrew does not seem to have it anymore:

            ...

            ANSWER

            Answered 2022-Apr-04 at 15:50

            You can get any Python release, including the last Python 2, from the official download site:

            https://www.python.org/downloads/release/python-2718/macOS 64-bit installer

            Source https://stackoverflow.com/questions/71739870

            QUESTION

            yq compare only part of files
            Asked 2022-Mar-29 at 12:17

            If I have two files, data1.yaml and data2.yaml.

            I do not want to compare all conntent of data files. I need to compare only for example version part

            ...

            ANSWER

            Answered 2022-Mar-29 at 11:29

            May be something like this?

            Source https://stackoverflow.com/questions/71661115

            QUESTION

            yaml - Print key and value, if value meets consitions
            Asked 2022-Mar-17 at 11:16

            Given the following yaml:

            ...

            ANSWER

            Answered 2022-Mar-17 at 11:07

            Using kislyuk/yq you can base your filter on jq.

            • to_entries splits up the object into an array of key-value pairs
            • select selects those items matching your criteria
            • String interpolation in combination with the -r option puts together your desired output

            Source https://stackoverflow.com/questions/71511088

            QUESTION

            yq - issue adding yaml into yaml
            Asked 2022-Mar-13 at 17:51

            Hi I would like to update a yaml like string into a yaml

            i do have the following yaml file argocd.yaml

            ...

            ANSWER

            Answered 2021-Oct-21 at 06:20

            Your second approach can work, but in a roundabout way, as mikefarah/yq does not support updating multi-line block literals yet

            One way to solve this, with the existing constructs would be to do below, without having to create a temporary YAML file

            Source https://stackoverflow.com/questions/69648216

            QUESTION

            yq add array element with name and subfields
            Asked 2022-Mar-09 at 04:30

            I got this test.yaml:

            ...

            ANSWER

            Answered 2022-Mar-08 at 23:20

            You can either make name and mountPath appear on the same level:

            Source https://stackoverflow.com/questions/71402474

            QUESTION

            Sanitize YAML front matter content with yq (macOS)
            Asked 2022-Feb-25 at 16:24

            I have around 30,000 .md files which include a frontmatter. all of them have different set of keys. To sort them alphabetically I successfully used brew yq and find.

            ...

            ANSWER

            Answered 2022-Feb-25 at 14:51

            You need to pass the --front-matter=process when modifying the front-matter content and pass the required expression to modify the tags.

            For case 1) pre-formatted array notation with just sorting needed, use yq as

            Source https://stackoverflow.com/questions/71264644

            QUESTION

            Change a key values based on a different value
            Asked 2022-Feb-25 at 15:03

            I have the following YAML file :

            ...

            ANSWER

            Answered 2021-Oct-27 at 05:42

            With the syntax you've shown in the question, I would assume you are using mikefarah/yq.

            Its DSL is almost similar to that of jq, so you can use select operator for choosing the right record and use the |= to update the desired value

            Source https://stackoverflow.com/questions/69731105

            QUESTION

            YAML: encoding vs semantic differences
            Asked 2022-Feb-23 at 00:29

            I would like to get some better understanding about what aspects of YAML refer to the encoding of data vs what aspects refer to semantic.

            A simple example:

            ...

            ANSWER

            Answered 2022-Feb-23 at 00:29
            Equality

            You're asking for equivalence but that's not a term in the spec and therefore cannot be discussed (at least not without definition). I'll go with discussing equality instead, which is defined by the spec as follows:

            Two scalars are equal only when their tags and canonical forms are equal character-by-character. Equality of collections is defined recursively.

            One node in your example has the tag !!binary but the others do not have tags. So we must check what the spec says about tags of nodes that don't have explicit tags:

            Tags and Schemes

            The YAML spec says that every node is to have a tag. Any node that does not have an explicit tag gets a non-specific tag assigned. Nodes are divided into scalars (that get created from textual content) and collections (sequences and mappings). Every non-plain scalar node (i.e. every scalar in quotes or given via | or >) that does not have an explicit tag gets the non-specific tag !, every other node without explicit tag gets the non-specific tag ?.

            During loading, the spec defines that non-specific tags are to be resolved to specific tags by means of using a scheme. The specification describes some schemes, but does not require an implementation to support any particular one.

            The failsafe scheme, which is designed to be the most basic scheme, will resolve non-specific tags as follows:

            • on scalars to !!str
            • on sequences to !!seq
            • on mappings to !!map

            and that's it.

            A scheme is allowed to derive a specific tag from a non-specific one by considering the kind of non-specific tag, the node's position in the document, and the node's content. For example, the JSON Scheme will give a scalar true the tag !!bool due to its content.

            The spec says that the non-specific tag ! should only be resolved to !!str for scalars, !!seq for sequence, and !!map for mappings, but does not require this. This is what most implementations support and means that if you quote your scalar, you will get a string. This is important so that you can give the scalar "true" quoted to avoid getting a boolean value.

            By the way, the spec does not say that every step defined there is to be implemented slavishly as defined in the spec, it is more a logical description. A lot of implementations do not actually transition from non-specific tags to specific tags, but instead directly choose native types for the YAML data they load according to the scheme rules.

            Applying Equality

            Now that we know how tags are assigned to nodes, let's go over your example:

            Source https://stackoverflow.com/questions/71228253

            QUESTION

            yq add extra contents to yaml
            Asked 2022-Feb-19 at 19:06

            I have tried many times with different combinations, but I cant get it working. Here is my yq command

            yq -i e '(.spec.template.spec.containers[]|select(.name == "od-fe").image) = "abcd"

            it is supposed to replace the deployment image which is successful, but it also adds template.spec.containers to the service. here is the deployment + service yaml

            ...

            ANSWER

            Answered 2022-Feb-19 at 19:06

            One way to fix that would be include a select statement at the top level to act on only Deployment type

            Source https://stackoverflow.com/questions/71187168

            QUESTION

            yq - Find and replace map value by map key
            Asked 2022-Feb-16 at 11:47

            I have a yml file called output.yml which contains a K8s Service, Deployment and Ingress resources like so (lots of fields omitted for brevity):

            ...

            ANSWER

            Answered 2022-Feb-16 at 11:47

            It can be accomplished by doing a recursive decent to identify keys matching your string and update their value part using |=

            Source https://stackoverflow.com/questions/71059640

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install yq

            As these are supported by the community :heart: - however, they may be out of date with the officially supported releases.

            Support

            As these are supported by the community :heart: - however, they may be out of date with the officially supported releases.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular YAML Processing Libraries

            yq

            by mikefarah

            yaml

            by go-yaml

            js-yaml

            by nodeca

            yaml

            by symfony

            yaml-cpp

            by jbeder

            Try Top Libraries by mikefarah

            dashinator

            by mikefarahJavaScript

            express-graphql

            by mikefarahJavaScript