Skip to content

Commit d1de435

Browse files
authored
Merge branch 'main' into refact/labels.go
2 parents bd14f68 + 1946de5 commit d1de435

32 files changed

+356
-265
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ body:
1212
Include both the current behavior (what you are seeing) as well as what you expected to happen.
1313
validations:
1414
required: true
15+
- type: markdown
16+
attributes:
17+
value: |
18+
[Docker Swarm](https://www.mirantis.com/software/swarm/) uses a distinct compose file parser and
19+
as such doesn't support some of the recent features of Docker Compose. Please contact Mirantis
20+
if you need assistance with compose file support in Docker Swarm.
1521
- type: textarea
1622
attributes:
1723
label: Steps To Reproduce

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ linters:
3030
deny:
3131
- pkg: io/ioutil
3232
desc: io/ioutil package has been deprecated
33+
- pkg: github.com/docker/docker/errdefs
34+
desc: use github.com/containerd/errdefs instead.
3335
- pkg: golang.org/x/exp/maps
3436
desc: use stdlib maps package
3537
- pkg: golang.org/x/exp/slices

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ your application are configured.
2323
Once you have a Compose file, you can create and start your application with a
2424
single command: `docker compose up`.
2525

26+
> **Note**: About Docker Swarm
27+
> Docker Swarm used to rely on the legacy compose file format but did not adopted the compose specification
28+
> so is missing some of the recent enhancements in the compose syntax. After
29+
> [acquisition by Mirantis](https://www.mirantis.com/software/swarm/) swarm isn't maintained by Docker Inc, and
30+
> as such some Docker Compose features aren't accessible to swarm users.
31+
2632
# Where to get Docker Compose
2733

2834
### Windows and macOS

cmd/cmdtrace/cmd_span.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ func Setup(cmd *cobra.Command, dockerCli command.Cli, args []string) error {
5555
ctx,
5656
"cli/"+strings.Join(commandName(cmd), "-"),
5757
)
58-
cmdSpan.SetAttributes(attribute.StringSlice("cli.flags", getFlags(cmd.Flags())))
59-
cmdSpan.SetAttributes(attribute.Bool("cli.isatty", dockerCli.In().IsTerminal()))
58+
cmdSpan.SetAttributes(
59+
attribute.StringSlice("cli.flags", getFlags(cmd.Flags())),
60+
attribute.Bool("cli.isatty", dockerCli.In().IsTerminal()),
61+
)
6062

6163
cmd.SetContext(ctx)
6264
wrapRunE(cmd, cmdSpan, tracingShutdown)

cmd/compose/build.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ type buildOptions struct {
4545
deps bool
4646
print bool
4747
check bool
48-
provenance bool
48+
sbom string
49+
provenance string
4950
}
5051

5152
func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, error) {
@@ -84,6 +85,7 @@ func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions,
8485
Check: opts.check,
8586
SSHs: SSHKeys,
8687
Builder: builderName,
88+
SBOM: opts.sbom,
8789
Provenance: opts.provenance,
8890
}, nil
8991
}
@@ -119,12 +121,14 @@ func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
119121
}
120122
flags := cmd.Flags()
121123
flags.BoolVar(&opts.push, "push", false, "Push service images")
122-
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
124+
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress the build output")
123125
flags.BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image")
124126
flags.StringArrayVar(&opts.args, "build-arg", []string{}, "Set build-time variables for services")
125127
flags.StringVar(&opts.ssh, "ssh", "", "Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent)")
126128
flags.StringVar(&opts.builder, "builder", "", "Set builder to use")
127129
flags.BoolVar(&opts.deps, "with-dependencies", false, "Also build dependencies (transitively)")
130+
flags.StringVar(&opts.provenance, "provenance", "", `Add a provenance attestation`)
131+
flags.StringVar(&opts.sbom, "sbom", "", `Add a SBOM attestation`)
128132

129133
flags.Bool("parallel", true, "Build images in parallel. DEPRECATED")
130134
flags.MarkHidden("parallel") //nolint:errcheck
@@ -156,7 +160,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, backend api.Service, o
156160
}
157161

158162
apiBuildOptions, err := opts.toAPIBuildOptions(services)
159-
apiBuildOptions.Provenance = true
163+
apiBuildOptions.Attestations = true
160164
if err != nil {
161165
return err
162166
}

