Uh oh!
There was an error while loading. Please reload this page.
ls: format opt - #1787
Conversation
I was wondering if formatting should be moved to a |
thaJeztah
commented
May 11, 2023
I know there's been some shuffling around in the past between "a single formatter package, containing formatting for all (sub) commands / object-types", and "per-object-type formatters" We need to have a look what works best; the "problem" I can see with putting all formatting in a single package, is that that package would now have to depend on all object-types (packages), whereas keeping it "per-object" could (potentially) allow for more granular imports (e.g. "I only need formatting for Of course, "common" / "generic" code should be put in a place that we can share. |
thaJeztah
left a comment
There was a problem hiding this comment.
Also quick check (ISTR we have some commands that do "one" and some that do "the other); for the JSON output, do we want to use "jsonlines" (https://jsonlines.org), or an array?
- I know
jqis perfectly able to handle either - Other tools may have more difficulty with line-delimited
- For some commands we used line-delimited, because we had to handle "streaming" responses (and didn't want to load everything into memory before being able to display (👈 but this probably doesn't apply to this command (I think we would have it all in memory, nothing streaming, right?)
Uh oh!
There was an error while loading. Please reload this page.
| case formatter.TableFormatKey: | ||
| format = lsDefaultTableFormat |
There was a problem hiding this comment.
We may have been inconsistent with this; slightly wondering if we should consider the default to be a table or not. (because of the nested presentation). We probably called it "table" for docker service ps (or which one was it?)
The default presentation COULD be considered more of a tree format (moby/moby#44582 (comment)), which could keep the road open to implement a "flat" table presentation.
(I haven't fully thought this through though!) /cc @jalonsogo
There was a problem hiding this comment.
That sounds like major change that should be first done upstream and then tackled in cli plugins no?
Uh oh!
There was an error while loading. Please reload this page.
| | `.IsNode` | `true` if entry is a node | | ||
| | `.IsCurrent` | `true` if entry is the active builder | |
There was a problem hiding this comment.
Hm. I'm not sure I'm a fan of this approach for writing templates, I think we lose something from the structured data.
I think I'd rather have . be the builder, and have a .Nodes property contain a list of nodes that can be ranged or indexd to get the node details out.
There was a problem hiding this comment.
Yeah me too but that's how the cli api does it today using the formatter context. I don't think there is something else than json-lines in the cli atm (cc @thaJeztah)
There was a problem hiding this comment.
Ah I see @thaJeztah commented on this #1787 (review). I would also prefer json array tbh.
There was a problem hiding this comment.
@jedevc was that specific about the .IsCurrent() ? I know we added that because in the past we had * as part of the name, which was not ideal, and having a separate .IsCurrent() allow it to be "formatted how you'd like", but still keeping the raw name available to be used.
There was a problem hiding this comment.
Ah sorry my bad, comment on the wrong line 😢 I meant to comment on IsNode.
There was a problem hiding this comment.
I was looking at https://docs.docker.com/engine/reference/commandline/service_ps/ which has services and tasks (similar to us with builders and nodes) and it seems format only handles tasks and not services: https://docs.docker.com/engine/reference/commandline/service_ps/#format
jedevc
commented
May 11, 2023
IMO, we can keep it more specific for this PR, and as we grow the functionality we can pick the one that's most natural? I don't expect anyone outside of buildx to use that API (:pray: hopefully :pray:), so we should be fine to change it. It also feels like we might want |
| github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect | ||
| github.com/klauspost/compress v1.16.0 // indirect | ||
| github.com/mailru/easyjson v0.7.6 // indirect | ||
| github.com/mattn/go-runewidth v0.0.13 // indirect |
There was a problem hiding this comment.
You could decide to bump this to v0.0.14 already; see docker/cli#4251 (v0.0.14 looks to have various performance improvements)
crazy-max
commented
May 11, 2023
Yes this is the idea: #830 (comment) |
a18a197 to
81c9973Compare223fdf2 to
af757c8Comparecrazy-max
commented
May 12, 2023
Added |
33d7426 to
a363846Compared8bb251 to
8cde7d1Compare
tonistiigi
left a comment
There was a problem hiding this comment.
This seems to make sense to me, but I don't know if there might be compatibility issues with any other CLI commands.
| berr = strings.TrimSpace(b.err.Error()) | ||
| } | ||
| return json.Marshal(struct { | ||
| Name string |
There was a problem hiding this comment.
Just confirming, these should not be lowercase?
There was a problem hiding this comment.
Yes I don't think we should so we are aligned with the placeholders https://github.com/docker/buildx/pull/1787/files#diff-3d2c8ae27c3eb567b2564a6d5b460040e281261aa98ad464b86fc6a047892dcbR46
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
fixes#325
follow-up #830 with just the
formatopt.