Skip to content

Commit eb675cc

Browse files
committed
api/types: move ImageImportSource to api/types/image
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f6cc76c commit eb675cc

9 files changed

Lines changed: 21 additions & 20 deletions

File tree

api/types/client.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ type ImageBuildResponse struct {
130130
OSType string
131131
}
132132

133-
// ImageImportSource holds source information for ImageImport
134-
type ImageImportSource struct {
135-
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
136-
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
137-
}
138-
139133
// ImageLoadResponse returns information to the client about a load process.
140134
type ImageLoadResponse struct {
141135
// Body must be closed to avoid a resource leak

api/types/image/opts.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ package image
22

33
import (
44
"context"
5+
"io"
56

67
"github.com/docker/docker/api/types/filters"
78
)
89

10+
// ImportSource holds source information for ImageImport
11+
type ImportSource struct {
12+
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
13+
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
14+
}
15+
916
// ImportOptions holds information to import images from the client host.
1017
type ImportOptions struct {
1118
Tag string // Tag is the name to tag this image with. This attribute is deprecated.

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ type EventsOptions = events.ListOptions
123123
//
124124
// Deprecated: use [registry.SearchOptions].
125125
type ImageSearchOptions = registry.SearchOptions
126+
127+
// ImageImportSource holds source information for ImageImport
128+
//
129+
// Deprecated: use [image.ImportSource].
130+
type ImageImportSource image.ImportSource

client/image_import.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77
"strings"
88

99
"github.com/distribution/reference"
10-
"github.com/docker/docker/api/types"
1110
"github.com/docker/docker/api/types/image"
1211
)
1312

1413
// ImageImport creates a new image based on the source options.
1514
// It returns the JSON content in the response body.
16-
func (cli *Client) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
15+
func (cli *Client) ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
1716
if ref != "" {
1817
// Check if the given image name can be resolved
1918
if _, err := reference.ParseNormalizedNamed(ref); err != nil {

client/image_import_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/docker/docker/api/types"
1413
"github.com/docker/docker/api/types/image"
1514
"github.com/docker/docker/errdefs"
1615
"gotest.tools/v3/assert"
@@ -21,7 +20,7 @@ func TestImageImportError(t *testing.T) {
2120
client := &Client{
2221
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
2322
}
24-
_, err := client.ImageImport(context.Background(), types.ImageImportSource{}, "image:tag", image.ImportOptions{})
23+
_, err := client.ImageImport(context.Background(), image.ImportSource{}, "image:tag", image.ImportOptions{})
2524
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
2625
}
2726

@@ -61,7 +60,7 @@ func TestImageImport(t *testing.T) {
6160
}, nil
6261
}),
6362
}
64-
importResponse, err := client.ImageImport(context.Background(), types.ImageImportSource{
63+
importResponse, err := client.ImageImport(context.Background(), image.ImportSource{
6564
Source: strings.NewReader("source"),
6665
SourceName: "image_source",
6766
}, "repository_name:imported", image.ImportOptions{

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ type ImageAPIClient interface {
9292
BuildCancel(ctx context.Context, id string) error
9393
ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error)
9494
ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
95-
ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
95+
ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
9696
ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
9797
ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
9898
ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)

integration/container/export_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/docker/docker/api/types"
109
"github.com/docker/docker/api/types/filters"
1110
"github.com/docker/docker/api/types/image"
1211
"github.com/docker/docker/integration/internal/container"
@@ -32,7 +31,7 @@ func TestExportContainerAndImportImage(t *testing.T) {
3231
reference := "repo/" + strings.ToLower(t.Name()) + ":v1"
3332
exportResp, err := apiClient.ContainerExport(ctx, cID)
3433
assert.NilError(t, err)
35-
importResp, err := apiClient.ImageImport(ctx, types.ImageImportSource{
34+
importResp, err := apiClient.ImageImport(ctx, image.ImportSource{
3635
Source: exportResp,
3736
SourceName: "-",
3837
}, reference, image.ImportOptions{})

integration/image/import_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010
"testing"
1111

12-
"github.com/docker/docker/api/types"
1312
imagetypes "github.com/docker/docker/api/types/image"
1413
"github.com/docker/docker/errdefs"
1514
"github.com/docker/docker/image"
@@ -48,7 +47,7 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) {
4847
reference := strings.ToLower(t.Name()) + ":v42"
4948

5049
_, err = client.ImageImport(ctx,
51-
types.ImageImportSource{Source: imageRdr, SourceName: "-"},
50+
imagetypes.ImportSource{Source: imageRdr, SourceName: "-"},
5251
reference,
5352
imagetypes.ImportOptions{})
5453
assert.NilError(t, err)
@@ -111,7 +110,7 @@ func TestImportWithCustomPlatform(t *testing.T) {
111110
reference := "import-with-platform:tc-" + strconv.Itoa(i)
112111

113112
_, err = client.ImageImport(ctx,
114-
types.ImageImportSource{Source: imageRdr, SourceName: "-"},
113+
imagetypes.ImportSource{Source: imageRdr, SourceName: "-"},
115114
reference,
116115
imagetypes.ImportOptions{Platform: tc.platform})
117116
assert.NilError(t, err)
@@ -177,7 +176,7 @@ func TestImportWithCustomPlatformReject(t *testing.T) {
177176
ctx := testutil.StartSpan(ctx, t)
178177
reference := "import-with-platform:tc-" + strconv.Itoa(i)
179178
_, err = client.ImageImport(ctx,
180-
types.ImageImportSource{Source: imageRdr, SourceName: "-"},
179+
imagetypes.ImportSource{Source: imageRdr, SourceName: "-"},
181180
reference,
182181
imagetypes.ImportOptions{Platform: tc.platform})
183182

integration/plugin/authz/authz_plugin_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"testing"
1717
"time"
1818

19-
"github.com/docker/docker/api/types"
2019
containertypes "github.com/docker/docker/api/types/container"
2120
eventtypes "github.com/docker/docker/api/types/events"
2221
"github.com/docker/docker/api/types/image"
@@ -463,7 +462,7 @@ func imageImport(ctx context.Context, client client.APIClient, path string) erro
463462
defer file.Close()
464463
options := image.ImportOptions{}
465464
ref := ""
466-
source := types.ImageImportSource{
465+
source := image.ImportSource{
467466
Source: file,
468467
SourceName: "-",
469468
}

0 commit comments

Comments
 (0)