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:
Sebastiaan van Stijn
2025-01-14 22:44:51 +01:00
parent 11999b16e4
commit 01da8a582f
84 changed files with 1260 additions and 289 deletions

View File

@ -123,7 +123,8 @@ func TestNewAPIClientFromFlagsWithCustomHeadersFromEnv(t *testing.T) {
}
func TestNewAPIClientFromFlagsWithAPIVersionFromEnv(t *testing.T) {
customVersion := "v3.3.3"
const customVersion = "v3.3.3"
const expectedVersion = "3.3.3"
t.Setenv("DOCKER_API_VERSION", customVersion)
t.Setenv("DOCKER_HOST", ":2375")
@ -131,7 +132,7 @@ func TestNewAPIClientFromFlagsWithAPIVersionFromEnv(t *testing.T) {
configFile := &configfile.ConfigFile{}
apiclient, err := NewAPIClientFromFlags(opts, configFile)
assert.NilError(t, err)
assert.Equal(t, apiclient.ClientVersion(), customVersion)
assert.Equal(t, apiclient.ClientVersion(), expectedVersion)
}
type fakeClient struct {

View File

@ -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,

View File

@ -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
})
}

View File

@ -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
},
},
}

View File

@ -4,6 +4,7 @@
package system
import (
"bytes"
"context"
"fmt"
"strings"
@ -13,7 +14,9 @@ import (
"github.com/docker/cli/cli/command/inspect"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
"github.com/docker/docker/errdefs"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@ -67,7 +70,12 @@ func inspectContainers(ctx context.Context, dockerCli command.Cli, getSize bool)
func inspectImages(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc {
return func(ref string) (any, []byte, error) {
return dockerCli.Client().ImageInspectWithRaw(ctx, ref)
var buf bytes.Buffer
resp, err := dockerCli.Client().ImageInspect(ctx, ref, client.ImageInspectWithRawResponse(&buf))
if err != nil {
return image.InspectResponse{}, nil, err
}
return resp, buf.Bytes(), err
}
}

View File

@ -32,8 +32,8 @@ func (c *fakeClient) Info(context.Context) (system.Info, error) {
return system.Info{}, nil
}
func (c *fakeClient) ImageInspectWithRaw(context.Context, string) (image.InspectResponse, []byte, error) {
return image.InspectResponse{}, []byte{}, nil
func (c *fakeClient) ImageInspect(context.Context, string, ...client.ImageInspectOption) (image.InspectResponse, error) {
return image.InspectResponse{}, nil
}
func (c *fakeClient) ImagePush(context.Context, string, image.PushOptions) (io.ReadCloser, error) {

View File

@ -140,7 +140,7 @@ func validateTag(imgRefAndAuth trust.ImageRefAndAuth) error {
}
func checkLocalImageExistence(ctx context.Context, apiClient client.APIClient, imageName string) error {
_, _, err := apiClient.ImageInspectWithRaw(ctx, imageName)
_, err := apiClient.ImageInspect(ctx, imageName)
return err
}