mirror of https://github.com/docker/cli.git
Replace deprecated types.Image* usage
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
68dac842a1
commit
4fa2fe9b9e
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -17,7 +18,7 @@ type ValidArgsFn func(cmd *cobra.Command, args []string, toComplete string) ([]s
|
||||||
// ImageNames offers completion for images present within the local store
|
// ImageNames offers completion for images present within the local store
|
||||||
func ImageNames(dockerCli command.Cli) ValidArgsFn {
|
func ImageNames(dockerCli command.Cli) ValidArgsFn {
|
||||||
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
list, err := dockerCli.Client().ImageList(cmd.Context(), types.ImageListOptions{})
|
list, err := dockerCli.Client().ImageList(cmd.Context(), image.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cobra.ShellCompDirectiveError
|
return nil, cobra.ShellCompDirectiveError
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
@ -23,7 +24,7 @@ type fakeClient struct {
|
||||||
platform *specs.Platform,
|
platform *specs.Platform,
|
||||||
containerName string) (container.CreateResponse, error)
|
containerName string) (container.CreateResponse, error)
|
||||||
containerStartFunc func(containerID string, options container.StartOptions) error
|
containerStartFunc func(containerID string, options container.StartOptions) error
|
||||||
imageCreateFunc func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
|
imageCreateFunc func(parentReference string, options image.CreateOptions) (io.ReadCloser, error)
|
||||||
infoFunc func() (system.Info, error)
|
infoFunc func() (system.Info, error)
|
||||||
containerStatPathFunc func(containerID, path string) (types.ContainerPathStat, error)
|
containerStatPathFunc func(containerID, path string) (types.ContainerPathStat, error)
|
||||||
containerCopyFromFunc func(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
|
containerCopyFromFunc func(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
|
||||||
|
@ -90,7 +91,7 @@ func (f *fakeClient) ContainerRemove(ctx context.Context, containerID string, op
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeClient) ImageCreate(_ context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
|
func (f *fakeClient) ImageCreate(_ context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) {
|
||||||
if f.imageCreateFunc != nil {
|
if f.imageCreateFunc != nil {
|
||||||
return f.imageCreateFunc(parentReference, options)
|
return f.imageCreateFunc(parentReference, options)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import (
|
||||||
"github.com/docker/cli/cli/command/image"
|
"github.com/docker/cli/cli/command/image"
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
|
@ -119,7 +119,7 @@ func pullImage(ctx context.Context, dockerCli command.Cli, img string, options *
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
responseBody, err := dockerCli.Client().ImageCreate(ctx, img, types.ImageCreateOptions{
|
responseBody, err := dockerCli.Client().ImageCreate(ctx, img, imagetypes.CreateOptions{
|
||||||
RegistryAuth: encodedAuth,
|
RegistryAuth: encodedAuth,
|
||||||
Platform: options.platform,
|
Platform: options.platform,
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,8 +15,8 @@ import (
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/notary"
|
"github.com/docker/cli/internal/test/notary"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
@ -134,7 +134,7 @@ func TestCreateContainerImagePullPolicy(t *testing.T) {
|
||||||
return container.CreateResponse{ID: containerID}, nil
|
return container.CreateResponse{ID: containerID}, nil
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
imageCreateFunc: func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
|
imageCreateFunc: func(parentReference string, options image.CreateOptions) (io.ReadCloser, error) {
|
||||||
defer func() { pullCounter++ }()
|
defer func() { pullCounter++ }()
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,15 +17,15 @@ type fakeClient struct {
|
||||||
client.Client
|
client.Client
|
||||||
imageTagFunc func(string, string) error
|
imageTagFunc func(string, string) error
|
||||||
imageSaveFunc func(images []string) (io.ReadCloser, error)
|
imageSaveFunc func(images []string) (io.ReadCloser, error)
|
||||||
imageRemoveFunc func(image string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error)
|
imageRemoveFunc func(image string, options image.RemoveOptions) ([]image.DeleteResponse, error)
|
||||||
imagePushFunc func(ref string, options types.ImagePushOptions) (io.ReadCloser, error)
|
imagePushFunc func(ref string, options image.PushOptions) (io.ReadCloser, error)
|
||||||
infoFunc func() (system.Info, error)
|
infoFunc func() (system.Info, error)
|
||||||
imagePullFunc func(ref string, options types.ImagePullOptions) (io.ReadCloser, error)
|
imagePullFunc func(ref string, options image.PullOptions) (io.ReadCloser, error)
|
||||||
imagesPruneFunc func(pruneFilter filters.Args) (types.ImagesPruneReport, error)
|
imagesPruneFunc func(pruneFilter filters.Args) (types.ImagesPruneReport, error)
|
||||||
imageLoadFunc func(input io.Reader, quiet bool) (types.ImageLoadResponse, error)
|
imageLoadFunc func(input io.Reader, quiet bool) (types.ImageLoadResponse, error)
|
||||||
imageListFunc func(options types.ImageListOptions) ([]image.Summary, error)
|
imageListFunc func(options image.ListOptions) ([]image.Summary, error)
|
||||||
imageInspectFunc func(image string) (types.ImageInspect, []byte, error)
|
imageInspectFunc func(image string) (types.ImageInspect, []byte, error)
|
||||||
imageImportFunc func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
|
imageImportFunc func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
||||||
imageHistoryFunc func(image string) ([]image.HistoryResponseItem, error)
|
imageHistoryFunc func(image string) ([]image.HistoryResponseItem, error)
|
||||||
imageBuildFunc func(context.Context, io.Reader, types.ImageBuildOptions) (types.ImageBuildResponse, error)
|
imageBuildFunc func(context.Context, io.Reader, types.ImageBuildOptions) (types.ImageBuildResponse, error)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func (cli *fakeClient) ImageSave(_ context.Context, images []string) (io.ReadClo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ImageRemove(_ context.Context, img string,
|
func (cli *fakeClient) ImageRemove(_ context.Context, img string,
|
||||||
options types.ImageRemoveOptions,
|
options image.RemoveOptions,
|
||||||
) ([]image.DeleteResponse, error) {
|
) ([]image.DeleteResponse, error) {
|
||||||
if cli.imageRemoveFunc != nil {
|
if cli.imageRemoveFunc != nil {
|
||||||
return cli.imageRemoveFunc(img, options)
|
return cli.imageRemoveFunc(img, options)
|
||||||
|
@ -53,7 +53,7 @@ func (cli *fakeClient) ImageRemove(_ context.Context, img string,
|
||||||
return []image.DeleteResponse{}, nil
|
return []image.DeleteResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ImagePush(_ context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) {
|
func (cli *fakeClient) ImagePush(_ context.Context, ref string, options image.PushOptions) (io.ReadCloser, error) {
|
||||||
if cli.imagePushFunc != nil {
|
if cli.imagePushFunc != nil {
|
||||||
return cli.imagePushFunc(ref, options)
|
return cli.imagePushFunc(ref, options)
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func (cli *fakeClient) Info(_ context.Context) (system.Info, error) {
|
||||||
return system.Info{}, nil
|
return system.Info{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ImagePull(_ context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) {
|
func (cli *fakeClient) ImagePull(_ context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
|
||||||
if cli.imagePullFunc != nil {
|
if cli.imagePullFunc != nil {
|
||||||
cli.imagePullFunc(ref, options)
|
cli.imagePullFunc(ref, options)
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func (cli *fakeClient) ImageLoad(_ context.Context, input io.Reader, quiet bool)
|
||||||
return types.ImageLoadResponse{}, nil
|
return types.ImageLoadResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ImageList(_ context.Context, options types.ImageListOptions) ([]image.Summary, error) {
|
func (cli *fakeClient) ImageList(_ context.Context, options image.ListOptions) ([]image.Summary, error) {
|
||||||
if cli.imageListFunc != nil {
|
if cli.imageListFunc != nil {
|
||||||
return cli.imageListFunc(options)
|
return cli.imageListFunc(options)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func (cli *fakeClient) ImageInspectWithRaw(_ context.Context, img string) (types
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ImageImport(_ context.Context, source types.ImageImportSource, ref string,
|
func (cli *fakeClient) ImageImport(_ context.Context, source types.ImageImportSource, ref string,
|
||||||
options types.ImageImportOptions,
|
options image.ImportOptions,
|
||||||
) (io.ReadCloser, error) {
|
) (io.ReadCloser, error) {
|
||||||
if cli.imageImportFunc != nil {
|
if cli.imageImportFunc != nil {
|
||||||
return cli.imageImportFunc(source, ref, options)
|
return cli.imageImportFunc(source, ref, options)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
dockeropts "github.com/docker/cli/opts"
|
dockeropts "github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -78,7 +79,7 @@ func runImport(ctx context.Context, dockerCli command.Cli, options importOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
responseBody, err := dockerCli.Client().ImageImport(ctx, source, options.reference, types.ImageImportOptions{
|
responseBody, err := dockerCli.Client().ImageImport(ctx, source, options.reference, image.ImportOptions{
|
||||||
Message: options.message,
|
Message: options.message,
|
||||||
Changes: options.changes.GetAll(),
|
Changes: options.changes.GetAll(),
|
||||||
Platform: options.platform,
|
Platform: options.platform,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
@ -17,7 +18,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectedError string
|
expectedError string
|
||||||
imageImportFunc func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
|
imageImportFunc func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "wrong-args",
|
name: "wrong-args",
|
||||||
|
@ -28,7 +29,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||||
name: "import-failed",
|
name: "import-failed",
|
||||||
args: []string{"testdata/import-command-success.input.txt"},
|
args: []string{"testdata/import-command-success.input.txt"},
|
||||||
expectedError: "something went wrong",
|
expectedError: "something went wrong",
|
||||||
imageImportFunc: func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
|
imageImportFunc: func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
|
||||||
return nil, errors.Errorf("something went wrong")
|
return nil, errors.Errorf("something went wrong")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -52,7 +53,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
imageImportFunc func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
|
imageImportFunc func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple",
|
name: "simple",
|
||||||
|
@ -65,7 +66,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "double",
|
name: "double",
|
||||||
args: []string{"-", "image:local"},
|
args: []string{"-", "image:local"},
|
||||||
imageImportFunc: func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
|
imageImportFunc: func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
|
||||||
assert.Check(t, is.Equal("image:local", ref))
|
assert.Check(t, is.Equal("image:local", ref))
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
|
@ -73,7 +74,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "message",
|
name: "message",
|
||||||
args: []string{"--message", "test message", "-"},
|
args: []string{"--message", "test message", "-"},
|
||||||
imageImportFunc: func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
|
imageImportFunc: func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
|
||||||
assert.Check(t, is.Equal("test message", options.Message))
|
assert.Check(t, is.Equal("test message", options.Message))
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
|
@ -81,7 +82,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "change",
|
name: "change",
|
||||||
args: []string{"--change", "ENV DEBUG=true", "-"},
|
args: []string{"--change", "ENV DEBUG=true", "-"},
|
||||||
imageImportFunc: func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
|
imageImportFunc: func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
|
||||||
assert.Check(t, is.Equal("ENV DEBUG=true", options.Changes[0]))
|
assert.Check(t, is.Equal("ENV DEBUG=true", options.Changes[0]))
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
|
@ -89,7 +90,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "change legacy syntax",
|
name: "change legacy syntax",
|
||||||
args: []string{"--change", "ENV DEBUG true", "-"},
|
args: []string{"--change", "ENV DEBUG true", "-"},
|
||||||
imageImportFunc: func(source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
|
imageImportFunc: func(source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
|
||||||
assert.Check(t, is.Equal("ENV DEBUG true", options.Changes[0]))
|
assert.Check(t, is.Equal("ENV DEBUG true", options.Changes[0]))
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func runImages(ctx context.Context, dockerCli command.Cli, options imagesOptions
|
||||||
filters.Add("reference", options.matchName)
|
filters.Add("reference", options.matchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
listOptions := types.ImageListOptions{
|
listOptions := image.ListOptions{
|
||||||
All: options.all,
|
All: options.all,
|
||||||
Filters: filters,
|
Filters: filters,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
@ -20,7 +19,7 @@ func TestNewImagesCommandErrors(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectedError string
|
expectedError string
|
||||||
imageListFunc func(options types.ImageListOptions) ([]image.Summary, error)
|
imageListFunc func(options image.ListOptions) ([]image.Summary, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "wrong-args",
|
name: "wrong-args",
|
||||||
|
@ -30,7 +29,7 @@ func TestNewImagesCommandErrors(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "failed-list",
|
name: "failed-list",
|
||||||
expectedError: "something went wrong",
|
expectedError: "something went wrong",
|
||||||
imageListFunc: func(options types.ImageListOptions) ([]image.Summary, error) {
|
imageListFunc: func(options image.ListOptions) ([]image.Summary, error) {
|
||||||
return []image.Summary{}, errors.Errorf("something went wrong")
|
return []image.Summary{}, errors.Errorf("something went wrong")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -48,7 +47,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
imageFormat string
|
imageFormat string
|
||||||
imageListFunc func(options types.ImageListOptions) ([]image.Summary, error)
|
imageListFunc func(options image.ListOptions) ([]image.Summary, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple",
|
name: "simple",
|
||||||
|
@ -65,7 +64,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "match-name",
|
name: "match-name",
|
||||||
args: []string{"image"},
|
args: []string{"image"},
|
||||||
imageListFunc: func(options types.ImageListOptions) ([]image.Summary, error) {
|
imageListFunc: func(options image.ListOptions) ([]image.Summary, error) {
|
||||||
assert.Check(t, is.Equal("image", options.Filters.Get("reference")[0]))
|
assert.Check(t, is.Equal("image", options.Filters.Get("reference")[0]))
|
||||||
return []image.Summary{}, nil
|
return []image.Summary{}, nil
|
||||||
},
|
},
|
||||||
|
@ -73,7 +72,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "filters",
|
name: "filters",
|
||||||
args: []string{"--filter", "name=value"},
|
args: []string{"--filter", "name=value"},
|
||||||
imageListFunc: func(options types.ImageListOptions) ([]image.Summary, error) {
|
imageListFunc: func(options image.ListOptions) ([]image.Summary, error) {
|
||||||
assert.Check(t, is.Equal("value", options.Filters.Get("name")[0]))
|
assert.Check(t, is.Equal("value", options.Filters.Get("name")[0]))
|
||||||
return []image.Summary{}, nil
|
return []image.Summary{}, nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/notary"
|
"github.com/docker/cli/internal/test/notary"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/image"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
|
@ -69,7 +69,7 @@ func TestNewPullCommandSuccess(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
imagePullFunc: func(ref string, options types.ImagePullOptions) (io.ReadCloser, error) {
|
imagePullFunc: func(ref string, options image.PullOptions) (io.ReadCloser, error) {
|
||||||
assert.Check(t, is.Equal(tc.expectedTag, ref), tc.name)
|
assert.Check(t, is.Equal(tc.expectedTag, ref), tc.name)
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
|
@ -111,7 +111,7 @@ func TestNewPullCommandWithContentTrustErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
imagePullFunc: func(ref string, options types.ImagePullOptions) (io.ReadCloser, error) {
|
imagePullFunc: func(ref string, options image.PullOptions) (io.ReadCloser, error) {
|
||||||
return io.NopCloser(strings.NewReader("")), fmt.Errorf("shouldn't try to pull image")
|
return io.NopCloser(strings.NewReader("")), fmt.Errorf("shouldn't try to pull image")
|
||||||
},
|
},
|
||||||
}, test.EnableContentTrust)
|
}, test.EnableContentTrust)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/image"
|
||||||
registrytypes "github.com/docker/docker/api/types/registry"
|
registrytypes "github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
|
@ -80,7 +80,7 @@ func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
requestPrivilege := command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, "push")
|
requestPrivilege := command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, "push")
|
||||||
options := types.ImagePushOptions{
|
options := image.PushOptions{
|
||||||
All: opts.all,
|
All: opts.all,
|
||||||
RegistryAuth: encodedAuth,
|
RegistryAuth: encodedAuth,
|
||||||
PrivilegeFunc: requestPrivilege,
|
PrivilegeFunc: requestPrivilege,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectedError string
|
expectedError string
|
||||||
imagePushFunc func(ref string, options types.ImagePushOptions) (io.ReadCloser, error)
|
imagePushFunc func(ref string, options image.PushOptions) (io.ReadCloser, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "wrong-args",
|
name: "wrong-args",
|
||||||
|
@ -32,7 +32,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
name: "push-failed",
|
name: "push-failed",
|
||||||
args: []string{"image:repo"},
|
args: []string{"image:repo"},
|
||||||
expectedError: "Failed to push",
|
expectedError: "Failed to push",
|
||||||
imagePushFunc: func(ref string, options types.ImagePushOptions) (io.ReadCloser, error) {
|
imagePushFunc: func(ref string, options image.PushOptions) (io.ReadCloser, error) {
|
||||||
return io.NopCloser(strings.NewReader("")), errors.Errorf("Failed to push")
|
return io.NopCloser(strings.NewReader("")), errors.Errorf("Failed to push")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -67,7 +67,7 @@ func TestNewPushCommandSuccess(t *testing.T) {
|
||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
imagePushFunc: func(ref string, options types.ImagePushOptions) (io.ReadCloser, error) {
|
imagePushFunc: func(ref string, options image.PushOptions) (io.ReadCloser, error) {
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -52,7 +52,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
func runRemove(ctx context.Context, dockerCli command.Cli, opts removeOptions, images []string) error {
|
func runRemove(ctx context.Context, dockerCli command.Cli, opts removeOptions, images []string) error {
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
options := types.ImageRemoveOptions{
|
options := image.RemoveOptions{
|
||||||
Force: opts.force,
|
Force: opts.force,
|
||||||
PruneChildren: !opts.noPrune,
|
PruneChildren: !opts.noPrune,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
@ -36,7 +35,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectedError string
|
expectedError string
|
||||||
imageRemoveFunc func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error)
|
imageRemoveFunc func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "wrong args",
|
name: "wrong args",
|
||||||
|
@ -46,7 +45,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||||
name: "ImageRemove fail with force option",
|
name: "ImageRemove fail with force option",
|
||||||
args: []string{"-f", "image1"},
|
args: []string{"-f", "image1"},
|
||||||
expectedError: "error removing image",
|
expectedError: "error removing image",
|
||||||
imageRemoveFunc: func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||||
assert.Check(t, is.Equal("image1", img))
|
assert.Check(t, is.Equal("image1", img))
|
||||||
return []image.DeleteResponse{}, errors.Errorf("error removing image")
|
return []image.DeleteResponse{}, errors.Errorf("error removing image")
|
||||||
},
|
},
|
||||||
|
@ -55,7 +54,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||||
name: "ImageRemove fail",
|
name: "ImageRemove fail",
|
||||||
args: []string{"arg1"},
|
args: []string{"arg1"},
|
||||||
expectedError: "error removing image",
|
expectedError: "error removing image",
|
||||||
imageRemoveFunc: func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||||
assert.Check(t, !options.Force)
|
assert.Check(t, !options.Force)
|
||||||
assert.Check(t, options.PruneChildren)
|
assert.Check(t, options.PruneChildren)
|
||||||
return []image.DeleteResponse{}, errors.Errorf("error removing image")
|
return []image.DeleteResponse{}, errors.Errorf("error removing image")
|
||||||
|
@ -78,13 +77,13 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
imageRemoveFunc func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error)
|
imageRemoveFunc func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error)
|
||||||
expectedStderr string
|
expectedStderr string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Image Deleted",
|
name: "Image Deleted",
|
||||||
args: []string{"image1"},
|
args: []string{"image1"},
|
||||||
imageRemoveFunc: func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||||
assert.Check(t, is.Equal("image1", img))
|
assert.Check(t, is.Equal("image1", img))
|
||||||
return []image.DeleteResponse{{Deleted: img}}, nil
|
return []image.DeleteResponse{{Deleted: img}}, nil
|
||||||
},
|
},
|
||||||
|
@ -92,7 +91,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Image not found with force option",
|
name: "Image not found with force option",
|
||||||
args: []string{"-f", "image1"},
|
args: []string{"-f", "image1"},
|
||||||
imageRemoveFunc: func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||||
assert.Check(t, is.Equal("image1", img))
|
assert.Check(t, is.Equal("image1", img))
|
||||||
assert.Check(t, is.Equal(true, options.Force))
|
assert.Check(t, is.Equal(true, options.Force))
|
||||||
return []image.DeleteResponse{}, notFound{"image1"}
|
return []image.DeleteResponse{}, notFound{"image1"}
|
||||||
|
@ -103,7 +102,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Image Untagged",
|
name: "Image Untagged",
|
||||||
args: []string{"image1"},
|
args: []string{"image1"},
|
||||||
imageRemoveFunc: func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||||
assert.Check(t, is.Equal("image1", img))
|
assert.Check(t, is.Equal("image1", img))
|
||||||
return []image.DeleteResponse{{Untagged: img}}, nil
|
return []image.DeleteResponse{{Untagged: img}}, nil
|
||||||
},
|
},
|
||||||
|
@ -111,7 +110,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Image Deleted and Untagged",
|
name: "Image Deleted and Untagged",
|
||||||
args: []string{"image1", "image2"},
|
args: []string{"image1", "image2"},
|
||||||
imageRemoveFunc: func(img string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||||
if img == "image1" {
|
if img == "image1" {
|
||||||
return []image.DeleteResponse{{Untagged: img}}, nil
|
return []image.DeleteResponse{{Untagged: img}}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
"github.com/docker/cli/cli/trust"
|
"github.com/docker/cli/cli/trust"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
registrytypes "github.com/docker/docker/api/types/registry"
|
registrytypes "github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
|
@ -30,7 +31,7 @@ type target struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrustedPush handles content trust pushing of an image
|
// TrustedPush handles content trust pushing of an image
|
||||||
func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named, authConfig registrytypes.AuthConfig, options types.ImagePushOptions) error {
|
func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named, authConfig registrytypes.AuthConfig, options image.PushOptions) error {
|
||||||
responseBody, err := cli.Client().ImagePush(ctx, reference.FamiliarString(ref), options)
|
responseBody, err := cli.Client().ImagePush(ctx, reference.FamiliarString(ref), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -267,7 +268,7 @@ func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth tru
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
requestPrivilege := command.RegistryAuthenticationPrivilegedFunc(cli, imgRefAndAuth.RepoInfo().Index, "pull")
|
requestPrivilege := command.RegistryAuthenticationPrivilegedFunc(cli, imgRefAndAuth.RepoInfo().Index, "pull")
|
||||||
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), types.ImagePullOptions{
|
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), image.PullOptions{
|
||||||
RegistryAuth: encodedAuth,
|
RegistryAuth: encodedAuth,
|
||||||
PrivilegeFunc: requestPrivilege,
|
PrivilegeFunc: requestPrivilege,
|
||||||
All: opts.all,
|
All: opts.all,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
notaryfake "github.com/docker/cli/internal/test/notary"
|
notaryfake "github.com/docker/cli/internal/test/notary"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
apiclient "github.com/docker/docker/client"
|
apiclient "github.com/docker/docker/client"
|
||||||
"github.com/theupdateframework/notary"
|
"github.com/theupdateframework/notary"
|
||||||
|
@ -36,7 +37,7 @@ func (c *fakeClient) ImageInspectWithRaw(context.Context, string) (types.ImageIn
|
||||||
return types.ImageInspect{}, []byte{}, nil
|
return types.ImageInspect{}, []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *fakeClient) ImagePush(context.Context, string, types.ImagePushOptions) (io.ReadCloser, error) {
|
func (c *fakeClient) ImagePush(context.Context, string, image.PushOptions) (io.ReadCloser, error) {
|
||||||
return &utils.NoopCloser{Reader: bytes.NewBuffer([]byte{})}, nil
|
return &utils.NoopCloser{Reader: bytes.NewBuffer([]byte{})}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/image"
|
"github.com/docker/cli/cli/command/image"
|
||||||
"github.com/docker/cli/cli/trust"
|
"github.com/docker/cli/cli/trust"
|
||||||
"github.com/docker/docker/api/types"
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
registrytypes "github.com/docker/docker/api/types/registry"
|
registrytypes "github.com/docker/docker/api/types/registry"
|
||||||
apiclient "github.com/docker/docker/client"
|
apiclient "github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -98,7 +98,7 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
options := types.ImagePushOptions{
|
options := imagetypes.PushOptions{
|
||||||
RegistryAuth: encodedAuth,
|
RegistryAuth: encodedAuth,
|
||||||
PrivilegeFunc: requestPrivilege,
|
PrivilegeFunc: requestPrivilege,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue