mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
ls: display buildkit version of the nodes
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@ -93,7 +93,7 @@ func runLs(dockerCli command.Cli, in lsOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
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
|
currentSet := false
|
||||||
for _, b := range builders {
|
for _, b := range builders {
|
||||||
@ -114,7 +114,7 @@ func printngi(w io.Writer, ngi *nginfo) {
|
|||||||
if ngi.err != nil {
|
if ngi.err != nil {
|
||||||
err = ngi.err.Error()
|
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 {
|
if ngi.err == nil {
|
||||||
for idx, n := range ngi.ng.Nodes {
|
for idx, n := range ngi.ng.Nodes {
|
||||||
d := ngi.drivers[idx]
|
d := ngi.drivers[idx]
|
||||||
@ -131,7 +131,7 @@ func printngi(w io.Writer, ngi *nginfo) {
|
|||||||
if err != "" {
|
if err != "" {
|
||||||
fmt.Fprintf(w, " %s\t%s\t%s\n", n.Name, n.Endpoint, err)
|
fmt.Fprintf(w, " %s\t%s\t%s\n", n.Name, n.Endpoint, err)
|
||||||
} else {
|
} 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), ", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,12 @@ import (
|
|||||||
ctxstore "github.com/docker/cli/cli/context/store"
|
ctxstore "github.com/docker/cli/cli/context/store"
|
||||||
dopts "github.com/docker/cli/opts"
|
dopts "github.com/docker/cli/opts"
|
||||||
dockerclient "github.com/docker/docker/client"
|
dockerclient "github.com/docker/docker/client"
|
||||||
|
"github.com/moby/buildkit/util/grpcerrors"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"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 = append(d.platforms, w.Platforms...)
|
||||||
}
|
}
|
||||||
d.platforms = platformutil.Dedupe(d.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
|
return nil
|
||||||
}
|
}
|
||||||
@ -396,6 +408,7 @@ type dinfo struct {
|
|||||||
di *build.DriverInfo
|
di *build.DriverInfo
|
||||||
info *driver.Info
|
info *driver.Info
|
||||||
platforms []specs.Platform
|
platforms []specs.Platform
|
||||||
|
version string
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user