cmd/compose/up.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
165165
flags.BoolVar(&create.recreateDeps, "always-recreate-deps", false, "Recreate dependent containers. Incompatible with --no-recreate.")
166166
flags.BoolVarP(&create.noInherit, "renew-anon-volumes", "V", false, "Recreate anonymous volumes instead of retrieving data from the previous containers")
167167
flags.BoolVar(&create.quietPull, "quiet-pull", false, "Pull without printing progress information")
168+
flags.BoolVar(&build.quiet, "quiet-build", false, "Suppress the build output")
168169
flags.StringArrayVar(&up.attach, "attach", []string{}, "Restrict attaching to the specified services. Incompatible with --attach-dependencies.")
169170
flags.StringArrayVar(&up.noAttach, "no-attach", []string{}, "Do not attach (stream logs) to the specified services")
170171
flags.BoolVar(&up.attachDependencies, "attach-dependencies", false, "Automatically attach to log output of dependent services")

cmd/formatter/ansi.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ func restoreCursor() {
4242
fmt.Print(ansi("8"))
4343
}
4444

45-
func hideCursor() {
46-
if disableAnsi {
47-
return
48-
}
49-
fmt.Print(ansi("[?25l"))
50-
}
51-
5245
func showCursor() {
5346
if disableAnsi {
5447
return

cmd/formatter/colors.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package formatter
1919
import (
2020
"fmt"
2121
"strconv"
22+
"strings"
2223
"sync"
2324

2425
"github.com/docker/cli/cli/command"
@@ -58,6 +59,9 @@ const (
5859
Auto = "auto"
5960
)
6061

62+
// ansiColorOffset is the offset for basic foreground colors in ANSI escape codes.
63+
const ansiColorOffset = 30
64+
6165
// SetANSIMode configure formatter for colored output on ANSI-compliant console
6266
func SetANSIMode(streams command.Streams, ansi string) {
6367
if !useAnsi(streams, ansi) {
@@ -91,11 +95,15 @@ func ansiColor(code, s string, formatOpts ...string) string {
9195

9296
// Everything about ansiColorCode color https://hyperskill.org/learn/step/18193
9397
func ansiColorCode(code string, formatOpts ...string) string {
94-
res := "\033["
98+
var sb strings.Builder
99+
sb.WriteString("\033[")
95100
for _, c := range formatOpts {
96-
res = fmt.Sprintf("%s%s;", res, c)
101+
sb.WriteString(c)
102+
sb.WriteString(";")
97103
}
98-
return fmt.Sprintf("%s%sm", res, code)
104+
sb.WriteString(code)
105+
sb.WriteString("m")
106+
return sb.String()
99107
}
100108

101109
func makeColorFunc(code string) colorFunc {
@@ -122,8 +130,8 @@ func rainbowColor() colorFunc {
122130
func init() {
123131
colors := map[string]colorFunc{}
124132
for i, name := range names {
125-
colors[name] = makeColorFunc(strconv.Itoa(30 + i))
126-
colors["intense_"+name] = makeColorFunc(strconv.Itoa(30+i) + ";1")
133+
colors[name] = makeColorFunc(strconv.Itoa(ansiColorOffset + i))
134+
colors["intense_"+name] = makeColorFunc(strconv.Itoa(ansiColorOffset+i) + ";1")
127135
}
128136
rainbow = []colorFunc{
129137
colors["cyan"],

cmd/formatter/stopping.go

Lines changed: 0 additions & 119 deletions
This file was deleted.

docs/reference/compose_build.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ run `docker compose build` to rebuild it.
2222
| `-m`, `--memory` | `bytes` | `0` | Set memory limit for the build container. Not supported by BuildKit. |
2323
| `--no-cache` | `bool` | | Do not use cache when building the image |
2424
| `--print` | `bool` | | Print equivalent bake file |
25+
| `--provenance` | `string` | | Add a provenance attestation |
2526
| `--pull` | `bool` | | Always attempt to pull a newer version of the image |
2627
| `--push` | `bool` | | Push service images |
27-
| `-q`, `--quiet` | `bool` | | Don't print anything to STDOUT |
28+
| `-q`, `--quiet` | `bool` | | Suppress the build output |
29+
| `--sbom` | `string` | | Add a SBOM attestation |
2830
| `--ssh` | `string` | | Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent) |
2931
| `--with-dependencies` | `bool` | | Also build dependencies (transitively) |
3032

0 commit comments

Comments
 (0)