josephburnett / jd

JSON diff and patch
MIT License
826 stars 38 forks source link

Docker support #30

Closed snypelife closed 3 years ago

snypelife commented 3 years ago

Really cool tool! Any interest in having it be available as a docker image via docker hub? Would be down to contribute 👍

There's a couple diff tools that exist, but the usage/API isn't the most intuitive. jq's (and some forks) are quite good in my opinion:

Would be nice to have access to the tool, without the reliance of a local Go install.

josephburnett commented 3 years ago

Interesting idea to put jd in a docker image. I added a basic Dockerfile and pushed to my hub account. Try it out with docker run josephburnett/jd. However to make it useful it would require binding a filesystem to read input. Do you have an idea for how to make it useful?

It's also easy enough to just download the latest release binary from the Github release page: https://github.com/josephburnett/jd/releases. Doesn't require golang to be installed, it's self contained.

Yeah, jq is a great tool. I wasn't aware of diffing capability though. That's why I created this project, as a compliment to that tool. In particular I wanted to provide an easily human readable diff format for e.g. unit test results. While I was at it, I allowed for diffs to be used for patching as well. Although there are more standard formats like JSON Patch.

snypelife commented 3 years ago

Thanks, that's perfect!

Yeah I hear you on the installing the binary being pretty straight forward. For me, when I'm putting together scripts that are shared, having a binary being run as a docker container is nice because I'm not forcing people to install something on the low.

Plus, it cleans up after itself with that handy --rm flag. I got this working nice for me:

docker run --rm -i -v $PWD:$PWD -w $PWD josephburnett/jd file1.json file2.json

I also do things like wrap it in a function to make it seem like a native command:

jd(){
  docker run --rm -i -v $PWD:$PWD -w $PWD josephburnett/jd "$@"
}

cat file2.json | jd file1.json

Anyway, thanks for doing that 👍

josephburnett commented 3 years ago

That's very clever. I'll include that in the "how to" section for running jd.

I'll update the Makefile to keep :latest in sync with master. And I'll tag releases so you can pin your script dependencies.

snypelife commented 3 years ago

woot woot! that's awesome, thanks.