Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed223bc820 | |||
| fab55e13ce | |||
| 2fcff17544 | |||
| b74d8e1a53 | |||
| 3789f8a39e | |||
| d3485b9e9f | |||
| 613380299f | |||
| b83959e001 | |||
| 28a08a22b9 | |||
| 8e0393932b | |||
| efd052eb85 | |||
| cdd81d6559 | |||
| d9770a962e | |||
| 6efe73abe0 | |||
| d977531018 | |||
| e9f843bf04 | |||
| cfbaee4689 | |||
| daeee46977 | |||
| 08ad72160f | |||
| 3c4fe7b3e6 | |||
| 98ffe42d84 | |||
| 0d5df48121 | |||
| bf081eec36 | |||
| dc45bcc993 | |||
| 710dd00e95 | |||
| bf632329d2 | |||
| 724548bc7d | |||
| 3c6c0bce1c | |||
| 65655cc262 | |||
| 580730fce9 | |||
| 11606268f8 | |||
| 27a19966fb | |||
| a8987063b3 | |||
| b74562d917 | |||
| c0e376854b | |||
| 3bc4543f83 | |||
| 1481c8ce9a | |||
| b17b6b562d | |||
| e97c765575 |
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -63,7 +63,7 @@ jobs:
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.20.6
|
||||
go-version: 1.20.7
|
||||
-
|
||||
name: Test
|
||||
run: |
|
||||
|
||||
@ -117,7 +117,10 @@ issues:
|
||||
- text: "package-comments: should have a package comment"
|
||||
linters:
|
||||
- revive
|
||||
|
||||
# FIXME temporarily suppress these (see https://github.com/gotestyourself/gotest.tools/issues/272)
|
||||
- text: "SA1019: (assert|cmp|is)\\.ErrorType is deprecated"
|
||||
linters:
|
||||
- staticcheck
|
||||
# Exclude some linters from running on tests files.
|
||||
- path: _test\.go
|
||||
linters:
|
||||
|
||||
@ -192,7 +192,7 @@ For more details, see the [MAINTAINERS](MAINTAINERS) page.
|
||||
The sign-off is a simple line at the end of the explanation for the patch. Your
|
||||
signature certifies that you wrote the patch or otherwise have the right to pass
|
||||
it on as an open-source patch. The rules are pretty simple: if you can certify
|
||||
the below (from [developercertificate.org](http://developercertificate.org/)):
|
||||
the below (from [developercertificate.org](https://developercertificate.org):
|
||||
|
||||
```
|
||||
Developer Certificate of Origin
|
||||
@ -336,9 +336,8 @@ The rules:
|
||||
1. All code should be formatted with `gofumpt` (preferred) or `gofmt -s`.
|
||||
2. All code should pass the default levels of
|
||||
[`golint`](https://github.com/golang/lint).
|
||||
3. All code should follow the guidelines covered in [Effective
|
||||
Go](http://golang.org/doc/effective_go.html) and [Go Code Review
|
||||
Comments](https://github.com/golang/go/wiki/CodeReviewComments).
|
||||
3. All code should follow the guidelines covered in [Effective Go](https://go.dev/doc/effective_go)
|
||||
and [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments).
|
||||
4. Comment the code. Tell us the why, the history and the context.
|
||||
5. Document _all_ declarations and methods, even private ones. Declare
|
||||
expectations, caveats and anything else that may be important. If a type
|
||||
@ -360,6 +359,6 @@ The rules:
|
||||
guidelines. Since you've read all the rules, you now know that.
|
||||
|
||||
If you are having trouble getting into the mood of idiomatic Go, we recommend
|
||||
reading through [Effective Go](https://golang.org/doc/effective_go.html). The
|
||||
[Go Blog](https://blog.golang.org) is also a great resource. Drinking the
|
||||
reading through [Effective Go](https://go.dev/doc/effective_go). The
|
||||
[Go Blog](https://go.dev/blog/) is also a great resource. Drinking the
|
||||
kool-aid is a lot easier than going thirsty.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG BASE_VARIANT=alpine
|
||||
ARG GO_VERSION=1.20.6
|
||||
ARG GO_VERSION=1.20.7
|
||||
ARG ALPINE_VERSION=3.17
|
||||
ARG XX_VERSION=1.2.1
|
||||
ARG GOVERSIONINFO_VERSION=v1.3.0
|
||||
|
||||
@ -3,28 +3,28 @@ package command
|
||||
import (
|
||||
"sync"
|
||||
|
||||
eventtypes "github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// EventHandler is abstract interface for user to customize
|
||||
// own handle functions of each type of events
|
||||
type EventHandler interface {
|
||||
Handle(action string, h func(eventtypes.Message))
|
||||
Watch(c <-chan eventtypes.Message)
|
||||
Handle(action string, h func(events.Message))
|
||||
Watch(c <-chan events.Message)
|
||||
}
|
||||
|
||||
// InitEventHandler initializes and returns an EventHandler
|
||||
func InitEventHandler() EventHandler {
|
||||
return &eventHandler{handlers: make(map[string]func(eventtypes.Message))}
|
||||
return &eventHandler{handlers: make(map[string]func(events.Message))}
|
||||
}
|
||||
|
||||
type eventHandler struct {
|
||||
handlers map[string]func(eventtypes.Message)
|
||||
handlers map[string]func(events.Message)
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (w *eventHandler) Handle(action string, h func(eventtypes.Message)) {
|
||||
func (w *eventHandler) Handle(action string, h func(events.Message)) {
|
||||
w.mu.Lock()
|
||||
w.handlers[action] = h
|
||||
w.mu.Unlock()
|
||||
@ -33,7 +33,7 @@ func (w *eventHandler) Handle(action string, h func(eventtypes.Message)) {
|
||||
// Watch ranges over the passed in event chan and processes the events based on the
|
||||
// handlers created for a given action.
|
||||
// To stop watching, close the event chan.
|
||||
func (w *eventHandler) Watch(c <-chan eventtypes.Message) {
|
||||
func (w *eventHandler) Watch(c <-chan events.Message) {
|
||||
for e := range c {
|
||||
w.mu.Lock()
|
||||
h, exists := w.handlers[e.Action]
|
||||
|
||||
@ -128,7 +128,7 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
|
||||
flags.Int64Var(&options.cpuQuota, "cpu-quota", 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
|
||||
flags.StringVar(&options.cpuSetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
|
||||
flags.StringVar(&options.cpuSetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
|
||||
flags.StringVar(&options.cgroupParent, "cgroup-parent", "", "Optional parent cgroup for the container")
|
||||
flags.StringVar(&options.cgroupParent, "cgroup-parent", "", `Set the parent cgroup for the "RUN" instructions during build`)
|
||||
flags.StringVar(&options.isolation, "isolation", "", "Container isolation technology")
|
||||
flags.Var(&options.labels, "label", "Set metadata for an image")
|
||||
flags.BoolVar(&options.noCache, "no-cache", false, "Do not use cache when building the image")
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/moby/buildkit/frontend/dockerfile/dockerignore"
|
||||
"github.com/moby/patternmatcher"
|
||||
"github.com/moby/patternmatcher/ignorefile"
|
||||
)
|
||||
|
||||
// ReadDockerignore reads the .dockerignore file in the context directory and
|
||||
@ -22,7 +23,11 @@ func ReadDockerignore(contextDir string) ([]string, error) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return dockerignore.ReadAll(f)
|
||||
patterns, err := ignorefile.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading .dockerignore: %w", err)
|
||||
}
|
||||
return patterns, nil
|
||||
}
|
||||
|
||||
// TrimBuildFilesFromExcludes removes the named Dockerfile and .dockerignore from
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
"gotest.tools/v3/skip"
|
||||
)
|
||||
|
||||
func TestNewHistoryCommandErrors(t *testing.T) {
|
||||
@ -43,13 +42,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func notUTCTimezone() bool {
|
||||
now := time.Now()
|
||||
return now != now.UTC()
|
||||
}
|
||||
|
||||
func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||
skip.If(t, notUTCTimezone, "expected output requires UTC timezone")
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
@ -62,6 +55,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||
return []image.HistoryResponseItem{{
|
||||
ID: "1234567890123456789",
|
||||
Created: time.Now().Unix(),
|
||||
Comment: "none",
|
||||
}}, nil
|
||||
},
|
||||
},
|
||||
@ -93,13 +87,19 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
||||
cmd := NewHistoryCommand(cli)
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.NilError(t, err)
|
||||
actual := cli.OutBuffer().String()
|
||||
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// Set to UTC timezone as timestamps in output are
|
||||
// printed in the current timezone
|
||||
t.Setenv("TZ", "UTC")
|
||||
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
||||
cmd := NewHistoryCommand(cli)
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.NilError(t, err)
|
||||
actual := cli.OutBuffer().String()
|
||||
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
IMAGE CREATED AT CREATED BY SIZE COMMENT
|
||||
abcdef 2017-01-01T12:00:03Z rose 0 new history item!
|
||||
IMAGE CREATED AT CREATED BY SIZE COMMENT
|
||||
abcdef 2017-01-01T12:00:03Z rose 0 new history item!
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
123456789012 Less than a second ago 0B
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
123456789012 Less than a second ago 0B none
|
||||
|
||||
@ -16,7 +16,7 @@ type osArch struct {
|
||||
|
||||
// Remove any unsupported os/arch combo
|
||||
// list of valid os/arch values (see "Optional Environment Variables" section
|
||||
// of https://golang.org/doc/install/source
|
||||
// of https://go.dev/doc/install/source
|
||||
// Added linux/s390x as we know System z support already exists
|
||||
// Keep in sync with _docker_manifest_annotate in contrib/completion/bash/docker
|
||||
var validOSArches = map[osArch]bool{
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
configtypes "github.com/docker/cli/cli/config/types"
|
||||
"github.com/docker/cli/cli/hints"
|
||||
"github.com/docker/cli/cli/streams"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/docker/docker/api/types"
|
||||
@ -19,6 +20,10 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const patSuggest = "You can log in with your password or a Personal Access " +
|
||||
"Token (PAT). Using a limited-scope PAT grants better security and is required " +
|
||||
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
|
||||
|
||||
// EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload.
|
||||
//
|
||||
// Deprecated: use [registrytypes.EncodeAuthConfig] instead.
|
||||
@ -113,7 +118,11 @@ func ConfigureAuth(cli Cli, flUser, flPassword string, authconfig *registrytypes
|
||||
if flUser = strings.TrimSpace(flUser); flUser == "" {
|
||||
if isDefaultRegistry {
|
||||
// if this is a default registry (docker hub), then display the following message.
|
||||
fmt.Fprintln(cli.Out(), "Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.")
|
||||
fmt.Fprintln(cli.Out(), "Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.")
|
||||
if hints.Enabled() {
|
||||
fmt.Fprintln(cli.Out(), patSuggest)
|
||||
fmt.Fprintln(cli.Out())
|
||||
}
|
||||
}
|
||||
promptWithDefault(cli.Out(), "Username", authconfig.Username)
|
||||
var err error
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
@ -12,6 +13,7 @@ type fakeClient struct {
|
||||
|
||||
version string
|
||||
serverVersion func(ctx context.Context) (types.Version, error)
|
||||
eventsFn func(context.Context, types.EventsOptions) (<-chan events.Message, <-chan error)
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) {
|
||||
@ -21,3 +23,7 @@ func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error)
|
||||
func (cli *fakeClient) ClientVersion() string {
|
||||
return cli.version
|
||||
}
|
||||
|
||||
func (cli *fakeClient) Events(ctx context.Context, opts types.EventsOptions) (<-chan events.Message, <-chan error) {
|
||||
return cli.eventsFn(ctx, opts)
|
||||
}
|
||||
|
||||
@ -12,10 +12,12 @@ import (
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/cli/templates"
|
||||
"github.com/docker/docker/api/types"
|
||||
eventtypes "github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -47,7 +49,7 @@ func NewEventsCommand(dockerCli command.Cli) *cobra.Command {
|
||||
flags.StringVar(&options.since, "since", "", "Show all events created since timestamp")
|
||||
flags.StringVar(&options.until, "until", "", "Stream events until this timestamp")
|
||||
flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")
|
||||
flags.StringVar(&options.format, "format", "", "Format the output using the given Go template")
|
||||
flags.StringVar(&options.format, "format", "", flagsHelper.InspectFormatHelp) // using the same flag description as "inspect" commands for now.
|
||||
|
||||
return cmd
|
||||
}
|
||||
@ -60,21 +62,19 @@ func runEvents(dockerCli command.Cli, options *eventsOptions) error {
|
||||
Status: "Error parsing format: " + err.Error(),
|
||||
}
|
||||
}
|
||||
eventOptions := types.EventsOptions{
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
evts, errs := dockerCli.Client().Events(ctx, types.EventsOptions{
|
||||
Since: options.since,
|
||||
Until: options.until,
|
||||
Filters: options.filter.Value(),
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
events, errs := dockerCli.Client().Events(ctx, eventOptions)
|
||||
})
|
||||
defer cancel()
|
||||
|
||||
out := dockerCli.Out()
|
||||
|
||||
for {
|
||||
select {
|
||||
case event := <-events:
|
||||
case event := <-evts:
|
||||
if err := handleEvent(out, event, tmpl); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -87,7 +87,7 @@ func runEvents(dockerCli command.Cli, options *eventsOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
func handleEvent(out io.Writer, event eventtypes.Message, tmpl *template.Template) error {
|
||||
func handleEvent(out io.Writer, event events.Message, tmpl *template.Template) error {
|
||||
if tmpl == nil {
|
||||
return prettyPrintEvent(out, event)
|
||||
}
|
||||
@ -96,16 +96,19 @@ func handleEvent(out io.Writer, event eventtypes.Message, tmpl *template.Templat
|
||||
}
|
||||
|
||||
func makeTemplate(format string) (*template.Template, error) {
|
||||
if format == "" {
|
||||
switch format {
|
||||
case "":
|
||||
return nil, nil
|
||||
case formatter.JSONFormatKey:
|
||||
format = formatter.JSONFormat
|
||||
}
|
||||
tmpl, err := templates.Parse(format)
|
||||
if err != nil {
|
||||
return tmpl, err
|
||||
}
|
||||
// we execute the template for an empty message, so as to validate
|
||||
// a bad template like "{{.badFieldString}}"
|
||||
return tmpl, tmpl.Execute(io.Discard, &eventtypes.Message{})
|
||||
// execute the template on an empty message to validate a bad
|
||||
// template like "{{.badFieldString}}"
|
||||
return tmpl, tmpl.Execute(io.Discard, &events.Message{})
|
||||
}
|
||||
|
||||
// rfc3339NanoFixed is similar to time.RFC3339Nano, except it pads nanoseconds
|
||||
@ -115,7 +118,7 @@ const rfc3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
|
||||
// prettyPrintEvent prints all types of event information.
|
||||
// Each output includes the event type, actor id, name and action.
|
||||
// Actor attributes are printed at the end if the actor has any.
|
||||
func prettyPrintEvent(out io.Writer, event eventtypes.Message) error {
|
||||
func prettyPrintEvent(out io.Writer, event events.Message) error {
|
||||
if event.TimeNano != 0 {
|
||||
fmt.Fprintf(out, "%s ", time.Unix(0, event.TimeNano).Format(rfc3339NanoFixed))
|
||||
} else if event.Time != 0 {
|
||||
@ -141,7 +144,7 @@ func prettyPrintEvent(out io.Writer, event eventtypes.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func formatEvent(out io.Writer, event eventtypes.Message, tmpl *template.Template) error {
|
||||
func formatEvent(out io.Writer, event events.Message, tmpl *template.Template) error {
|
||||
defer out.Write([]byte{'\n'})
|
||||
return tmpl.Execute(out, event)
|
||||
}
|
||||
|
||||
83
cli/command/system/events_test.go
Normal file
83
cli/command/system/events_test.go
Normal file
@ -0,0 +1,83 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
|
||||
func TestEventsFormat(t *testing.T) {
|
||||
var evts []events.Message
|
||||
for i, action := range []string{"create", "start", "attach", "die"} {
|
||||
evts = append(evts, events.Message{
|
||||
Status: action,
|
||||
ID: "abc123",
|
||||
From: "ubuntu:latest",
|
||||
Type: events.ContainerEventType,
|
||||
Action: action,
|
||||
Actor: events.Actor{
|
||||
ID: "abc123",
|
||||
Attributes: map[string]string{"image": "ubuntu:latest"},
|
||||
},
|
||||
Scope: "local",
|
||||
Time: int64(time.Second) * int64(i+1),
|
||||
TimeNano: int64(time.Second) * int64(i+1),
|
||||
})
|
||||
}
|
||||
tests := []struct {
|
||||
name, format string
|
||||
}{
|
||||
{
|
||||
name: "default",
|
||||
},
|
||||
{
|
||||
name: "json",
|
||||
format: "json",
|
||||
},
|
||||
{
|
||||
name: "json template",
|
||||
format: "{{ json . }}",
|
||||
},
|
||||
{
|
||||
name: "json action",
|
||||
format: "{{ json .Action }}",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// Set to UTC timezone as timestamps in output are
|
||||
// printed in the current timezone
|
||||
t.Setenv("TZ", "UTC")
|
||||
cli := test.NewFakeCli(&fakeClient{eventsFn: func(context.Context, types.EventsOptions) (<-chan events.Message, <-chan error) {
|
||||
messages := make(chan events.Message)
|
||||
errs := make(chan error, 1)
|
||||
go func() {
|
||||
for _, msg := range evts {
|
||||
messages <- msg
|
||||
}
|
||||
errs <- io.EOF
|
||||
}()
|
||||
return messages, errs
|
||||
}})
|
||||
cmd := NewEventsCommand(cli)
|
||||
if tc.format != "" {
|
||||
cmd.Flags().Set("format", tc.format)
|
||||
}
|
||||
assert.Check(t, cmd.Execute())
|
||||
out := cli.OutBuffer().String()
|
||||
assert.Check(t, golden.String(out, fmt.Sprintf("docker-events-%s.golden", strings.ReplaceAll(tc.name, " ", "-"))))
|
||||
cli.OutBuffer().Reset()
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ func newPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||
flags := cmd.Flags()
|
||||
flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
|
||||
flags.BoolVarP(&options.all, "all", "a", false, "Remove all unused images not just dangling ones")
|
||||
flags.BoolVar(&options.pruneVolumes, "volumes", false, "Prune volumes")
|
||||
flags.BoolVar(&options.pruneVolumes, "volumes", false, "Prune anonymous volumes")
|
||||
flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=<key>=<value>")`)
|
||||
// "filter" flag is available in 1.28 (docker 17.04) and up
|
||||
flags.SetAnnotation("filter", "version", []string{"1.28"})
|
||||
@ -114,7 +114,7 @@ func confirmationMessage(dockerCli command.Cli, options pruneOptions) string {
|
||||
"all networks not used by at least one container",
|
||||
}
|
||||
if options.pruneVolumes {
|
||||
warnings = append(warnings, "all volumes not used by at least one container")
|
||||
warnings = append(warnings, "all anonymous volumes not used by at least one container")
|
||||
}
|
||||
if options.all {
|
||||
warnings = append(warnings, "all images without at least one container associated to them")
|
||||
|
||||
4
cli/command/system/testdata/docker-events-default.golden
vendored
Normal file
4
cli/command/system/testdata/docker-events-default.golden
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
1970-01-01T00:00:01.000000000Z container create abc123 (image=ubuntu:latest)
|
||||
1970-01-01T00:00:02.000000000Z container start abc123 (image=ubuntu:latest)
|
||||
1970-01-01T00:00:03.000000000Z container attach abc123 (image=ubuntu:latest)
|
||||
1970-01-01T00:00:04.000000000Z container die abc123 (image=ubuntu:latest)
|
||||
4
cli/command/system/testdata/docker-events-json-action.golden
vendored
Normal file
4
cli/command/system/testdata/docker-events-json-action.golden
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
"create"
|
||||
"start"
|
||||
"attach"
|
||||
"die"
|
||||
4
cli/command/system/testdata/docker-events-json-template.golden
vendored
Normal file
4
cli/command/system/testdata/docker-events-json-template.golden
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{"status":"create","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"create","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":1000000000,"timeNano":1000000000}
|
||||
{"status":"start","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"start","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":2000000000,"timeNano":2000000000}
|
||||
{"status":"attach","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"attach","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":3000000000,"timeNano":3000000000}
|
||||
{"status":"die","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"die","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":4000000000,"timeNano":4000000000}
|
||||
4
cli/command/system/testdata/docker-events-json.golden
vendored
Normal file
4
cli/command/system/testdata/docker-events-json.golden
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{"status":"create","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"create","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":1000000000,"timeNano":1000000000}
|
||||
{"status":"start","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"start","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":2000000000,"timeNano":2000000000}
|
||||
{"status":"attach","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"attach","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":3000000000,"timeNano":3000000000}
|
||||
{"status":"die","id":"abc123","from":"ubuntu:latest","Type":"container","Action":"die","Actor":{"ID":"abc123","Attributes":{"image":"ubuntu:latest"}},"scope":"local","time":4000000000,"timeNano":4000000000}
|
||||
@ -27,7 +27,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "prune [OPTIONS]",
|
||||
Short: "Remove all unused local volumes",
|
||||
Short: "Remove unused local volumes",
|
||||
Args: cli.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
spaceReclaimed, output, err := runPrune(dockerCli, options)
|
||||
|
||||
18
cli/hints/hints.go
Normal file
18
cli/hints/hints.go
Normal file
@ -0,0 +1,18 @@
|
||||
package hints
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Enabled returns whether cli hints are enabled or not
|
||||
func Enabled() bool {
|
||||
if v := os.Getenv("DOCKER_CLI_HINTS"); v != "" {
|
||||
enabled, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return enabled
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
manifesttypes "github.com/docker/cli/cli/manifest/types"
|
||||
"github.com/docker/cli/cli/trust"
|
||||
"github.com/docker/distribution"
|
||||
"github.com/docker/distribution/reference"
|
||||
distributionclient "github.com/docker/distribution/registry/client"
|
||||
@ -77,6 +78,7 @@ func (c *client) MountBlob(ctx context.Context, sourceRef reference.Canonical, t
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repoEndpoint.actions = trust.ActionsPushAndPull
|
||||
repo, err := c.getRepositoryForReference(ctx, targetRef, repoEndpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -102,6 +104,7 @@ func (c *client) PutManifest(ctx context.Context, ref reference.Named, manifest
|
||||
return digest.Digest(""), err
|
||||
}
|
||||
|
||||
repoEndpoint.actions = trust.ActionsPushAndPull
|
||||
repo, err := c.getRepositoryForReference(ctx, ref, repoEndpoint)
|
||||
if err != nil {
|
||||
return digest.Digest(""), err
|
||||
@ -151,7 +154,9 @@ func (c *client) getHTTPTransportForRepoEndpoint(ctx context.Context, repoEndpoi
|
||||
c.authConfigResolver(ctx, repoEndpoint.info.Index),
|
||||
repoEndpoint.endpoint,
|
||||
repoEndpoint.Name(),
|
||||
c.userAgent)
|
||||
c.userAgent,
|
||||
repoEndpoint.actions,
|
||||
)
|
||||
return httpTransport, errors.Wrap(err, "failed to configure transport")
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/docker/cli/cli/trust"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/docker/distribution/registry/client/auth"
|
||||
"github.com/docker/distribution/registry/client/transport"
|
||||
@ -17,6 +18,7 @@ import (
|
||||
type repositoryEndpoint struct {
|
||||
info *registry.RepositoryInfo
|
||||
endpoint registry.APIEndpoint
|
||||
actions []string
|
||||
}
|
||||
|
||||
// Name returns the repository name
|
||||
@ -74,7 +76,7 @@ func getDefaultEndpointFromRepoInfo(repoInfo *registry.RepositoryInfo) (registry
|
||||
}
|
||||
|
||||
// getHTTPTransport builds a transport for use in communicating with a registry
|
||||
func getHTTPTransport(authConfig registrytypes.AuthConfig, endpoint registry.APIEndpoint, repoName string, userAgent string) (http.RoundTripper, error) {
|
||||
func getHTTPTransport(authConfig registrytypes.AuthConfig, endpoint registry.APIEndpoint, repoName, userAgent string, actions []string) (http.RoundTripper, error) {
|
||||
// get the http transport, this will be used in a client to upload manifest
|
||||
base := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
@ -98,8 +100,11 @@ func getHTTPTransport(authConfig registrytypes.AuthConfig, endpoint registry.API
|
||||
passThruTokenHandler := &existingTokenHandler{token: authConfig.RegistryToken}
|
||||
modifiers = append(modifiers, auth.NewAuthorizer(challengeManager, passThruTokenHandler))
|
||||
} else {
|
||||
if len(actions) == 0 {
|
||||
actions = trust.ActionsPullOnly
|
||||
}
|
||||
creds := registry.NewStaticCredentialStore(&authConfig)
|
||||
tokenHandler := auth.NewTokenHandler(authTransport, creds, repoName, "push", "pull")
|
||||
tokenHandler := auth.NewTokenHandler(authTransport, creds, repoName, actions...)
|
||||
basicHandler := auth.NewBasicHandler(creds)
|
||||
modifiers = append(modifiers, auth.NewAuthorizer(challengeManager, tokenHandler, basicHandler))
|
||||
}
|
||||
|
||||
@ -202,7 +202,8 @@ func pullManifestList(ctx context.Context, ref reference.Named, repo distributio
|
||||
}
|
||||
|
||||
// Replace platform from config
|
||||
imageManifest.Descriptor.Platform = types.OCIPlatform(&manifestDescriptor.Platform)
|
||||
p := manifestDescriptor.Platform
|
||||
imageManifest.Descriptor.Platform = types.OCIPlatform(&p)
|
||||
|
||||
infos = append(infos, imageManifest)
|
||||
}
|
||||
@ -242,11 +243,6 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
|
||||
|
||||
confirmedTLSRegistries := make(map[string]bool)
|
||||
for _, endpoint := range endpoints {
|
||||
if endpoint.Version == registry.APIVersion1 {
|
||||
logrus.Debugf("skipping v1 endpoint %s", endpoint.URL)
|
||||
continue
|
||||
}
|
||||
|
||||
if endpoint.URL.Scheme != "https" {
|
||||
if _, confirmedTLS := confirmedTLSRegistries[endpoint.URL.Host]; confirmedTLS {
|
||||
logrus.Debugf("skipping non-TLS endpoint %s for host/port that appears to use TLS", endpoint.URL)
|
||||
|
||||
@ -402,14 +402,22 @@ func areFlagsSupported(cmd *cobra.Command, details versionDetails) error {
|
||||
errs := []string{}
|
||||
|
||||
cmd.Flags().VisitAll(func(f *pflag.Flag) {
|
||||
if !f.Changed {
|
||||
if !f.Changed || len(f.Annotations) == 0 {
|
||||
return
|
||||
}
|
||||
if !isVersionSupported(f, details.CurrentVersion()) {
|
||||
// Important: in the code below, calls to "details.CurrentVersion()" and
|
||||
// "details.ServerInfo()" are deliberately executed inline to make them
|
||||
// be executed "lazily". This is to prevent making a connection with the
|
||||
// daemon to perform a "ping" (even for flags that do not require a
|
||||
// daemon connection).
|
||||
//
|
||||
// See commit b39739123b845f872549e91be184cc583f5b387c for details.
|
||||
|
||||
if _, ok := f.Annotations["version"]; ok && !isVersionSupported(f, details.CurrentVersion()) {
|
||||
errs = append(errs, fmt.Sprintf(`"--%s" requires API version %s, but the Docker daemon API version is %s`, f.Name, getFlagAnnotation(f, "version"), details.CurrentVersion()))
|
||||
return
|
||||
}
|
||||
if !isOSTypeSupported(f, details.ServerInfo().OSType) {
|
||||
if _, ok := f.Annotations["ostype"]; ok && !isOSTypeSupported(f, details.ServerInfo().OSType) {
|
||||
errs = append(errs, fmt.Sprintf(
|
||||
`"--%s" is only supported on a Docker daemon running on %s, but the Docker daemon is running on %s`,
|
||||
f.Name,
|
||||
|
||||
@ -1142,7 +1142,10 @@ __docker_complete_user_group() {
|
||||
fi
|
||||
}
|
||||
|
||||
DOCKER_PLUGINS_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{.Path}}:{{end}}')
|
||||
__docker_plugins_path() {
|
||||
local docker_plugins_path=$(docker info --format '{{range .ClientInfo.Plugins}}{{.Path}}:{{end}}')
|
||||
echo "${docker_plugins_path//:/ }"
|
||||
}
|
||||
|
||||
__docker_complete_plugin() {
|
||||
local path=$1
|
||||
@ -5504,7 +5507,7 @@ _docker() {
|
||||
# Create completion functions for all registered plugins
|
||||
local known_plugin_commands=()
|
||||
local plugin_name=""
|
||||
for plugin_path in ${DOCKER_PLUGINS_PATH//:/ }; do
|
||||
for plugin_path in $(__docker_plugins_path); do
|
||||
plugin_name=$(basename "$plugin_path" | sed 's/ *$//')
|
||||
plugin_name=${plugin_name#docker-}
|
||||
plugin_name=${plugin_name%%.*}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
variable "GO_VERSION" {
|
||||
default = "1.20.6"
|
||||
default = "1.20.7"
|
||||
}
|
||||
variable "VERSION" {
|
||||
default = ""
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.20.6
|
||||
ARG GO_VERSION=1.20.7
|
||||
ARG ALPINE_VERSION=3.17
|
||||
|
||||
ARG BUILDX_VERSION=0.11.2
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.20.6
|
||||
ARG GO_VERSION=1.20.7
|
||||
ARG ALPINE_VERSION=3.17
|
||||
ARG GOLANGCI_LINT_VERSION=v1.52.2
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.20.6
|
||||
ARG GO_VERSION=1.20.7
|
||||
ARG ALPINE_VERSION=3.17
|
||||
ARG MODOUTDATED_VERSION=v0.8.0
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ Build an image from a Dockerfile
|
||||
| [`--add-host`](#add-host) | `list` | | Add a custom host-to-IP mapping (`host:ip`) |
|
||||
| [`--build-arg`](#build-arg) | `list` | | Set build-time variables |
|
||||
| [`--cache-from`](#cache-from) | `stringSlice` | | Images to consider as cache sources |
|
||||
| [`--cgroup-parent`](#cgroup-parent) | `string` | | Optional parent cgroup for the container |
|
||||
| [`--cgroup-parent`](#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||
| `--compress` | | | Compress the build context using gzip |
|
||||
| `--cpu-period` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) period |
|
||||
| `--cpu-quota` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) quota |
|
||||
@ -458,7 +458,17 @@ You can add other hosts into a container's `/etc/hosts` file by using one or
|
||||
more `--add-host` flags. This example adds a static address for a host named
|
||||
`docker`:
|
||||
|
||||
$ docker build --add-host=docker:10.180.0.1 .
|
||||
```console
|
||||
$ docker build --add-host docker:10.180.0.1 .
|
||||
```
|
||||
|
||||
If you need your build to connect to services running on the host, you can use
|
||||
the special `host-gateway` value for `--add-host`. In the following example,
|
||||
build containers resolve `host.docker.internal` to the host's gateway IP.
|
||||
|
||||
```console
|
||||
$ docker build --add-host host.docker.internal:host-gateway .
|
||||
```
|
||||
|
||||
### <a name="target"></a> Specifying target build stage (--target)
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ Build an image from a Dockerfile
|
||||
| `--add-host` | `list` | | Add a custom host-to-IP mapping (`host:ip`) |
|
||||
| `--build-arg` | `list` | | Set build-time variables |
|
||||
| `--cache-from` | `stringSlice` | | Images to consider as cache sources |
|
||||
| `--cgroup-parent` | `string` | | Optional parent cgroup for the container |
|
||||
| `--cgroup-parent` | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||
| `--compress` | | | Compress the build context using gzip |
|
||||
| `--cpu-period` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) period |
|
||||
| `--cpu-quota` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) quota |
|
||||
|
||||
@ -134,6 +134,7 @@ line:
|
||||
| `DOCKER_DEFAULT_PLATFORM` | Default platform for commands that take the `--platform` flag. |
|
||||
| `DOCKER_HIDE_LEGACY_COMMANDS` | When set, Docker hides "legacy" top-level commands (such as `docker rm`, and `docker pull`) in `docker help` output, and only `Management commands` per object-type (e.g., `docker container`) are printed. This may become the default in a future release. |
|
||||
| `DOCKER_HOST` | Daemon socket to connect to. |
|
||||
| `DOCKER_TLS` | Enable TLS for connections made by the `docker` CLI (equivalent of the `--tls` command-line option). Set to a non-empty value to enable TLS. Note that TLS is enabled automatically if any of the other TLS options are set. |
|
||||
| `DOCKER_TLS_VERIFY` | When set Docker uses TLS and verifies the remote. This variable is used both by the `docker` CLI and the [`dockerd` daemon](dockerd.md) |
|
||||
| `BUILDKIT_PROGRESS` | Set type of progress output (`auto`, `plain`, `tty`) when [building](build.md) with [BuildKit backend](https://docs.docker.com/build/buildkit/). Use plain to show container output (default `auto`). |
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ Inspects the specified config.
|
||||
By default, this renders all results in a JSON array. If a format is specified,
|
||||
the given template will be executed for each result.
|
||||
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
Go's [text/template](https://pkg.go.dev/text/template) package
|
||||
describes all the details of the format.
|
||||
|
||||
For detailed information about using configs, refer to [store configuration data using Docker Configs](https://docs.docker.com/engine/swarm/configs/).
|
||||
|
||||
@ -1265,6 +1265,25 @@ the host.
|
||||
For details about how to use this feature, as well as limitations, see
|
||||
[Isolate containers with a user namespace](https://docs.docker.com/engine/security/userns-remap/).
|
||||
|
||||
### Configure host gateway IP
|
||||
|
||||
The Docker daemon supports a special `host-gateway` value for the `--add-host`
|
||||
flag for the `docker run` and `docker build` commands. This value resolves to
|
||||
the host's gateway IP and lets containers connect to services running on the
|
||||
host.
|
||||
|
||||
By default, `host-gateway` resolves to the IP address of the default bridge.
|
||||
You can configure this to resolve to a different IP using the `--host-gateway-ip`
|
||||
flag for the dockerd command line interface, or the `host-gateway-ip` key in
|
||||
the daemon configuration file.
|
||||
|
||||
```console
|
||||
$ dockerd --host-gateway-ip 192.0.2.0
|
||||
$ docker run -it --add-host host.docker.internal:host-gateway \
|
||||
busybox ping host.docker.internal
|
||||
PING host.docker.internal (192.0.2.0): 56 data bytes
|
||||
```
|
||||
|
||||
### Miscellaneous options
|
||||
|
||||
IP masquerading uses address translation to allow containers without a public
|
||||
|
||||
@ -9,12 +9,12 @@ Get real time events from the server
|
||||
|
||||
### Options
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|:---------------------------------------|:---------|:--------|:----------------------------------------------|
|
||||
| [`-f`](#filter), [`--filter`](#filter) | `filter` | | Filter output based on conditions provided |
|
||||
| [`--format`](#format) | `string` | | Format the output using the given Go template |
|
||||
| [`--since`](#since) | `string` | | Show all events created since timestamp |
|
||||
| `--until` | `string` | | Stream events until this timestamp |
|
||||
| Name | Type | Default | Description |
|
||||
|:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [`-f`](#filter), [`--filter`](#filter) | `filter` | | Filter output based on conditions provided |
|
||||
| [`--format`](#format) | `string` | | Format output using a custom template:<br>'json': Print in JSON format<br>'TEMPLATE': Print output using the given Go template.<br>Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
|
||||
| [`--since`](#since) | `string` | | Show all events created since timestamp |
|
||||
| `--until` | `string` | | Stream events until this timestamp |
|
||||
|
||||
|
||||
<!---MARKER_GEN_END-->
|
||||
@ -194,7 +194,7 @@ The currently supported filters are:
|
||||
|
||||
If a format (`--format`) is specified, the given template will be executed
|
||||
instead of the default
|
||||
format. Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
format. Go's [text/template](https://pkg.go.dev/text/template) package
|
||||
describes all the details of the format.
|
||||
|
||||
If a format is set to `{{json .}}`, the events are streamed as valid JSON
|
||||
@ -401,8 +401,11 @@ Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299
|
||||
|
||||
#### Format as JSON
|
||||
|
||||
To list events in JSON format, use the `json` directive, which is the equivalent
|
||||
of `--format '{{ json . }}`.
|
||||
|
||||
```console
|
||||
$ docker events --format '{{json .}}'
|
||||
$ docker events --format json
|
||||
|
||||
{"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
{"status":"attach","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
@ -410,3 +413,5 @@ $ docker events --format '{{json .}}'
|
||||
{"status":"start","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f42..
|
||||
{"status":"resize","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
```
|
||||
|
||||
.
|
||||
|
||||
@ -14,7 +14,7 @@ Build an image from a Dockerfile
|
||||
| `--add-host` | `list` | | Add a custom host-to-IP mapping (`host:ip`) |
|
||||
| `--build-arg` | `list` | | Set build-time variables |
|
||||
| `--cache-from` | `stringSlice` | | Images to consider as cache sources |
|
||||
| `--cgroup-parent` | `string` | | Optional parent cgroup for the container |
|
||||
| `--cgroup-parent` | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||
| `--compress` | | | Compress the build context using gzip |
|
||||
| `--cpu-period` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) period |
|
||||
| `--cpu-quota` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) quota |
|
||||
|
||||
@ -101,7 +101,7 @@ read the [`dockerd`](dockerd.md) reference page.
|
||||
| [volume create](volume_create.md) | Creates a new volume where containers can consume and store data |
|
||||
| [volume inspect](volume_inspect.md) | Display information about a volume |
|
||||
| [volume ls](volume_ls.md) | Lists all the volumes Docker knows about |
|
||||
| [volume prune](volume_prune.md) | Remove all unused local volumes |
|
||||
| [volume prune](volume_prune.md) | Remove unused local volumes |
|
||||
| [volume rm](volume_rm.md) | Remove one or more volumes |
|
||||
|
||||
### Swarm node commands
|
||||
|
||||
@ -24,7 +24,7 @@ The number of images shown is the number of unique images. The same image tagged
|
||||
under different names is counted only once.
|
||||
|
||||
If a format is specified, the given template will be executed instead of the
|
||||
default format. Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
default format. Go's [text/template](https://pkg.go.dev/text/template) package
|
||||
describes all the details of the format.
|
||||
|
||||
Depending on the storage driver in use, additional information can be shown, such
|
||||
|
||||
@ -24,7 +24,7 @@ By default, `docker inspect` will render results in a JSON array.
|
||||
|
||||
If a format is specified, the given template will be executed for each result.
|
||||
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package describes
|
||||
Go's [text/template](https://pkg.go.dev/text/template) package describes
|
||||
all the details of the format.
|
||||
|
||||
### <a name="type"></a> Specify target type (--type)
|
||||
|
||||
@ -34,7 +34,7 @@ the container's `STDOUT` and `STDERR`.
|
||||
Passing a negative number or a non-integer to `--tail` is invalid and the
|
||||
value is set to `all` in that case.
|
||||
|
||||
The `docker logs --timestamps` command will add an [RFC3339Nano timestamp](https://golang.org/pkg/time/#pkg-constants)
|
||||
The `docker logs --timestamps` command will add an [RFC3339Nano timestamp](https://pkg.go.dev/time#RFC3339Nano)
|
||||
, for example `2014-09-16T06:17:46.000000000Z`, to each
|
||||
log entry. To ensure that the timestamps are aligned the
|
||||
nano-second part of the timestamp will be padded with zero when necessary.
|
||||
|
||||
@ -41,7 +41,7 @@ node are shown.
|
||||
|
||||
You can specify an alternate format to execute a given
|
||||
template for each result. Go's
|
||||
[text/template](https://golang.org/pkg/text/template/) package describes all the
|
||||
[text/template](https://pkg.go.dev/text/template) package describes all the
|
||||
details of the format.
|
||||
|
||||
```console
|
||||
|
||||
@ -18,7 +18,7 @@ Display detailed information on one or more nodes
|
||||
Returns information about a node. By default, this command renders all results
|
||||
in a JSON array. You can specify an alternate format to execute a
|
||||
given template for each result. Go's
|
||||
[text/template](https://golang.org/pkg/text/template/) package describes all the
|
||||
[text/template](https://pkg.go.dev/text/template) package describes all the
|
||||
details of the format.
|
||||
|
||||
> **Note**
|
||||
|
||||
@ -759,24 +759,28 @@ PING docker (93.184.216.34): 56 data bytes
|
||||
round-trip min/avg/max = 92.209/92.495/93.052 ms
|
||||
```
|
||||
|
||||
Sometimes you need to connect to the Docker host from within your
|
||||
container. To enable this, pass the Docker host's IP address to
|
||||
the container using the `--add-host` flag. To find the host's address,
|
||||
use the `ip addr show` command.
|
||||
The `--add-host` flag supports a special `host-gateway` value that resolves to
|
||||
the internal IP address of the host. This is useful when you want containers to
|
||||
connect to services running on the host machine.
|
||||
|
||||
The flags you pass to `ip addr show` depend on whether you are
|
||||
using IPv4 or IPv6 networking in your containers. Use the following
|
||||
flags for IPv4 address retrieval for a network device named `eth0`:
|
||||
It's conventional to use `host.docker.internal` as the hostname referring to
|
||||
`host-gateway`. Docker Desktop automatically resolves this hostname, see
|
||||
[Explore networking features](https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host).
|
||||
|
||||
The following example shows how the special `host-gateway` value works. The
|
||||
example runs an HTTP server that serves a file from host to container over the
|
||||
`host.docker.internal` hostname, which resolves to the host's internal IP.
|
||||
|
||||
```console
|
||||
$ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print $2}' | cut -d / -f 1 | sed -n 1p`
|
||||
$ docker run --add-host=docker:${HOSTIP} --rm -it debian
|
||||
$ echo "hello from host!" > ./hello
|
||||
$ python3 -m http.server 8000
|
||||
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
|
||||
$ docker run \
|
||||
--add-host host.docker.internal:host-gateway \
|
||||
curlimages/curl -s host.docker.internal:8000/hello
|
||||
hello from host!
|
||||
```
|
||||
|
||||
For IPv6 use the `-6` flag instead of the `-4` flag. For other network
|
||||
devices, replace `eth0` with the correct device name (for example `docker0`
|
||||
for the bridge device).
|
||||
|
||||
### <a name="ulimit"></a> Set ulimits in container (--ulimit)
|
||||
|
||||
Since setting `ulimit` settings in a container requires extra privileges not
|
||||
|
||||
@ -20,7 +20,7 @@ Inspects the specified secret.
|
||||
By default, this renders all results in a JSON array. If a format is specified,
|
||||
the given template will be executed for each result.
|
||||
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
Go's [text/template](https://pkg.go.dev/text/template) package
|
||||
describes all the details of the format.
|
||||
|
||||
For detailed information about using secrets, refer to [manage sensitive data with Docker secrets](https://docs.docker.com/engine/swarm/secrets/).
|
||||
|
||||
@ -1013,7 +1013,7 @@ registry value must be located in:
|
||||
### Create services using templates
|
||||
|
||||
You can use templates for some flags of `service create`, using the syntax
|
||||
provided by the Go's [text/template](https://golang.org/pkg/text/template/) package.
|
||||
provided by the Go's [text/template](https://pkg.go.dev/text/template) package.
|
||||
|
||||
The supported flags are the following :
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ Inspects the specified service.
|
||||
By default, this renders all results in a JSON array. If a format is specified,
|
||||
the given template will be executed for each result.
|
||||
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
Go's [text/template](https://pkg.go.dev/text/template) package
|
||||
describes all the details of the format.
|
||||
|
||||
> **Note**
|
||||
|
||||
@ -50,7 +50,7 @@ the service's `STDOUT` and `STDERR`.
|
||||
Passing a negative number or a non-integer to `--tail` is invalid and the
|
||||
value is set to `all` in that case.
|
||||
|
||||
The `docker service logs --timestamps` command will add an [RFC3339Nano timestamp](https://golang.org/pkg/time/#pkg-constants)
|
||||
The `docker service logs --timestamps` command will add an [RFC3339Nano timestamp](https://pkg.go.dev/time#RFC3339Nano)
|
||||
, for example `2014-09-16T06:17:46.000000000Z`, to each
|
||||
log entry. To ensure that the timestamps are aligned the
|
||||
nano-second part of the timestamp will be padded with zero when necessary.
|
||||
|
||||
@ -5,13 +5,12 @@ Manage Docker
|
||||
|
||||
### Subcommands
|
||||
|
||||
| Name | Description |
|
||||
|:-------------------------------------|:---------------------------------------------------------------------------------|
|
||||
| [`df`](system_df.md) | Show docker disk usage |
|
||||
| [`dial-stdio`](system_dial-stdio.md) | Proxy the stdio stream to the daemon connection. Should not be invoked manually. |
|
||||
| [`events`](system_events.md) | Get real time events from the server |
|
||||
| [`info`](system_info.md) | Display system-wide information |
|
||||
| [`prune`](system_prune.md) | Remove unused data |
|
||||
| Name | Description |
|
||||
|:-----------------------------|:-------------------------------------|
|
||||
| [`df`](system_df.md) | Show docker disk usage |
|
||||
| [`events`](system_events.md) | Get real time events from the server |
|
||||
| [`info`](system_info.md) | Display system-wide information |
|
||||
| [`prune`](system_prune.md) | Remove unused data |
|
||||
|
||||
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@ Get real time events from the server
|
||||
|
||||
### Options
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|:---------------------------------------|:---------|:--------|:----------------------------------------------|
|
||||
| [`-f`](#filter), [`--filter`](#filter) | `filter` | | Filter output based on conditions provided |
|
||||
| [`--format`](#format) | `string` | | Format the output using the given Go template |
|
||||
| `--since` | `string` | | Show all events created since timestamp |
|
||||
| `--until` | `string` | | Stream events until this timestamp |
|
||||
| Name | Type | Default | Description |
|
||||
|:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [`-f`](#filter), [`--filter`](#filter) | `filter` | | Filter output based on conditions provided |
|
||||
| [`--format`](#format) | `string` | | Format output using a custom template:<br>'json': Print in JSON format<br>'TEMPLATE': Print output using the given Go template.<br>Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
|
||||
| `--since` | `string` | | Show all events created since timestamp |
|
||||
| `--until` | `string` | | Stream events until this timestamp |
|
||||
|
||||
|
||||
<!---MARKER_GEN_END-->
|
||||
@ -308,7 +308,7 @@ $ docker system events --filter 'type=plugin'
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
If a format (`--format`) is specified, the given template will be executed
|
||||
instead of the default format. Go's [text/template](https://golang.org/pkg/text/template/)
|
||||
instead of the default format. Go's [text/template](https://pkg.go.dev/text/template)
|
||||
package describes all the details of the format.
|
||||
|
||||
```console
|
||||
|
||||
@ -10,7 +10,7 @@ Remove unused data
|
||||
| `-a`, `--all` | | | Remove all unused images not just dangling ones |
|
||||
| [`--filter`](#filter) | `filter` | | Provide filter values (e.g. `label=<key>=<value>`) |
|
||||
| `-f`, `--force` | | | Do not prompt for confirmation |
|
||||
| `--volumes` | | | Prune volumes |
|
||||
| `--volumes` | | | Prune anonymous volumes |
|
||||
|
||||
|
||||
<!---MARKER_GEN_END-->
|
||||
@ -50,7 +50,7 @@ Total reclaimed space: 1.84kB
|
||||
|
||||
By default, volumes are not removed to prevent important data from being
|
||||
deleted if there is currently no container using the volume. Use the `--volumes`
|
||||
flag when running the command to prune volumes as well:
|
||||
flag when running the command to prune anonymous volumes as well:
|
||||
|
||||
```console
|
||||
$ docker system prune -a --volumes
|
||||
@ -58,7 +58,7 @@ $ docker system prune -a --volumes
|
||||
WARNING! This will remove:
|
||||
- all stopped containers
|
||||
- all networks not used by at least one container
|
||||
- all volumes not used by at least one container
|
||||
- all anonymous volumes not used by at least one container
|
||||
- all images without at least one container associated to them
|
||||
- all build cache
|
||||
Are you sure you want to continue? [y/N] y
|
||||
|
||||
@ -10,7 +10,7 @@ Manage volumes
|
||||
| [`create`](volume_create.md) | Create a volume |
|
||||
| [`inspect`](volume_inspect.md) | Display detailed information on one or more volumes |
|
||||
| [`ls`](volume_ls.md) | List volumes |
|
||||
| [`prune`](volume_prune.md) | Remove all unused local volumes |
|
||||
| [`prune`](volume_prune.md) | Remove unused local volumes |
|
||||
| [`rm`](volume_rm.md) | Remove one or more volumes |
|
||||
| [`update`](volume_update.md) | Update a volume (cluster volumes only) |
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ Display detailed information on one or more volumes
|
||||
Returns information about a volume. By default, this command renders all results
|
||||
in a JSON array. You can specify an alternate format to execute a
|
||||
given template for each result. Go's
|
||||
[text/template](https://golang.org/pkg/text/template/) package describes all the
|
||||
[text/template](https://pkg.go.dev/text/template) package describes all the
|
||||
details of the format.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# volume prune
|
||||
|
||||
<!---MARKER_GEN_START-->
|
||||
Remove all unused local volumes
|
||||
Remove unused local volumes
|
||||
|
||||
### Options
|
||||
|
||||
|
||||
@ -672,7 +672,7 @@ the container exits**, you can add the `--rm` flag:
|
||||
> ```console
|
||||
> $ docker run --rm -v /foo -v awesome:/bar busybox top
|
||||
> ```
|
||||
>
|
||||
>
|
||||
> the volume for `/foo` will be removed, but the volume for `/bar` will not.
|
||||
> Volumes inherited via `--volumes-from` will be removed with the same logic: if
|
||||
> the original volume was specified with a name it will **not** be removed.
|
||||
@ -1418,7 +1418,7 @@ container's logging driver. The following options are supported:
|
||||
| `fluentd` | Fluentd logging driver for Docker. Writes log messages to `fluentd` (forward input). |
|
||||
| `awslogs` | Amazon CloudWatch Logs logging driver for Docker. Writes log messages to Amazon CloudWatch Logs. |
|
||||
| `splunk` | Splunk logging driver for Docker. Writes log messages to `splunk` using Event Http Collector. |
|
||||
| `etwlogs` | Event Tracing for Windows (ETW) events. Writes log messages as Event Tracing for Windows (ETW) events. Only Windows platforms. |
|
||||
| `etwlogs` | Event Tracing for Windows (ETW) events. Writes log messages as Event Tracing for Windows (ETW) events. Only Windows platforms. |
|
||||
| `gcplogs` | Google Cloud Platform (GCP) Logging. Writes log messages to Google Cloud Platform (GCP) Logging. |
|
||||
| `logentries` | Rapid7 Logentries. Writes log messages to Rapid7 Logentries. |
|
||||
|
||||
|
||||
2
e2e/testdata/Dockerfile.gencerts
vendored
2
e2e/testdata/Dockerfile.gencerts
vendored
@ -1,6 +1,6 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.20.6
|
||||
ARG GO_VERSION=1.20.7
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS generated
|
||||
RUN go install github.com/dmcgowan/quicktls@master
|
||||
|
||||
@ -8,7 +8,7 @@ docker-build - Build an image from a Dockerfile
|
||||
[**--add-host**[=*[]*]]
|
||||
[**--build-arg**[=*[]*]]
|
||||
[**--cache-from**[=*[]*]]
|
||||
[**--cpu-shares**[=*0*]]
|
||||
[**-c**|**--cpu-shares**[=*0*]]
|
||||
[**--cgroup-parent**[=*CGROUP-PARENT*]]
|
||||
[**--help**]
|
||||
[**--iidfile**[=*CIDFILE*]]
|
||||
@ -153,7 +153,7 @@ In Linux, default is **bridge**.
|
||||
Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you omit the unit, the system uses bytes.
|
||||
If you omit the size entirely, the system uses `64m`.
|
||||
|
||||
**--cpu-shares** *0*
|
||||
**-c**, **--cpu-shares** *0*
|
||||
CPU shares (relative weight).
|
||||
|
||||
By default, all containers get the same proportion of CPU cycles.
|
||||
@ -166,7 +166,7 @@ In Linux, default is **bridge**.
|
||||
You can change this proportion by adjusting the container's CPU share
|
||||
weighting relative to the weighting of all other running containers.
|
||||
|
||||
To modify the proportion from the default of 1024, use the **--cpu-shares**
|
||||
To modify the proportion from the default of 1024, use the **-c** or **--cpu-shares**
|
||||
flag to set the weighting to 2 or higher.
|
||||
|
||||
Container CPU share Flag
|
||||
|
||||
@ -10,7 +10,7 @@ docker-run - Create and run a new container from an image
|
||||
[**--annotation**[=*[]*]]
|
||||
[**--blkio-weight**[=*[BLKIO-WEIGHT]*]]
|
||||
[**--blkio-weight-device**[=*[]*]]
|
||||
[**--cpu-shares**[=*0*]]
|
||||
[**-c**|**--cpu-shares**[=*0*]]
|
||||
[**--cap-add**[=*[]*]]
|
||||
[**--cap-drop**[=*[]*]]
|
||||
[**--cgroupns**[=*[]*]]
|
||||
@ -137,14 +137,14 @@ option can be set multiple times.
|
||||
**--blkio-weight-device**=[]
|
||||
Block IO weight (relative device weight, format: `DEVICE_NAME:WEIGHT`).
|
||||
|
||||
**--cpu-shares**=*0*
|
||||
**-c**, **--cpu-shares**=*0*
|
||||
CPU shares (relative weight)
|
||||
|
||||
By default, all containers get the same proportion of CPU cycles. This proportion
|
||||
can be modified by changing the container's CPU share weighting relative
|
||||
to the weighting of all other running containers.
|
||||
|
||||
To modify the proportion from the default of 1024, use the **--cpu-shares**
|
||||
To modify the proportion from the default of 1024, use the **-c** or **--cpu-shares**
|
||||
flag to set the weighting to 2 or higher.
|
||||
|
||||
The proportion will only apply when CPU-intensive processes are running.
|
||||
|
||||
@ -9,7 +9,7 @@ container is unpaused, and then run
|
||||
# CAPABILITIES
|
||||
|
||||
`privileged` gives the process extended
|
||||
[Linux capabilities](http://man7.org/linux/man-pages/man7/capabilities.7.html)
|
||||
[Linux capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html)
|
||||
when running in a container.
|
||||
|
||||
Without this flag, the process run by `docker exec` in a running container has
|
||||
|
||||
@ -193,7 +193,7 @@ output:
|
||||
80/tcp -> 80
|
||||
|
||||
You can get more information about how to write a Go template from:
|
||||
https://golang.org/pkg/text/template/.
|
||||
https://pkg.go.dev/text/template.
|
||||
|
||||
## Getting size information on a container
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727
|
||||
The `network inspect` command shows the containers, by id, in its
|
||||
results. You can specify an alternate format to execute a given
|
||||
template for each result. Go's
|
||||
[text/template](http://golang.org/pkg/text/template/) package
|
||||
[text/template](https://pkg.go.dev/text/template) package
|
||||
describes all the details of the format.
|
||||
|
||||
```console
|
||||
|
||||
@ -85,7 +85,7 @@ details of the format.
|
||||
Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
|
||||
If a format is set to `{{json .}}`, the events are streamed as valid JSON
|
||||
Lines. For information about JSON Lines, please refer to http://jsonlines.org/ .
|
||||
Lines. For information about JSON Lines, please refer to https://jsonlines.org .
|
||||
|
||||
# docker events --format '{{json .}}'
|
||||
{"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Returns information about one or more volumes. By default, this command renders
|
||||
all results in a JSON array. You can specify an alternate format to execute a
|
||||
given template is executed for each result. Go's https://golang.org/pkg/text/template/
|
||||
given template is executed for each result. Go's https://pkg.go.dev/text/template
|
||||
package describes all the details of the format.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
set -eu
|
||||
|
||||
: "${CLI_DOCS_TOOL_VERSION=v0.5.1}"
|
||||
: "${CLI_DOCS_TOOL_VERSION=v0.6.0}"
|
||||
|
||||
export GO111MODULE=auto
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ require (
|
||||
github.com/containerd/containerd v1.6.21
|
||||
github.com/creack/pty v1.1.18
|
||||
github.com/docker/distribution v2.8.2+incompatible
|
||||
github.com/docker/docker v24.0.5-0.20230718221249-d4a26c153000+incompatible // v24.0.5-dev
|
||||
github.com/docker/docker v24.0.5+incompatible
|
||||
github.com/docker/docker-credential-helpers v0.7.0
|
||||
github.com/docker/go-connections v0.4.0
|
||||
github.com/docker/go-units v0.5.0
|
||||
@ -22,7 +22,7 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.14
|
||||
github.com/mitchellh/mapstructure v1.3.2
|
||||
github.com/moby/buildkit v0.11.6
|
||||
github.com/moby/patternmatcher v0.5.0
|
||||
github.com/moby/patternmatcher v0.6.0
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230531205928-01bb7a41396b
|
||||
github.com/moby/sys/sequential v0.5.0
|
||||
github.com/moby/sys/signal v0.7.0
|
||||
@ -42,7 +42,7 @@ require (
|
||||
golang.org/x/term v0.8.0
|
||||
golang.org/x/text v0.9.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gotest.tools/v3 v3.4.0
|
||||
gotest.tools/v3 v3.5.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
13
vendor.sum
13
vendor.sum
@ -96,8 +96,8 @@ github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xb
|
||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
|
||||
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v24.0.5-0.20230718221249-d4a26c153000+incompatible h1:LkM7hKYoTf+ESj5ZuqRlI8NFxcKp2UprZ/IeL9Dses8=
|
||||
github.com/docker/docker v24.0.5-0.20230718221249-d4a26c153000+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
|
||||
github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
|
||||
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
|
||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||
@ -271,8 +271,8 @@ github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYG
|
||||
github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/buildkit v0.11.6 h1:VYNdoKk5TVxN7k4RvZgdeM4GOyRvIi4Z8MXOY7xvyUs=
|
||||
github.com/moby/buildkit v0.11.6/go.mod h1:GCqKfHhz+pddzfgaR7WmHVEE3nKKZMMDPpK8mh3ZLv4=
|
||||
github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo=
|
||||
github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
|
||||
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230531205928-01bb7a41396b h1:w07xyBXYTrihwBqCkuXPLqcQ1a2guqXlRIocU+e9K7A=
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230531205928-01bb7a41396b/go.mod h1:Z5i5At5g0zU+ZBWb/95yVwDeNQX8BZmei9ZoYvoVD7g=
|
||||
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
|
||||
@ -618,7 +618,6 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -740,8 +739,8 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
|
||||
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
|
||||
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
|
||||
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package dockerignore
|
||||
package ignorefile
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -6,23 +6,31 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ReadAll reads a .dockerignore file and returns the list of file patterns
|
||||
// to ignore. Note this will trim whitespace from each line as well
|
||||
// as use GO's "clean" func to get the shortest/cleanest path for each.
|
||||
// ReadAll reads an ignore file from a reader and returns the list of file
|
||||
// patterns to ignore, applying the following rules:
|
||||
//
|
||||
// - An UTF8 BOM header (if present) is stripped.
|
||||
// - Lines starting with "#" are considered comments and are skipped.
|
||||
//
|
||||
// For remaining lines:
|
||||
//
|
||||
// - Leading and trailing whitespace is removed from each ignore pattern.
|
||||
// - It uses [filepath.Clean] to get the shortest/cleanest path for
|
||||
// ignore patterns.
|
||||
// - Leading forward-slashes ("/") are removed from ignore patterns,
|
||||
// so "/some/path" and "some/path" are considered equivalent.
|
||||
func ReadAll(reader io.Reader) ([]string, error) {
|
||||
if reader == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(reader)
|
||||
var excludes []string
|
||||
currentLine := 0
|
||||
|
||||
utf8bom := []byte{0xEF, 0xBB, 0xBF}
|
||||
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
scannedBytes := scanner.Bytes()
|
||||
// We trim UTF8 BOM
|
||||
@ -59,7 +67,7 @@ func ReadAll(reader io.Reader) ([]string, error) {
|
||||
excludes = append(excludes, pattern)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, errors.Wrap(err, "error reading .dockerignore")
|
||||
return nil, err
|
||||
}
|
||||
return excludes, nil
|
||||
}
|
||||
69
vendor/gotest.tools/v3/assert/assert.go
vendored
69
vendor/gotest.tools/v3/assert/assert.go
vendored
@ -4,7 +4,7 @@ values in tests. When an assertion fails a helpful error message is printed.
|
||||
|
||||
# Example usage
|
||||
|
||||
All the assertions in this package use testing.T.Helper to mark themselves as
|
||||
All the assertions in this package use [testing.T.Helper] to mark themselves as
|
||||
test helpers. This allows the testing package to print the filename and line
|
||||
number of the file function that failed.
|
||||
|
||||
@ -67,19 +67,19 @@ message is omitted from these examples for brevity.
|
||||
|
||||
# Assert and Check
|
||||
|
||||
Assert and Check are very similar, they both accept a Comparison, and fail
|
||||
[Assert] and [Check] are very similar, they both accept a [cmp.Comparison], and fail
|
||||
the test when the comparison fails. The one difference is that Assert uses
|
||||
testing.T.FailNow to fail the test, which will end the test execution immediately.
|
||||
Check uses testing.T.Fail to fail the test, which allows it to return the
|
||||
[testing.T.FailNow] to fail the test, which will end the test execution immediately.
|
||||
Check uses [testing.T.Fail] to fail the test, which allows it to return the
|
||||
result of the comparison, then proceed with the rest of the test case.
|
||||
|
||||
Like testing.T.FailNow, Assert must be called from the goroutine running the test,
|
||||
not from other goroutines created during the test. Check is safe to use from any
|
||||
Like [testing.T.FailNow], [Assert] must be called from the goroutine running the test,
|
||||
not from other goroutines created during the test. [Check] is safe to use from any
|
||||
goroutine.
|
||||
|
||||
# Comparisons
|
||||
|
||||
Package http://pkg.go.dev/gotest.tools/v3/assert/cmp provides
|
||||
Package [gotest.tools/v3/assert/cmp] provides
|
||||
many common comparisons. Additional comparisons can be written to compare
|
||||
values in other ways. See the example Assert (CustomComparison).
|
||||
|
||||
@ -98,11 +98,11 @@ import (
|
||||
"gotest.tools/v3/internal/assert"
|
||||
)
|
||||
|
||||
// BoolOrComparison can be a bool, cmp.Comparison, or error. See Assert for
|
||||
// BoolOrComparison can be a bool, [cmp.Comparison], or error. See [Assert] for
|
||||
// details about how this type is used.
|
||||
type BoolOrComparison interface{}
|
||||
|
||||
// TestingT is the subset of testing.T used by the assert package.
|
||||
// TestingT is the subset of [testing.T] (see also [testing.TB]) used by the assert package.
|
||||
type TestingT interface {
|
||||
FailNow()
|
||||
Fail()
|
||||
@ -133,11 +133,11 @@ type helperT interface {
|
||||
//
|
||||
// Extra details can be added to the failure message using msgAndArgs. msgAndArgs
|
||||
// may be either a single string, or a format string and args that will be
|
||||
// passed to fmt.Sprintf.
|
||||
// passed to [fmt.Sprintf].
|
||||
//
|
||||
// Assert uses t.FailNow to fail the test. Like t.FailNow, Assert must be called
|
||||
// Assert uses [testing.TB.FailNow] to fail the test. Like t.FailNow, Assert must be called
|
||||
// from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check from other goroutines.
|
||||
// goroutines created during the test. Use [Check] from other goroutines.
|
||||
func Assert(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
ht.Helper()
|
||||
@ -151,7 +151,7 @@ func Assert(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{})
|
||||
// failed, a failure message is printed, and Check returns false. If the comparison
|
||||
// is successful Check returns true. Check may be called from any goroutine.
|
||||
//
|
||||
// See Assert for details about the comparison arg and failure messages.
|
||||
// See [Assert] for details about the comparison arg and failure messages.
|
||||
func Check(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{}) bool {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
ht.Helper()
|
||||
@ -166,9 +166,9 @@ func Check(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{}) b
|
||||
// NilError fails the test immediately if err is not nil, and includes err.Error
|
||||
// in the failure message.
|
||||
//
|
||||
// NilError uses t.FailNow to fail the test. Like t.FailNow, NilError must be
|
||||
// NilError uses [testing.TB.FailNow] to fail the test. Like t.FailNow, NilError must be
|
||||
// called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check from other goroutines.
|
||||
// goroutines created during the test. Use [Check] from other goroutines.
|
||||
func NilError(t TestingT, err error, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
ht.Helper()
|
||||
@ -193,9 +193,9 @@ func NilError(t TestingT, err error, msgAndArgs ...interface{}) {
|
||||
// the unified diff will be augmented by replacing whitespace characters with
|
||||
// visible characters to identify the whitespace difference.
|
||||
//
|
||||
// Equal uses t.FailNow to fail the test. Like t.FailNow, Equal must be
|
||||
// Equal uses [testing.T.FailNow] to fail the test. Like t.FailNow, Equal must be
|
||||
// called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check with cmp.Equal from other
|
||||
// goroutines created during the test. Use [Check] with [cmp.Equal] from other
|
||||
// goroutines.
|
||||
func Equal(t TestingT, x, y interface{}, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
@ -206,15 +206,15 @@ func Equal(t TestingT, x, y interface{}, msgAndArgs ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// DeepEqual uses google/go-cmp (https://godoc.org/github.com/google/go-cmp/cmp)
|
||||
// DeepEqual uses [github.com/google/go-cmp/cmp]
|
||||
// to assert two values are equal and fails the test if they are not equal.
|
||||
//
|
||||
// Package http://pkg.go.dev/gotest.tools/v3/assert/opt provides some additional
|
||||
// Package [gotest.tools/v3/assert/opt] provides some additional
|
||||
// commonly used Options.
|
||||
//
|
||||
// DeepEqual uses t.FailNow to fail the test. Like t.FailNow, DeepEqual must be
|
||||
// DeepEqual uses [testing.T.FailNow] to fail the test. Like t.FailNow, DeepEqual must be
|
||||
// called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check with cmp.DeepEqual from other
|
||||
// goroutines created during the test. Use [Check] with [cmp.DeepEqual] from other
|
||||
// goroutines.
|
||||
func DeepEqual(t TestingT, x, y interface{}, opts ...gocmp.Option) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
@ -227,13 +227,13 @@ func DeepEqual(t TestingT, x, y interface{}, opts ...gocmp.Option) {
|
||||
|
||||
// Error fails the test if err is nil, or if err.Error is not equal to expected.
|
||||
// Both err.Error and expected will be included in the failure message.
|
||||
// Error performs an exact match of the error text. Use ErrorContains if only
|
||||
// part of the error message is relevant. Use ErrorType or ErrorIs to compare
|
||||
// Error performs an exact match of the error text. Use [ErrorContains] if only
|
||||
// part of the error message is relevant. Use [ErrorType] or [ErrorIs] to compare
|
||||
// errors by type.
|
||||
//
|
||||
// Error uses t.FailNow to fail the test. Like t.FailNow, Error must be
|
||||
// Error uses [testing.T.FailNow] to fail the test. Like t.FailNow, Error must be
|
||||
// called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check with cmp.Error from other
|
||||
// goroutines created during the test. Use [Check] with [cmp.Error] from other
|
||||
// goroutines.
|
||||
func Error(t TestingT, err error, expected string, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
@ -248,9 +248,9 @@ func Error(t TestingT, err error, expected string, msgAndArgs ...interface{}) {
|
||||
// contain the expected substring. Both err.Error and the expected substring
|
||||
// will be included in the failure message.
|
||||
//
|
||||
// ErrorContains uses t.FailNow to fail the test. Like t.FailNow, ErrorContains
|
||||
// ErrorContains uses [testing.T.FailNow] to fail the test. Like t.FailNow, ErrorContains
|
||||
// must be called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check with cmp.ErrorContains from other
|
||||
// goroutines created during the test. Use [Check] with [cmp.ErrorContains] from other
|
||||
// goroutines.
|
||||
func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
@ -262,8 +262,7 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf
|
||||
}
|
||||
|
||||
// ErrorType fails the test if err is nil, or err is not the expected type.
|
||||
// Most new code should use ErrorIs instead. ErrorType may be deprecated in the
|
||||
// future.
|
||||
// New code should use ErrorIs instead.
|
||||
//
|
||||
// Expected can be one of:
|
||||
//
|
||||
@ -281,10 +280,12 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf
|
||||
// reflect.Type
|
||||
// The assertion fails if err does not implement the reflect.Type.
|
||||
//
|
||||
// ErrorType uses t.FailNow to fail the test. Like t.FailNow, ErrorType
|
||||
// ErrorType uses [testing.T.FailNow] to fail the test. Like t.FailNow, ErrorType
|
||||
// must be called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check with cmp.ErrorType from other
|
||||
// goroutines created during the test. Use [Check] with [cmp.ErrorType] from other
|
||||
// goroutines.
|
||||
//
|
||||
// Deprecated: Use [ErrorIs]
|
||||
func ErrorType(t TestingT, err error, expected interface{}, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
ht.Helper()
|
||||
@ -295,12 +296,12 @@ func ErrorType(t TestingT, err error, expected interface{}, msgAndArgs ...interf
|
||||
}
|
||||
|
||||
// ErrorIs fails the test if err is nil, or the error does not match expected
|
||||
// when compared using errors.Is. See https://golang.org/pkg/errors/#Is for
|
||||
// when compared using errors.Is. See [errors.Is] for
|
||||
// accepted arguments.
|
||||
//
|
||||
// ErrorIs uses t.FailNow to fail the test. Like t.FailNow, ErrorIs
|
||||
// ErrorIs uses [testing.T.FailNow] to fail the test. Like t.FailNow, ErrorIs
|
||||
// must be called from the goroutine running the test function, not from other
|
||||
// goroutines created during the test. Use Check with cmp.ErrorIs from other
|
||||
// goroutines created during the test. Use [Check] with [cmp.ErrorIs] from other
|
||||
// goroutines.
|
||||
func ErrorIs(t TestingT, err error, expected error, msgAndArgs ...interface{}) {
|
||||
if ht, ok := t.(helperT); ok {
|
||||
|
||||
25
vendor/gotest.tools/v3/assert/cmp/compare.go
vendored
25
vendor/gotest.tools/v3/assert/cmp/compare.go
vendored
@ -12,17 +12,16 @@ import (
|
||||
"gotest.tools/v3/internal/format"
|
||||
)
|
||||
|
||||
// Comparison is a function which compares values and returns ResultSuccess if
|
||||
// Comparison is a function which compares values and returns [ResultSuccess] if
|
||||
// the actual value matches the expected value. If the values do not match the
|
||||
// Result will contain a message about why it failed.
|
||||
// [Result] will contain a message about why it failed.
|
||||
type Comparison func() Result
|
||||
|
||||
// DeepEqual compares two values using google/go-cmp
|
||||
// (https://godoc.org/github.com/google/go-cmp/cmp)
|
||||
// DeepEqual compares two values using [github.com/google/go-cmp/cmp]
|
||||
// and succeeds if the values are equal.
|
||||
//
|
||||
// The comparison can be customized using comparison Options.
|
||||
// Package http://pkg.go.dev/gotest.tools/v3/assert/opt provides some additional
|
||||
// Package [gotest.tools/v3/assert/opt] provides some additional
|
||||
// commonly used Options.
|
||||
func DeepEqual(x, y interface{}, opts ...cmp.Option) Comparison {
|
||||
return func() (result Result) {
|
||||
@ -61,7 +60,7 @@ func toResult(success bool, msg string) Result {
|
||||
return ResultFailure(msg)
|
||||
}
|
||||
|
||||
// RegexOrPattern may be either a *regexp.Regexp or a string that is a valid
|
||||
// RegexOrPattern may be either a [*regexp.Regexp] or a string that is a valid
|
||||
// regexp pattern.
|
||||
type RegexOrPattern interface{}
|
||||
|
||||
@ -95,7 +94,7 @@ func Regexp(re RegexOrPattern, v string) Comparison {
|
||||
}
|
||||
}
|
||||
|
||||
// Equal succeeds if x == y. See assert.Equal for full documentation.
|
||||
// Equal succeeds if x == y. See [gotest.tools/v3/assert.Equal] for full documentation.
|
||||
func Equal(x, y interface{}) Comparison {
|
||||
return func() Result {
|
||||
switch {
|
||||
@ -159,10 +158,10 @@ func Len(seq interface{}, expected int) Comparison {
|
||||
// slice, or array.
|
||||
//
|
||||
// If collection is a string, item must also be a string, and is compared using
|
||||
// strings.Contains().
|
||||
// [strings.Contains].
|
||||
// If collection is a Map, contains will succeed if item is a key in the map.
|
||||
// If collection is a slice or array, item is compared to each item in the
|
||||
// sequence using reflect.DeepEqual().
|
||||
// sequence using [reflect.DeepEqual].
|
||||
func Contains(collection interface{}, item interface{}) Comparison {
|
||||
return func() Result {
|
||||
colValue := reflect.ValueOf(collection)
|
||||
@ -259,7 +258,7 @@ func formatErrorMessage(err error) string {
|
||||
|
||||
// Nil succeeds if obj is a nil interface, pointer, or function.
|
||||
//
|
||||
// Use NilError() for comparing errors. Use Len(obj, 0) for comparing slices,
|
||||
// Use [gotest.tools/v3/assert.NilError] for comparing errors. Use Len(obj, 0) for comparing slices,
|
||||
// maps, and channels.
|
||||
func Nil(obj interface{}) Comparison {
|
||||
msgFunc := func(value reflect.Value) string {
|
||||
@ -306,7 +305,9 @@ func isNil(obj interface{}, msgFunc func(reflect.Value) string) Comparison {
|
||||
//
|
||||
// reflect.Type
|
||||
//
|
||||
// Fails if err does not implement the reflect.Type
|
||||
// Fails if err does not implement the [reflect.Type].
|
||||
//
|
||||
// Deprecated: Use [ErrorIs]
|
||||
func ErrorType(err error, expected interface{}) Comparison {
|
||||
return func() Result {
|
||||
switch expectedType := expected.(type) {
|
||||
@ -381,7 +382,7 @@ var (
|
||||
)
|
||||
|
||||
// ErrorIs succeeds if errors.Is(actual, expected) returns true. See
|
||||
// https://golang.org/pkg/errors/#Is for accepted argument values.
|
||||
// [errors.Is] for accepted argument values.
|
||||
func ErrorIs(actual error, expected error) Comparison {
|
||||
return func() Result {
|
||||
if errors.Is(actual, expected) {
|
||||
|
||||
12
vendor/gotest.tools/v3/assert/cmp/result.go
vendored
12
vendor/gotest.tools/v3/assert/cmp/result.go
vendored
@ -10,12 +10,12 @@ import (
|
||||
"gotest.tools/v3/internal/source"
|
||||
)
|
||||
|
||||
// A Result of a Comparison.
|
||||
// A Result of a [Comparison].
|
||||
type Result interface {
|
||||
Success() bool
|
||||
}
|
||||
|
||||
// StringResult is an implementation of Result that reports the error message
|
||||
// StringResult is an implementation of [Result] that reports the error message
|
||||
// string verbatim and does not provide any templating or formatting of the
|
||||
// message.
|
||||
type StringResult struct {
|
||||
@ -34,16 +34,16 @@ func (r StringResult) FailureMessage() string {
|
||||
return r.message
|
||||
}
|
||||
|
||||
// ResultSuccess is a constant which is returned by a ComparisonWithResult to
|
||||
// ResultSuccess is a constant which is returned by a [Comparison] to
|
||||
// indicate success.
|
||||
var ResultSuccess = StringResult{success: true}
|
||||
|
||||
// ResultFailure returns a failed Result with a failure message.
|
||||
// ResultFailure returns a failed [Result] with a failure message.
|
||||
func ResultFailure(message string) StringResult {
|
||||
return StringResult{message: message}
|
||||
}
|
||||
|
||||
// ResultFromError returns ResultSuccess if err is nil. Otherwise ResultFailure
|
||||
// ResultFromError returns [ResultSuccess] if err is nil. Otherwise [ResultFailure]
|
||||
// is returned with the error message as the failure message.
|
||||
func ResultFromError(err error) Result {
|
||||
if err == nil {
|
||||
@ -74,7 +74,7 @@ func (r templatedResult) UpdatedExpected(stackIndex int) error {
|
||||
return source.UpdateExpectedValue(stackIndex+1, r.data["x"], r.data["y"])
|
||||
}
|
||||
|
||||
// ResultFailureTemplate returns a Result with a template string and data which
|
||||
// ResultFailureTemplate returns a [Result] with a template string and data which
|
||||
// can be used to format a failure message. The template may access data from .Data,
|
||||
// the comparison args with the callArg function, and the formatNode function may
|
||||
// be used to format the call args.
|
||||
|
||||
2
vendor/gotest.tools/v3/env/env.go
vendored
2
vendor/gotest.tools/v3/env/env.go
vendored
@ -72,7 +72,7 @@ func PatchAll(t assert.TestingT, env map[string]string) func() {
|
||||
return clean
|
||||
}
|
||||
|
||||
// ToMap takes a list of strings in the format returned by os.Environ() and
|
||||
// ToMap takes a list of strings in the format returned by [os.Environ] and
|
||||
// returns a mapping of keys to values.
|
||||
func ToMap(env []string) map[string]string {
|
||||
result := map[string]string{}
|
||||
|
||||
17
vendor/gotest.tools/v3/icmd/command.go
vendored
17
vendor/gotest.tools/v3/icmd/command.go
vendored
@ -195,6 +195,7 @@ type Cmd struct {
|
||||
Timeout time.Duration
|
||||
Stdin io.Reader
|
||||
Stdout io.Writer
|
||||
Stderr io.Writer
|
||||
Dir string
|
||||
Env []string
|
||||
ExtraFiles []*os.File
|
||||
@ -207,10 +208,7 @@ func Command(command string, args ...string) Cmd {
|
||||
|
||||
// RunCmd runs a command and returns a Result
|
||||
func RunCmd(cmd Cmd, cmdOperators ...CmdOp) *Result {
|
||||
for _, op := range cmdOperators {
|
||||
op(&cmd)
|
||||
}
|
||||
result := StartCmd(cmd)
|
||||
result := StartCmd(cmd, cmdOperators...)
|
||||
if result.Error != nil {
|
||||
return result
|
||||
}
|
||||
@ -223,7 +221,10 @@ func RunCommand(command string, args ...string) *Result {
|
||||
}
|
||||
|
||||
// StartCmd starts a command, but doesn't wait for it to finish
|
||||
func StartCmd(cmd Cmd) *Result {
|
||||
func StartCmd(cmd Cmd, cmdOperators ...CmdOp) *Result {
|
||||
for _, op := range cmdOperators {
|
||||
op(&cmd)
|
||||
}
|
||||
result := buildCmd(cmd)
|
||||
if result.Error != nil {
|
||||
return result
|
||||
@ -252,7 +253,11 @@ func buildCmd(cmd Cmd) *Result {
|
||||
} else {
|
||||
execCmd.Stdout = outBuffer
|
||||
}
|
||||
execCmd.Stderr = errBuffer
|
||||
if cmd.Stderr != nil {
|
||||
execCmd.Stderr = io.MultiWriter(errBuffer, cmd.Stderr)
|
||||
} else {
|
||||
execCmd.Stderr = errBuffer
|
||||
}
|
||||
execCmd.ExtraFiles = cmd.ExtraFiles
|
||||
|
||||
return &Result{
|
||||
|
||||
14
vendor/gotest.tools/v3/icmd/ops.go
vendored
14
vendor/gotest.tools/v3/icmd/ops.go
vendored
@ -38,6 +38,20 @@ func WithStdin(r io.Reader) CmdOp {
|
||||
}
|
||||
}
|
||||
|
||||
// WithStdout sets the standard output of the command to the specified writer
|
||||
func WithStdout(w io.Writer) CmdOp {
|
||||
return func(c *Cmd) {
|
||||
c.Stdout = w
|
||||
}
|
||||
}
|
||||
|
||||
// WithStderr sets the standard error of the command to the specified writer
|
||||
func WithStderr(w io.Writer) CmdOp {
|
||||
return func(c *Cmd) {
|
||||
c.Stderr = w
|
||||
}
|
||||
}
|
||||
|
||||
// WithExtraFile adds a file descriptor to the command
|
||||
func WithExtraFile(f *os.File) CmdOp {
|
||||
return func(c *Cmd) {
|
||||
|
||||
4
vendor/gotest.tools/v3/poll/check.go
vendored
4
vendor/gotest.tools/v3/poll/check.go
vendored
@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Check is a function which will be used as check for the WaitOn method.
|
||||
// Check is a function which will be used as check for the [WaitOn] method.
|
||||
type Check func(t LogT) Result
|
||||
|
||||
// FileExists looks on filesystem and check that path exists.
|
||||
@ -29,7 +29,7 @@ func FileExists(path string) Check {
|
||||
}
|
||||
|
||||
// Connection try to open a connection to the address on the
|
||||
// named network. See net.Dial for a description of the network and
|
||||
// named network. See [net.Dial] for a description of the network and
|
||||
// address parameters.
|
||||
func Connection(network, address string) Check {
|
||||
return func(t LogT) Result {
|
||||
|
||||
18
vendor/gotest.tools/v3/poll/poll.go
vendored
18
vendor/gotest.tools/v3/poll/poll.go
vendored
@ -11,13 +11,13 @@ import (
|
||||
"gotest.tools/v3/internal/assert"
|
||||
)
|
||||
|
||||
// TestingT is the subset of testing.T used by WaitOn
|
||||
// TestingT is the subset of [testing.T] used by [WaitOn]
|
||||
type TestingT interface {
|
||||
LogT
|
||||
Fatalf(format string, args ...interface{})
|
||||
}
|
||||
|
||||
// LogT is a logging interface that is passed to the WaitOn check function
|
||||
// LogT is a logging interface that is passed to the [WaitOn] check function
|
||||
type LogT interface {
|
||||
Log(args ...interface{})
|
||||
Logf(format string, args ...interface{})
|
||||
@ -27,7 +27,7 @@ type helperT interface {
|
||||
Helper()
|
||||
}
|
||||
|
||||
// Settings are used to configure the behaviour of WaitOn
|
||||
// Settings are used to configure the behaviour of [WaitOn]
|
||||
type Settings struct {
|
||||
// Timeout is the maximum time to wait for the condition. Defaults to 10s.
|
||||
Timeout time.Duration
|
||||
@ -57,7 +57,7 @@ func WithTimeout(timeout time.Duration) SettingOp {
|
||||
}
|
||||
}
|
||||
|
||||
// Result of a check performed by WaitOn
|
||||
// Result of a check performed by [WaitOn]
|
||||
type Result interface {
|
||||
// Error indicates that the check failed and polling should stop, and the
|
||||
// the has failed
|
||||
@ -86,20 +86,20 @@ func (r result) Error() error {
|
||||
return r.err
|
||||
}
|
||||
|
||||
// Continue returns a Result that indicates to WaitOn that it should continue
|
||||
// Continue returns a [Result] that indicates to [WaitOn] that it should continue
|
||||
// polling. The message text will be used as the failure message if the timeout
|
||||
// is reached.
|
||||
func Continue(message string, args ...interface{}) Result {
|
||||
return result{message: fmt.Sprintf(message, args...)}
|
||||
}
|
||||
|
||||
// Success returns a Result where Done() returns true, which indicates to WaitOn
|
||||
// Success returns a [Result] where Done() returns true, which indicates to [WaitOn]
|
||||
// that it should stop polling and exit without an error.
|
||||
func Success() Result {
|
||||
return result{done: true}
|
||||
}
|
||||
|
||||
// Error returns a Result that indicates to WaitOn that it should fail the test
|
||||
// Error returns a [Result] that indicates to [WaitOn] that it should fail the test
|
||||
// and stop polling.
|
||||
func Error(err error) Result {
|
||||
return result{err: err}
|
||||
@ -143,9 +143,9 @@ func WaitOn(t TestingT, check Check, pollOps ...SettingOp) {
|
||||
}
|
||||
}
|
||||
|
||||
// Compare values using the cmp.Comparison. If the comparison fails return a
|
||||
// Compare values using the [cmp.Comparison]. If the comparison fails return a
|
||||
// result which indicates to WaitOn that it should continue waiting.
|
||||
// If the comparison is successful then WaitOn stops polling.
|
||||
// If the comparison is successful then [WaitOn] stops polling.
|
||||
func Compare(compare cmp.Comparison) Result {
|
||||
buf := new(logBuffer)
|
||||
if assert.RunComparison(buf, assert.ArgsAtZeroIndex, compare) {
|
||||
|
||||
10
vendor/modules.txt
vendored
10
vendor/modules.txt
vendored
@ -40,7 +40,7 @@ github.com/docker/distribution/registry/client/transport
|
||||
github.com/docker/distribution/registry/storage/cache
|
||||
github.com/docker/distribution/registry/storage/cache/memory
|
||||
github.com/docker/distribution/uuid
|
||||
# github.com/docker/docker v24.0.5-0.20230718221249-d4a26c153000+incompatible
|
||||
# github.com/docker/docker v24.0.5+incompatible
|
||||
## explicit
|
||||
github.com/docker/docker/api
|
||||
github.com/docker/docker/api/types
|
||||
@ -161,11 +161,11 @@ github.com/miekg/pkcs11
|
||||
github.com/mitchellh/mapstructure
|
||||
# github.com/moby/buildkit v0.11.6
|
||||
## explicit; go 1.18
|
||||
github.com/moby/buildkit/frontend/dockerfile/dockerignore
|
||||
github.com/moby/buildkit/util/appcontext
|
||||
# github.com/moby/patternmatcher v0.5.0
|
||||
# github.com/moby/patternmatcher v0.6.0
|
||||
## explicit; go 1.19
|
||||
github.com/moby/patternmatcher
|
||||
github.com/moby/patternmatcher/ignorefile
|
||||
# github.com/moby/swarmkit/v2 v2.0.0-20230531205928-01bb7a41396b
|
||||
## explicit; go 1.18
|
||||
github.com/moby/swarmkit/v2/api
|
||||
@ -391,8 +391,8 @@ google.golang.org/protobuf/types/known/timestamppb
|
||||
# gopkg.in/yaml.v2 v2.4.0
|
||||
## explicit; go 1.15
|
||||
gopkg.in/yaml.v2
|
||||
# gotest.tools/v3 v3.4.0
|
||||
## explicit; go 1.13
|
||||
# gotest.tools/v3 v3.5.0
|
||||
## explicit; go 1.17
|
||||
gotest.tools/v3/assert
|
||||
gotest.tools/v3/assert/cmp
|
||||
gotest.tools/v3/env
|
||||
|
||||
Reference in New Issue
Block a user