From 6e3babc461066ef9eaf6e0a168bbc975c36ae3e0 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 9 Apr 2022 01:22:33 +0200 Subject: [PATCH] ls: display buildkit version of the nodes Signed-off-by: CrazyMax --- commands/ls.go | 6 +++--- commands/util.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/commands/ls.go b/commands/ls.go index 25c87782..15bc6f30 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -93,7 +93,7 @@ func runLs(dockerCli command.Cli, in lsOptions) error { } w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0) - fmt.Fprintf(w, "NAME/NODE\tDRIVER/ENDPOINT\tSTATUS\tPLATFORMS\n") + fmt.Fprintf(w, "NAME/NODE\tDRIVER/ENDPOINT\tSTATUS\tBUILDKIT\tPLATFORMS\n") currentSet := false for _, b := range builders { @@ -114,7 +114,7 @@ func printngi(w io.Writer, ngi *nginfo) { if ngi.err != nil { err = ngi.err.Error() } - fmt.Fprintf(w, "%s\t%s\t%s\t\n", ngi.ng.Name, ngi.ng.Driver, err) + fmt.Fprintf(w, "%s\t%s\t%s\t\t\n", ngi.ng.Name, ngi.ng.Driver, err) if ngi.err == nil { for idx, n := range ngi.ng.Nodes { d := ngi.drivers[idx] @@ -131,7 +131,7 @@ func printngi(w io.Writer, ngi *nginfo) { if err != "" { fmt.Fprintf(w, " %s\t%s\t%s\n", n.Name, n.Endpoint, err) } else { - fmt.Fprintf(w, " %s\t%s\t%s\t%s\n", n.Name, n.Endpoint, status, strings.Join(platformutil.FormatInGroups(n.Platforms, d.platforms), ", ")) + fmt.Fprintf(w, " %s\t%s\t%s\t%s\t%s\n", n.Name, n.Endpoint, status, d.version, strings.Join(platformutil.FormatInGroups(n.Platforms, d.platforms), ", ")) } } } diff --git a/commands/util.go b/commands/util.go index 5988ddde..f2339a7a 100644 --- a/commands/util.go +++ b/commands/util.go @@ -18,10 +18,12 @@ import ( ctxstore "github.com/docker/cli/cli/context/store" dopts "github.com/docker/cli/opts" dockerclient "github.com/docker/docker/client" + "github.com/moby/buildkit/util/grpcerrors" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" + "google.golang.org/grpc/codes" "k8s.io/client-go/tools/clientcmd" ) @@ -309,6 +311,16 @@ func loadInfoData(ctx context.Context, d *dinfo) error { d.platforms = append(d.platforms, w.Platforms...) } d.platforms = platformutil.Dedupe(d.platforms) + inf, err := c.Info(ctx) + if err != nil { + if st, ok := grpcerrors.AsGRPCStatus(err); ok && st.Code() == codes.Unimplemented { + d.version = "N/A" + } else { + return errors.Wrap(err, "getting info") + } + } else { + d.version = inf.BuildkitVersion.Version + } } return nil } @@ -396,6 +408,7 @@ type dinfo struct { di *build.DriverInfo info *driver.Info platforms []specs.Platform + version string err error }