compose icon indicating copy to clipboard operation
compose copied to clipboard

Add JSON stream progress writer

Open felixfontein opened this issue 1 year ago • 6 comments

What I did I added a JSON stream progress writer. This allows to write machine readable output to stderr, which makes it a lot easier to use Docker Compose from other tools, like Ansible.

Related issue Fixes #10872.

(not mandatory) A picture of a cute animal, if possible in relation to what you did A cute cat with rather sharp claws, watch out when petting her

felixfontein avatar Feb 08 '24 10:02 felixfontein

I still need to run make docs and commit the changes. Unfortunately it never comes remotely near to completion with the not so great internet connection I have on this train, so that has to wait until later...

felixfontein avatar Feb 08 '24 11:02 felixfontein

Docs are updated, CI passes (checked in https://github.com/felixfontein/compose/pull/1), but while testing this (now that I was actually able to build this) I noticed that Docker Compose apparently expects Docker Buildx and Docker CLI itself to also have a JSON progress writer. I'm getting invalid progress mode json errors when it tries to pull images, and building also doesn't seem to work.

felixfontein avatar Feb 08 '24 13:02 felixfontein

I eventually noticed that in case of errors, the error is always printed regularly and not via the progress API. I added code in d3b85f9e388787e06fe514957231e1b9696e051a that in case --progress json it also formats the error as JSON.

felixfontein avatar Feb 08 '24 20:02 felixfontein

This is now ready for review.

felixfontein avatar Feb 08 '24 20:02 felixfontein

It probably makes sense to set logging to JSON (logrus.SetFormatter(&logrus.JSONFormatter{}), see https://github.com/sirupsen/logrus/blob/master/README.md) to avoid random non-JSON logging messages to show up on stderr.

felixfontein avatar Mar 03 '24 08:03 felixfontein

@ndeloof can you take another look at this? Thanks!

felixfontein avatar Jun 28 '24 13:06 felixfontein

Can you please squash your commits and rebase, I'll enable auto-merge on this PR

ndeloof avatar Jul 01 '24 13:07 ndeloof

@ndeloof thanks a lot for reviewing and merging! Since you rebase-merged I assume I don't need to rebase/squash this anymore :)

felixfontein avatar Jul 01 '24 13:07 felixfontein

auto-merge applied before squash, never mind

ndeloof avatar Jul 01 '24 14:07 ndeloof