vendor: github.com/docker/docker 164cae56ed95 (master, v-next)
full diff: 2269acc7a3...164cae56ed
Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -16,17 +16,17 @@ import (
|
||||
type fakeClient struct {
|
||||
client.Client
|
||||
imageTagFunc func(string, string) error
|
||||
imageSaveFunc func(images []string) (io.ReadCloser, error)
|
||||
imageSaveFunc func(images []string, options image.SaveOptions) (io.ReadCloser, error)
|
||||
imageRemoveFunc func(image string, options image.RemoveOptions) ([]image.DeleteResponse, error)
|
||||
imagePushFunc func(ref string, options image.PushOptions) (io.ReadCloser, error)
|
||||
infoFunc func() (system.Info, error)
|
||||
imagePullFunc func(ref string, options image.PullOptions) (io.ReadCloser, error)
|
||||
imagesPruneFunc func(pruneFilter filters.Args) (image.PruneReport, error)
|
||||
imageLoadFunc func(input io.Reader, quiet bool) (image.LoadResponse, error)
|
||||
imageLoadFunc func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error)
|
||||
imageListFunc func(options image.ListOptions) ([]image.Summary, error)
|
||||
imageInspectFunc func(img string) (image.InspectResponse, []byte, error)
|
||||
imageImportFunc func(source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
||||
imageHistoryFunc func(img string) ([]image.HistoryResponseItem, error)
|
||||
imageHistoryFunc func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error)
|
||||
imageBuildFunc func(context.Context, io.Reader, types.ImageBuildOptions) (types.ImageBuildResponse, error)
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ func (cli *fakeClient) ImageTag(_ context.Context, img, ref string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ImageSave(_ context.Context, images []string) (io.ReadCloser, error) {
|
||||
func (cli *fakeClient) ImageSave(_ context.Context, images []string, options image.SaveOptions) (io.ReadCloser, error) {
|
||||
if cli.imageSaveFunc != nil {
|
||||
return cli.imageSaveFunc(images)
|
||||
return cli.imageSaveFunc(images, options)
|
||||
}
|
||||
return io.NopCloser(strings.NewReader("")), nil
|
||||
}
|
||||
@ -81,9 +81,9 @@ func (cli *fakeClient) ImagesPrune(_ context.Context, pruneFilter filters.Args)
|
||||
return image.PruneReport{}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ImageLoad(_ context.Context, input io.Reader, quiet bool) (image.LoadResponse, error) {
|
||||
func (cli *fakeClient) ImageLoad(_ context.Context, input io.Reader, options image.LoadOptions) (image.LoadResponse, error) {
|
||||
if cli.imageLoadFunc != nil {
|
||||
return cli.imageLoadFunc(input, quiet)
|
||||
return cli.imageLoadFunc(input, options)
|
||||
}
|
||||
return image.LoadResponse{}, nil
|
||||
}
|
||||
@ -111,9 +111,9 @@ func (cli *fakeClient) ImageImport(_ context.Context, source image.ImportSource,
|
||||
return io.NopCloser(strings.NewReader("")), nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ImageHistory(_ context.Context, img string) ([]image.HistoryResponseItem, error) {
|
||||
func (cli *fakeClient) ImageHistory(_ context.Context, img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) {
|
||||
if cli.imageHistoryFunc != nil {
|
||||
return cli.imageHistoryFunc(img)
|
||||
return cli.imageHistoryFunc(img, options)
|
||||
}
|
||||
return []image.HistoryResponseItem{{ID: img, Created: time.Now().Unix()}}, nil
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -49,7 +50,7 @@ func NewHistoryCommand(dockerCli command.Cli) *cobra.Command {
|
||||
}
|
||||
|
||||
func runHistory(ctx context.Context, dockerCli command.Cli, opts historyOptions) error {
|
||||
history, err := dockerCli.Client().ImageHistory(ctx, opts.image)
|
||||
history, err := dockerCli.Client().ImageHistory(ctx, opts.image, image.HistoryOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||
name string
|
||||
args []string
|
||||
expectedError string
|
||||
imageHistoryFunc func(img string) ([]image.HistoryResponseItem, error)
|
||||
imageHistoryFunc func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error)
|
||||
}{
|
||||
{
|
||||
name: "wrong-args",
|
||||
@ -29,7 +29,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||
name: "client-error",
|
||||
args: []string{"image:tag"},
|
||||
expectedError: "something went wrong",
|
||||
imageHistoryFunc: func(img string) ([]image.HistoryResponseItem, error) {
|
||||
imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) {
|
||||
return []image.HistoryResponseItem{{}}, errors.Errorf("something went wrong")
|
||||
},
|
||||
},
|
||||
@ -50,12 +50,12 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
imageHistoryFunc func(img string) ([]image.HistoryResponseItem, error)
|
||||
imageHistoryFunc func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error)
|
||||
}{
|
||||
{
|
||||
name: "simple",
|
||||
args: []string{"image:tag"},
|
||||
imageHistoryFunc: func(img string) ([]image.HistoryResponseItem, error) {
|
||||
imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) {
|
||||
return []image.HistoryResponseItem{{
|
||||
ID: "1234567890123456789",
|
||||
Created: time.Now().Unix(),
|
||||
@ -70,7 +70,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||
{
|
||||
name: "non-human",
|
||||
args: []string{"--human=false", "image:tag"},
|
||||
imageHistoryFunc: func(img string) ([]image.HistoryResponseItem, error) {
|
||||
imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) {
|
||||
return []image.HistoryResponseItem{{
|
||||
ID: "abcdef",
|
||||
Created: time.Date(2017, 1, 1, 12, 0, 3, 0, time.UTC).Unix(),
|
||||
@ -82,7 +82,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||
{
|
||||
name: "quiet-no-trunc",
|
||||
args: []string{"--quiet", "--no-trunc", "image:tag"},
|
||||
imageHistoryFunc: func(img string) ([]image.HistoryResponseItem, error) {
|
||||
imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) {
|
||||
return []image.HistoryResponseItem{{
|
||||
ID: "1234567890123456789",
|
||||
Created: time.Now().Unix(),
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/moby/sys/sequential"
|
||||
"github.com/pkg/errors"
|
||||
@ -62,10 +63,12 @@ func runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error
|
||||
return errors.Errorf("requested load from stdin, but stdin is empty")
|
||||
}
|
||||
|
||||
if !dockerCli.Out().IsTerminal() {
|
||||
opts.quiet = true
|
||||
var loadOpts image.LoadOptions
|
||||
if opts.quiet || !dockerCli.Out().IsTerminal() {
|
||||
loadOpts.Quiet = true
|
||||
}
|
||||
response, err := dockerCli.Client().ImageLoad(ctx, input, opts.quiet)
|
||||
|
||||
response, err := dockerCli.Client().ImageLoad(ctx, input, loadOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||
args []string
|
||||
isTerminalIn bool
|
||||
expectedError string
|
||||
imageLoadFunc func(input io.Reader, quiet bool) (image.LoadResponse, error)
|
||||
imageLoadFunc func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error)
|
||||
}{
|
||||
{
|
||||
name: "wrong-args",
|
||||
@ -34,7 +34,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||
{
|
||||
name: "pull-error",
|
||||
expectedError: "something went wrong",
|
||||
imageLoadFunc: func(input io.Reader, quiet bool) (image.LoadResponse, error) {
|
||||
imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) {
|
||||
return image.LoadResponse{}, errors.Errorf("something went wrong")
|
||||
},
|
||||
},
|
||||
@ -67,17 +67,17 @@ func TestNewLoadCommandSuccess(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
imageLoadFunc func(input io.Reader, quiet bool) (image.LoadResponse, error)
|
||||
imageLoadFunc func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error)
|
||||
}{
|
||||
{
|
||||
name: "simple",
|
||||
imageLoadFunc: func(input io.Reader, quiet bool) (image.LoadResponse, error) {
|
||||
imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) {
|
||||
return image.LoadResponse{Body: io.NopCloser(strings.NewReader("Success"))}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "json",
|
||||
imageLoadFunc: func(input io.Reader, quiet bool) (image.LoadResponse, error) {
|
||||
imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) {
|
||||
json := "{\"ID\": \"1\"}"
|
||||
return image.LoadResponse{
|
||||
Body: io.NopCloser(strings.NewReader(json)),
|
||||
@ -88,7 +88,7 @@ func TestNewLoadCommandSuccess(t *testing.T) {
|
||||
{
|
||||
name: "input-file",
|
||||
args: []string{"--input", "testdata/load-command-success.input.txt"},
|
||||
imageLoadFunc: func(input io.Reader, quiet bool) (image.LoadResponse, error) {
|
||||
imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) {
|
||||
return image.LoadResponse{Body: io.NopCloser(strings.NewReader("Success"))}, nil
|
||||
},
|
||||
},
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@ -51,7 +52,7 @@ func RunSave(ctx context.Context, dockerCli command.Cli, opts saveOptions) error
|
||||
return errors.Wrap(err, "failed to save image")
|
||||
}
|
||||
|
||||
responseBody, err := dockerCli.Client().ImageSave(ctx, opts.images)
|
||||
responseBody, err := dockerCli.Client().ImageSave(ctx, opts.images, image.SaveOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
@ -18,7 +19,7 @@ func TestNewSaveCommandErrors(t *testing.T) {
|
||||
args []string
|
||||
isTerminal bool
|
||||
expectedError string
|
||||
imageSaveFunc func(images []string) (io.ReadCloser, error)
|
||||
imageSaveFunc func(images []string, options image.SaveOptions) (io.ReadCloser, error)
|
||||
}{
|
||||
{
|
||||
name: "wrong args",
|
||||
@ -36,7 +37,7 @@ func TestNewSaveCommandErrors(t *testing.T) {
|
||||
args: []string{"arg1"},
|
||||
isTerminal: false,
|
||||
expectedError: "error saving image",
|
||||
imageSaveFunc: func(images []string) (io.ReadCloser, error) {
|
||||
imageSaveFunc: func(images []string, options image.SaveOptions) (io.ReadCloser, error) {
|
||||
return io.NopCloser(strings.NewReader("")), errors.Errorf("error saving image")
|
||||
},
|
||||
},
|
||||
@ -99,7 +100,7 @@ func TestNewSaveCommandSuccess(t *testing.T) {
|
||||
tc := tc
|
||||
t.Run(strings.Join(tc.args, " "), func(t *testing.T) {
|
||||
cmd := NewSaveCommand(test.NewFakeCli(&fakeClient{
|
||||
imageSaveFunc: func(images []string) (io.ReadCloser, error) {
|
||||
imageSaveFunc: func(images []string, options image.SaveOptions) (io.ReadCloser, error) {
|
||||
return io.NopCloser(strings.NewReader("")), nil
|
||||
},
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user