From 6c9436fbd5faad62cfe29df231a6a847577894b7 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 30 May 2023 20:38:14 +0200 Subject: [PATCH] inspect: display builder features Signed-off-by: CrazyMax --- commands/inspect.go | 14 ++++++++++++++ docs/reference/buildx_inspect.md | 6 ++++++ driver/features.go | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/commands/inspect.go b/commands/inspect.go index 37c3249c..1e1f313a 100644 --- a/commands/inspect.go +++ b/commands/inspect.go @@ -10,10 +10,12 @@ import ( "time" "github.com/docker/buildx/builder" + "github.com/docker/buildx/driver" "github.com/docker/buildx/util/cobrautil/completion" "github.com/docker/buildx/util/platformutil" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/debug" "github.com/docker/go-units" "github.com/moby/buildkit/util/appcontext" "github.com/spf13/cobra" @@ -92,6 +94,18 @@ func runInspect(dockerCli command.Cli, in inspectOptions) error { fmt.Fprintf(w, "Buildkit:\t%s\n", nodes[i].Version) } fmt.Fprintf(w, "Platforms:\t%s\n", strings.Join(platformutil.FormatInGroups(n.Node.Platforms, n.Platforms), ", ")) + if debug.IsEnabled() { + fmt.Fprintf(w, "Features:\n") + features := nodes[i].Driver.Features(ctx) + featKeys := make([]string, 0, len(features)) + for k := range features { + featKeys = append(featKeys, string(k)) + } + sort.Strings(featKeys) + for _, k := range featKeys { + fmt.Fprintf(w, "\t%s:\t%t\n", k, features[driver.Feature(k)]) + } + } if len(nodes[i].Labels) > 0 { fmt.Fprintf(w, "Labels:\n") for _, k := range sortedKeys(nodes[i].Labels) { diff --git a/docs/reference/buildx_inspect.md b/docs/reference/buildx_inspect.md index fcefe75b..27dfe6af 100644 --- a/docs/reference/buildx_inspect.md +++ b/docs/reference/buildx_inspect.md @@ -84,3 +84,9 @@ GC Policy rule#3: All: true Keep Bytes: 24.21GiB ``` + +`debug` flag can also be used to get more information about the builder: + +```console +$ docker --debug buildx inspect elated_tesla +``` diff --git a/driver/features.go b/driver/features.go index d908d750..a1efa567 100644 --- a/driver/features.go +++ b/driver/features.go @@ -5,7 +5,7 @@ type Feature string const OCIExporter Feature = "OCI exporter" const DockerExporter Feature = "Docker exporter" -const CacheExport Feature = "cache export" -const MultiPlatform Feature = "multiple platforms" +const CacheExport Feature = "Cache export" +const MultiPlatform Feature = "Multiple platforms" -const HistoryAPI Feature = "history api" +const HistoryAPI Feature = "History API"