diff --git a/commands/build.go b/commands/build.go index 97536508..7abe4300 100644 --- a/commands/build.go +++ b/commands/build.go @@ -338,7 +338,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) done := timeBuildCommand(mp, attributes) var resp *client.SolveResponse var retErr error - if isExperimental() { + if confutil.IsExperimental() { resp, retErr = runControllerBuild(ctx, dockerCli, opts, options, printer) } else { resp, retErr = runBasicBuild(ctx, dockerCli, opts, options, printer) @@ -589,7 +589,7 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D flags.StringArrayVar(&options.platforms, "platform", platformsDefault, "Set target platform for build") - if isExperimental() { + if confutil.IsExperimental() { flags.StringVar(&options.printFunc, "print", "", "Print result of information request (e.g., outline, targets)") cobrautil.MarkFlagsExperimental(flags, "print") } @@ -617,7 +617,7 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D flags.StringVar(&options.sbom, "sbom", "", `Shorthand for "--attest=type=sbom"`) flags.StringVar(&options.provenance, "provenance", "", `Shorthand for "--attest=type=provenance"`) - if isExperimental() { + if confutil.IsExperimental() { // TODO: move this to debug command if needed flags.StringVar(&options.Root, "root", "", "Specify root directory of server to connect") flags.BoolVar(&options.Detach, "detach", false, "Detach buildx server (supported only on linux)") @@ -762,14 +762,6 @@ func (w *wrapped) Unwrap() error { return w.err } -func isExperimental() bool { - if v, ok := os.LookupEnv("BUILDX_EXPERIMENTAL"); ok { - vv, _ := strconv.ParseBool(v) - return vv - } - return false -} - func updateLastActivity(dockerCli command.Cli, ng *store.NodeGroup) error { txn, release, err := storeutil.GetStore(dockerCli) if err != nil { diff --git a/commands/root.go b/commands/root.go index cf351200..8c0d8627 100644 --- a/commands/root.go +++ b/commands/root.go @@ -7,6 +7,7 @@ import ( imagetoolscmd "github.com/docker/buildx/commands/imagetools" "github.com/docker/buildx/controller/remote" "github.com/docker/buildx/util/cobrautil/completion" + "github.com/docker/buildx/util/confutil" "github.com/docker/buildx/util/logutil" "github.com/docker/cli-docs-tool/annotation" "github.com/docker/cli/cli" @@ -63,7 +64,7 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman "using default config store", )) - if !isExperimental() { + if !confutil.IsExperimental() { cmd.SetHelpTemplate(cmd.HelpTemplate() + "\nExperimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.\n") } @@ -96,7 +97,7 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) { duCmd(dockerCli, opts), imagetoolscmd.RootCmd(dockerCli, imagetoolscmd.RootOptions{Builder: &opts.builder}), ) - if isExperimental() { + if confutil.IsExperimental() { cmd.AddCommand(debugcmd.RootCmd(dockerCli, newDebuggableBuild(dockerCli, opts), ))