diff --git a/cli/command/image/client_test.go b/cli/command/image/client_test.go index 4e14bcf7abeb..a2aa4a988106 100644 --- a/cli/command/image/client_test.go +++ b/cli/command/image/client_test.go @@ -16,7 +16,7 @@ import ( type fakeClient struct { client.Client imageTagFunc func(string, string) error - imageSaveFunc func(images []string) (io.ReadCloser, error) + imageSaveFunc func(images []string, _ ...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) @@ -26,7 +26,7 @@ type fakeClient struct { 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) } diff --git a/cli/command/image/history.go b/cli/command/image/history.go index 1c0ae409811a..73a893fa976c 100644 --- a/cli/command/image/history.go +++ b/cli/command/image/history.go @@ -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 } diff --git a/cli/command/image/history_test.go b/cli/command/image/history_test.go index 072bd035a6ed..6c5c70c3ac0c 100644 --- a/cli/command/image/history_test.go +++ b/cli/command/image/history_test.go @@ -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(), diff --git a/cli/command/image/load.go b/cli/command/image/load.go index b11303d90ce9..ecb815b2b17f 100644 --- a/cli/command/image/load.go +++ b/cli/command/image/load.go @@ -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,11 @@ 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, image.LoadOptions{Quiet: opts.quiet}) if err != nil { return err } diff --git a/cli/command/image/save.go b/cli/command/image/save.go index 40cdf68ee104..c5a32859b831 100644 --- a/cli/command/image/save.go +++ b/cli/command/image/save.go @@ -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 }