kubectl-neat | Clean up Kubernetes yaml and json output to make | YAML Processing library

 by   itaysk Go Version: v2.0.3 License: Apache-2.0

kandi X-RAY | kubectl-neat Summary

kandi X-RAY | kubectl-neat Summary

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

Clean up Kubernetes yaml and json output to make it readable
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              kubectl-neat has a medium active ecosystem.
              It has 1323 star(s) with 79 fork(s). There are 15 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 22 open issues and 27 have been closed. On average issues are closed in 67 days. There are 9 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of kubectl-neat is v2.0.3

            kandi-Quality Quality

              kubectl-neat has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

              kubectl-neat is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              kubectl-neat releases are available to install and integrate.
              It has 1335 lines of code, 30 functions and 8 files.
              It has low 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 kubectl-neat
            Get all kandi verified functions for this library.

            kubectl-neat Key Features

            No Key Features are available at this moment for kubectl-neat.

            kubectl-neat Examples and Code Snippets

            No Code Snippets are available at this moment for kubectl-neat.

            Community Discussions

            Trending Discussions on kubectl-neat

            QUESTION

            find and delete nested json object in Go
            Asked 2019-Aug-11 at 22:17

            I have a json document of a Kubernetes Pod, here's an example: https://github.com/itaysk/kubectl-neat/blob/master/test/fixtures/pod-1-raw.json

            I'd like to traverse spec.containers[i].volumeMounts and delete those volumeMount objects where the .name starts with "default-token-". Note that both containers and volumeMounts are arrays.

            Using jq it took me 1 min to write this 1 line: try del(.spec.containers[].volumeMounts[] | select(.name | startswith("default-token-"))). I'm trying to rewrite this in Go.

            While looking for a good json library I settled on gjson/sjson. Since sjson doesn't support array accessors (the # syntax), and gjson doesn't support getting the path of result, I looked for workarounds.
            I've tried using Result.Index do delete the the result from the byte slice directly, and succeeded, but for the query I wrote (spec.containers.#.volumeMounts.#(name%\"default-token-*\")|0) the Index is always 0 (I tried different variations of it, same result).
            So currently I have some code 25 line code that uses gjson to get spec.containers.#.volumeMounts and iterate it's way through the structure and eventually use sjson.Delete to delete. It works, but it feels way more complicated then I expected it to be.

            Is there a better way to do this in Go? I'm willing to switch json library if needed.

            EDIT: I would prefer to avoid using a typed schema because I may need to perform this on different types, for some I don't have the full schema.
            (also removed some distracting details about my current implemetation)

            ...

            ANSWER

            Answered 2019-Aug-11 at 20:05

            The easiest thing to do here is parse the JSON into an object, work with that object, then serialise back into JSON.

            Kubernetes provides a Go client library that defines the v1.Pod struct you can Unmarshal onto using the stdlib encoding/json:

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install kubectl-neat

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

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

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/itaysk/kubectl-neat.git

          • CLI

            gh repo clone itaysk/kubectl-neat

          • sshUrl

            git@github.com:itaysk/kubectl-neat.git

          • 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 itaysk

            azure-tagowner

            by itayskJavaScript

            kube-conditioner

            by itayskGo

            regogo

            by itayskGo

            AzureGC

            by itayskPowerShell

            hacktober-script

            by itayskShell