vendor: github.com/docker/docker 6c3797923dcb (master, v28.0-dev)
full diff: 6968719093...6c3797923d
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -24,7 +24,7 @@ type fakeClient struct {
|
||||
imagesPruneFunc func(pruneFilter filters.Args) (image.PruneReport, 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)
|
||||
imageInspectFunc func(img string) (image.InspectResponse, error)
|
||||
imageImportFunc func(source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
||||
imageHistoryFunc func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error)
|
||||
imageBuildFunc func(context.Context, io.Reader, types.ImageBuildOptions) (types.ImageBuildResponse, error)
|
||||
@ -95,11 +95,11 @@ func (cli *fakeClient) ImageList(_ context.Context, options image.ListOptions) (
|
||||
return []image.Summary{}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ImageInspectWithRaw(_ context.Context, img string) (image.InspectResponse, []byte, error) {
|
||||
func (cli *fakeClient) ImageInspect(_ context.Context, img string, _ ...client.ImageInspectOption) (image.InspectResponse, error) {
|
||||
if cli.imageInspectFunc != nil {
|
||||
return cli.imageInspectFunc(img)
|
||||
}
|
||||
return image.InspectResponse{}, nil, nil
|
||||
return image.InspectResponse{}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ImageImport(_ context.Context, source image.ImportSource, ref string,
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
@ -11,6 +12,8 @@ import (
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/inspect"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -42,6 +45,11 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command {
|
||||
func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {
|
||||
apiClient := dockerCLI.Client()
|
||||
return inspect.Inspect(dockerCLI.Out(), opts.refs, opts.format, func(ref string) (any, []byte, error) {
|
||||
return apiClient.ImageInspectWithRaw(ctx, ref)
|
||||
var buf bytes.Buffer
|
||||
resp, err := apiClient.ImageInspect(ctx, ref, client.ImageInspectWithRawResponse(&buf))
|
||||
if err != nil {
|
||||
return image.InspectResponse{}, nil, err
|
||||
}
|
||||
return resp, buf.Bytes(), err
|
||||
})
|
||||
}
|
||||
|
||||
@ -41,39 +41,39 @@ func TestNewInspectCommandSuccess(t *testing.T) {
|
||||
name string
|
||||
args []string
|
||||
imageCount int
|
||||
imageInspectFunc func(img string) (image.InspectResponse, []byte, error)
|
||||
imageInspectFunc func(img string) (image.InspectResponse, error)
|
||||
}{
|
||||
{
|
||||
name: "simple",
|
||||
args: []string{"image"},
|
||||
imageCount: 1,
|
||||
imageInspectFunc: func(img string) (image.InspectResponse, []byte, error) {
|
||||
imageInspectFunc: func(img string) (image.InspectResponse, error) {
|
||||
imageInspectInvocationCount++
|
||||
assert.Check(t, is.Equal("image", img))
|
||||
return image.InspectResponse{}, nil, nil
|
||||
return image.InspectResponse{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "format",
|
||||
imageCount: 1,
|
||||
args: []string{"--format='{{.ID}}'", "image"},
|
||||
imageInspectFunc: func(img string) (image.InspectResponse, []byte, error) {
|
||||
imageInspectFunc: func(img string) (image.InspectResponse, error) {
|
||||
imageInspectInvocationCount++
|
||||
return image.InspectResponse{ID: img}, nil, nil
|
||||
return image.InspectResponse{ID: img}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "simple-many",
|
||||
args: []string{"image1", "image2"},
|
||||
imageCount: 2,
|
||||
imageInspectFunc: func(img string) (image.InspectResponse, []byte, error) {
|
||||
imageInspectFunc: func(img string) (image.InspectResponse, error) {
|
||||
imageInspectInvocationCount++
|
||||
if imageInspectInvocationCount == 1 {
|
||||
assert.Check(t, is.Equal("image1", img))
|
||||
} else {
|
||||
assert.Check(t, is.Equal("image2", img))
|
||||
}
|
||||
return image.InspectResponse{}, nil, nil
|
||||
return image.InspectResponse{}, nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user