slim icon indicating copy to clipboard operation
slim copied to clipboard

Console output as json with a flag to control when the console output is free form text and when it's json

Open kcq opened this issue 3 years ago • 16 comments

Need to have a global flag to control the console output mode (--json-output or something like that).

kcq avatar Dec 08 '21 03:12 kcq

@kcq Could I take a stab at this?

loganshamberger avatar Dec 30 '21 06:12 loganshamberger

Go for it @loganshamberger :) Let me know if you'd like to do a code walk through to learn about the execution context used for I/O and other things.

kcq avatar Dec 30 '21 07:12 kcq

@kcq I think that would be helpful. I've pulled it down and am just trying to get the code built and run to start.

loganshamberger avatar Dec 30 '21 17:12 loganshamberger

@kcq hey , is someone still working on this?

rghdrizzle avatar Apr 20 '22 13:04 rghdrizzle

still open and still TBD :)

kcq avatar Apr 20 '22 17:04 kcq

Hi @kcq is someone still working on it?

akankshakumari393 avatar Jun 18 '22 05:06 akankshakumari393

@akankshakumari393 are you interested in contributing this enhancement :)

kcq avatar Jun 18 '22 05:06 kcq

@kcq yeah I am interested.

akankshakumari393 avatar Jun 18 '22 05:06 akankshakumari393

@kcq yeah I am interested.

Let's chat then :)

kcq avatar Jun 18 '22 06:06 kcq

hey @kcq, I am new to it, could you please suggest me where do we start with?

akankshakumari393 avatar Jun 21 '22 05:06 akankshakumari393

@akankshakumari393 when are you online? I can give you an overview.

A few notes to get you started in the meantime...

The docker-slim I/O happens using the ExecutionContext construct ( https://github.com/docker-slim/docker-slim/blob/master/pkg/app/execontext.go ). TheExecutionContext.Output.Info(), ExecutionContext.Output.State(), ExecutionContext.Output.Message() and ExecutionContext.Output.Error() calls are responsible for the actual console output and that's where we need to conditionally print using the standard formatting or json.

The docker-slim commands are here and that's where the ExecutionContext struct is used for I/O: https://github.com/docker-slim/docker-slim/tree/master/pkg/app/master/commands

Example:

			xc.Out.Info("params",
				ovars{
					"target.type":   "image",
					"target":        targetRef,
					"continue.mode": continueAfter.Mode,
					"rt.as.user":    doRunTargetAsUser,
					"keep.perms":    doKeepPerms,
					"tags":          strings.Join(outputTags, ","),
				})

https://github.com/docker-slim/docker-slim/blob/master/pkg/app/master/commands/build/handler.go#L255

Also a couple of videos to watch:

https://www.youtube.com/watch?v=Y60g3Jz2Fg8&t=14s https://www.youtube.com/watch?v=ioIG-oPg0pA&t=60s

kcq avatar Jun 22 '22 16:06 kcq

Hey thanks, I will go through these references and will let you know in case I have any doubt. we can then discuss.

akankshakumari393 avatar Jun 23 '22 17:06 akankshakumari393

@kcq How is the globalflag --log-format different from the json-output that we are gonna add?

akankshakumari393 avatar Jun 25 '22 09:06 akankshakumari393

The log-format flag is for the logging data output. The standard app output data is different from the logging data, which is usually disabled and you enable it when you need additional debugging information. Both end up being printed to the screen, but they are independent of each other.

kcq avatar Jun 25 '22 17:06 kcq

@akankshakumari393 let me know if you want to do an online session next week to go over the enhancements

kcq avatar Jul 03 '22 17:07 kcq

@kcq I won't be available this week. I would be good if we can schedule it to next week.

akankshakumari393 avatar Jul 06 '22 04:07 akankshakumari393