Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ func (o *buildOptions) toOptions() (*BuildOptions, error) {
}

func (o *buildOptions) toDisplayMode() (progressui.DisplayMode, error) {
progress := progressui.DisplayMode(o.progress)
progressMode := o.progress
if progressMode == "quiet" {
o.quiet = true
}
if progressMode == "none" { // in buildx "quiet" means printing image ID in the end
progressMode = "quiet"
}
progress := progressui.DisplayMode(progressMode)
if o.quiet {
if progress != progressui.AutoMode && progress != progressui.QuietMode {
return "", errors.Errorf("progress=%s and quiet cannot be used together", o.progress)
Expand Down Expand Up @@ -386,7 +393,9 @@ func runBuild(ctx context.Context, dockerCli command.Cli, debugOpts debuggerOpti
case progressui.RawJSONMode:
// no additional display
case progressui.QuietMode:
fmt.Println(getImageID(resp.ExporterResponse))
if options.quiet {
fmt.Println(getImageID(resp.ExporterResponse))
}
default:
desktop.PrintBuildDetails(os.Stderr, printer.BuildRefs(), term)
}
Expand Down Expand Up @@ -624,7 +633,7 @@ type commonFlags struct {

func commonBuildFlags(options *commonFlags, flags *pflag.FlagSet) {
options.noCache = flags.Bool("no-cache", false, "Do not use cache when building the image")
flags.StringVar(&options.progress, "progress", "auto", `Set type of progress output ("auto", "quiet", "plain", "tty", "rawjson"). Use plain to show container output`)
flags.StringVar(&options.progress, "progress", "auto", `Set type of progress output ("auto", "none", "plain", "quiet", "rawjson", "tty"). Use plain to show container output`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be more straightforward to modify the --quiet flag.

If you change quiet to be an integer, you can use pflag.CountVarP so -qq will be "very" quiet. Then we can also add --progress=none and have it set o.quiet = 2. If o.quiet <= 1 then we'll print the image id.

I think that will keep backwards compatibility and will be an easier command line experience.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. --quiet is a boolean atm. Afaics you can't change its type in a backwards-compatible way.

This isn't about extending the capabilites of --quiet. For me it is flag that you should never use and only provided for historic reasons. Ideally we should have left the printing on image ID only to --quiet and make --progress=quiet actually return empty progress but can't change that anymore.

options.pull = flags.Bool("pull", false, "Always attempt to pull all referenced images")
flags.StringVar(&options.metadataFile, "metadata-file", "", "Write build result metadata to a file")
}
Expand Down
9 changes: 7 additions & 2 deletions commands/dial_stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ func runDialStdio(dockerCli command.Cli, opts stdioOptions) error {
return err
}

printer, err := progress.NewPrinter(ctx, os.Stderr, progressui.DisplayMode(opts.progress), progress.WithPhase("dial-stdio"), progress.WithDesc("builder: "+b.Name, "builder:"+b.Name))
progressMode := opts.progress
if progressMode == "none" { // in buildx "quiet" means printing image ID in the end
progressMode = "quiet"
}

printer, err := progress.NewPrinter(ctx, os.Stderr, progressui.DisplayMode(progressMode), progress.WithPhase("dial-stdio"), progress.WithDesc("builder: "+b.Name, "builder:"+b.Name))
if err != nil {
return err
}
Expand Down Expand Up @@ -127,6 +132,6 @@ func dialStdioCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {

flags := cmd.Flags()
flags.StringVar(&opts.platform, "platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), "Target platform: this is used for node selection")
flags.StringVar(&opts.progress, "progress", "quiet", `Set type of progress output ("auto", "plain", "tty", "rawjson"). Use plain to show container output`)
flags.StringVar(&opts.progress, "progress", "none", `Set type of progress output ("auto", "plain", "rawjson", "tty"). Use plain to show container output`)
return cmd
}
8 changes: 6 additions & 2 deletions commands/imagetools/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ func runCreate(ctx context.Context, dockerCli command.Cli, in createOptions, arg

ctx2, cancel := context.WithCancelCause(context.TODO())
defer func() { cancel(errors.WithStack(context.Canceled)) }()
printer, err := progress.NewPrinter(ctx2, os.Stderr, progressui.DisplayMode(in.progress))
progressMode := in.progress
if progressMode == "none" {
progressMode = "quiet"
}
printer, err := progress.NewPrinter(ctx2, os.Stderr, progressui.DisplayMode(progressMode))
if err != nil {
return err
}
Expand Down Expand Up @@ -288,7 +292,7 @@ func createCmd(dockerCli command.Cli, opts RootOptions) *cobra.Command {
flags.StringArrayVarP(&options.tags, "tag", "t", []string{}, "Set reference for new image")
flags.BoolVar(&options.dryrun, "dry-run", false, "Show final image instead of pushing")
flags.BoolVar(&options.actionAppend, "append", false, "Append to existing manifest")
flags.StringVar(&options.progress, "progress", "auto", `Set type of progress output ("auto", "plain", "tty", "rawjson"). Use plain to show container output`)
flags.StringVar(&options.progress, "progress", "auto", `Set type of progress output ("auto", "none", "plain", "rawjson", "tty"). Use plain to show container output`)
flags.StringArrayVarP(&options.annotations, "annotation", "", []string{}, "Add annotation to the image")
flags.BoolVar(&options.preferIndex, "prefer-index", true, "When only a single source is specified, prefer outputting an image index or manifest list instead of performing a carbon copy")

Expand Down
38 changes: 19 additions & 19 deletions docs/reference/buildx_bake.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ Build from a file

### Options

| Name | Type | Default | Description |
|:------------------------------------|:--------------|:--------|:-------------------------------------------------------------------------------------------------------------|
| [`--allow`](#allow) | `stringArray` | | Allow build to access specified resources |
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
| `-D`, `--debug` | `bool` | | Enable debug logging |
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Build definition file |
| [`--list`](#list) | `string` | | List targets or variables |
| [`--load`](#load) | `bool` | | Shorthand for `--set=*.output=type=docker`. Conditional. |
| [`--metadata-file`](#metadata-file) | `string` | | Write build result metadata to a file |
| [`--no-cache`](#no-cache) | `bool` | | Do not use cache when building the image |
| [`--print`](#print) | `bool` | | Print the options without building |
| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `quiet`, `plain`, `tty`, `rawjson`). Use plain to show container output |
| [`--provenance`](#provenance) | `string` | | Shorthand for `--set=*.attest=type=provenance` |
| [`--pull`](#pull) | `bool` | | Always attempt to pull all referenced images |
| [`--push`](#push) | `bool` | | Shorthand for `--set=*.output=type=registry`. Conditional. |
| [`--sbom`](#sbom) | `string` | | Shorthand for `--set=*.attest=type=sbom` |
| [`--set`](#set) | `stringArray` | | Override target value (e.g., `targetpattern.key=value`) |
| Name | Type | Default | Description |
|:------------------------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------------------------|
| [`--allow`](#allow) | `stringArray` | | Allow build to access specified resources |
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
| `-D`, `--debug` | `bool` | | Enable debug logging |
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Build definition file |
| [`--list`](#list) | `string` | | List targets or variables |
| [`--load`](#load) | `bool` | | Shorthand for `--set=*.output=type=docker`. Conditional. |
| [`--metadata-file`](#metadata-file) | `string` | | Write build result metadata to a file |
| [`--no-cache`](#no-cache) | `bool` | | Do not use cache when building the image |
| [`--print`](#print) | `bool` | | Print the options without building |
| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `none`, `plain`, `quiet`, `rawjson`, `tty`). Use plain to show container output |
| [`--provenance`](#provenance) | `string` | | Shorthand for `--set=*.attest=type=provenance` |
| [`--pull`](#pull) | `bool` | | Always attempt to pull all referenced images |
| [`--push`](#push) | `bool` | | Shorthand for `--set=*.output=type=registry`. Conditional. |
| [`--sbom`](#sbom) | `string` | | Shorthand for `--set=*.attest=type=sbom` |
| [`--set`](#set) | `stringArray` | | Override target value (e.g., `targetpattern.key=value`) |


<!---MARKER_GEN_END-->
Expand Down
Loading