Merge pull request #50910 from thaJeztah/api_docs_image_config
api/docs: remove temporary "full" example for image config
diff --git a/api/docs/v1.52.yaml b/api/docs/v1.52.yaml
index 49ed133..3f50dc3 100644
--- a/api/docs/v1.52.yaml
+++ b/api/docs/v1.52.yaml
@@ -2408,10 +2408,13 @@
Name of the network.
type: "string"
example: "my_network"
+ x-omitempty: false
Id:
description: |
ID that uniquely identifies a network on a single machine.
type: "string"
+ x-go-name: "ID"
+ x-omitempty: false
example: "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99"
Created:
description: |
@@ -2419,36 +2422,53 @@
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
type: "string"
format: "dateTime"
+ x-omitempty: false
+ x-go-type:
+ type: Time
+ import:
+ package: time
+ hints:
+ nullable: false
example: "2016-10-19T04:33:30.360899459Z"
Scope:
description: |
The level at which the network exists (e.g. `swarm` for cluster-wide
or `local` for machine level)
type: "string"
+ x-omitempty: false
example: "local"
Driver:
description: |
The name of the driver used to create the network (e.g. `bridge`,
`overlay`).
type: "string"
+ x-omitempty: false
example: "overlay"
EnableIPv4:
description: |
Whether the network was created with IPv4 enabled.
type: "boolean"
+ x-omitempty: false
example: true
EnableIPv6:
description: |
Whether the network was created with IPv6 enabled.
type: "boolean"
+ x-omitempty: false
example: false
IPAM:
+ description: |
+ The network's IP Address Management.
$ref: "#/definitions/IPAM"
+ x-nullable: false
+ x-omitempty: false
Internal:
description: |
Whether the network is created to only allow internal networking
connectivity.
type: "boolean"
+ x-nullable: false
+ x-omitempty: false
default: false
example: false
Attachable:
@@ -2456,16 +2476,22 @@
Whether a global / swarm scope network is manually attachable by regular
containers from workers in swarm mode.
type: "boolean"
+ x-nullable: false
+ x-omitempty: false
default: false
example: false
Ingress:
description: |
Whether the network is providing the routing-mesh for the swarm cluster.
type: "boolean"
+ x-nullable: false
+ x-omitempty: false
default: false
example: false
ConfigFrom:
$ref: "#/definitions/ConfigReference"
+ x-nullable: false
+ x-omitempty: false
ConfigOnly:
description: |
Whether the network is a config-only network. Config-only networks are
@@ -2473,24 +2499,14 @@
networks. Config-only networks cannot be used directly to run containers
or services.
type: "boolean"
+ x-omitempty: false
+ x-nullable: false
default: false
- Containers:
- description: |
- Contains endpoints attached to the network.
- type: "object"
- additionalProperties:
- $ref: "#/definitions/NetworkContainer"
- example:
- 19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c:
- Name: "test"
- EndpointID: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
- MacAddress: "02:42:ac:13:00:02"
- IPv4Address: "172.19.0.2/16"
- IPv6Address: ""
Options:
description: |
Network-specific options uses when creating the network.
type: "object"
+ x-omitempty: false
additionalProperties:
type: "string"
example:
@@ -2501,8 +2517,10 @@
com.docker.network.bridge.name: "docker0"
com.docker.network.driver.mtu: "1500"
Labels:
- description: "User-defined key/value metadata."
+ description: |
+ Metadata specific to the network being created.
type: "object"
+ x-omitempty: false
additionalProperties:
type: "string"
example:
@@ -2513,12 +2531,101 @@
List of peer nodes for an overlay network. This field is only present
for overlay networks, and omitted for other network types.
type: "array"
+ x-omitempty: true
items:
$ref: "#/definitions/PeerInfo"
- x-nullable: true
- # TODO: Add Services (only present when "verbose" is set).
+
+ NetworkSummary:
+ description: "Network list response item"
+ x-go-name: Summary
+ type: "object"
+ allOf:
+ - $ref: "#/definitions/Network"
+
+ NetworkInspect:
+ description: 'The body of the "get network" http response message.'
+ x-go-name: Inspect
+ type: "object"
+ allOf:
+ - $ref: "#/definitions/Network"
+ properties:
+ Containers:
+ description: |
+ Contains endpoints attached to the network.
+ type: "object"
+ x-omitempty: false
+ additionalProperties:
+ $ref: "#/definitions/EndpointResource"
+ example:
+ 19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c:
+ Name: "test"
+ EndpointID: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
+ MacAddress: "02:42:ac:13:00:02"
+ IPv4Address: "172.19.0.2/16"
+ IPv6Address: ""
+ Services:
+ description: |
+ List of services using the network. This field is only present for
+ swarm scope networks, and omitted for local scope networks.
+ type: "object"
+ x-omitempty: true
+ additionalProperties:
+ x-go-type:
+ type: ServiceInfo
+ hints:
+ nullable: false
+
+ ServiceInfo:
+ x-nullable: false
+ x-omitempty: false
+ description: >
+ represents service parameters with the list of service's tasks
+ type: "object"
+ properties:
+ VIP:
+ type: "string"
+ x-omitempty: false
+ Ports:
+ type: "array"
+ x-omitempty: false
+ items:
+ type: "string"
+ LocalLBIndex:
+ type: "integer"
+ format: "int"
+ x-omitempty: false
+ Tasks:
+ type: "array"
+ x-omitempty: false
+ items:
+ $ref: "#/definitions/NetworkTaskInfo"
+
+ NetworkTaskInfo:
+ x-nullable: false
+ x-omitempty: false
+ x-go-name: Task
+ description: >
+ carries the information about one backend task
+ type: "object"
+ properties:
+ Name:
+ type: "string"
+ x-omitempty: false
+ EndpointID:
+ type: "string"
+ x-omitempty: false
+ EndpointIP:
+ type: "string"
+ x-omitempty: false
+ Info:
+ type: "object"
+ x-omitempty: false
+ additionalProperties:
+ type: "string"
ConfigReference:
+ x-nullable: false
+ x-omitempty: false
description: |
The config-only network source to provide the configuration for
this network.
@@ -2530,10 +2637,13 @@
configuration. The specified network must be an existing config-only
network. Only network names are allowed, not network IDs.
type: "string"
+ x-omitempty: false
example: "config_only_network_01"
IPAM:
type: "object"
+ x-nullable: false
+ x-omitempty: false
properties:
Driver:
description: "Name of the IPAM driver to use."
@@ -2575,39 +2685,50 @@
additionalProperties:
type: "string"
- NetworkContainer:
+ EndpointResource:
type: "object"
+ description: >
+ contains network resources allocated and used for a
+ container in a network.
properties:
Name:
type: "string"
+ x-omitempty: false
example: "container_1"
EndpointID:
type: "string"
+ x-omitempty: false
example: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
MacAddress:
type: "string"
+ x-omitempty: false
example: "02:42:ac:13:00:02"
IPv4Address:
type: "string"
+ x-omitempty: false
example: "172.19.0.2/16"
IPv6Address:
type: "string"
+ x-omitempty: false
example: ""
PeerInfo:
- description: |
- PeerInfo represents one peer of an overlay network.
+ description: >
+ represents one peer of an overlay network.
type: "object"
+ x-nullable: false
properties:
Name:
description:
ID of the peer-node in the Swarm cluster.
type: "string"
+ x-omitempty: false
example: "6869d7c1732b"
IP:
description:
IP-address of the peer-node in the Swarm cluster.
type: "string"
+ x-omitempty: false
example: "10.133.77.91"
NetworkCreateResponse:
@@ -10996,7 +11117,7 @@
schema:
type: "array"
items:
- $ref: "#/definitions/Network"
+ $ref: "#/definitions/NetworkSummary"
examples:
application/json:
- Name: "bridge"
@@ -11087,7 +11208,7 @@
200:
description: "No error"
schema:
- $ref: "#/definitions/Network"
+ $ref: "#/definitions/NetworkInspect"
404:
description: "Network not found"
schema:
diff --git a/api/types/build/build.go b/api/types/build/build.go
index a798802..db98397 100644
--- a/api/types/build/build.go
+++ b/api/types/build/build.go
@@ -1,12 +1,5 @@
package build
-import (
- "io"
-
- "github.com/moby/moby/api/types/container"
- "github.com/moby/moby/api/types/registry"
-)
-
// BuilderVersion sets the version of underlying builder to use
type BuilderVersion string
@@ -21,71 +14,3 @@
type Result struct {
ID string
}
-
-// ImageBuildOptions holds the information
-// necessary to build images.
-type ImageBuildOptions struct {
- Tags []string
- SuppressOutput bool
- RemoteContext string
- NoCache bool
- Remove bool
- ForceRemove bool
- PullParent bool
- Isolation container.Isolation
- CPUSetCPUs string
- CPUSetMems string
- CPUShares int64
- CPUQuota int64
- CPUPeriod int64
- Memory int64
- MemorySwap int64
- CgroupParent string
- NetworkMode string
- ShmSize int64
- Dockerfile string
- Ulimits []*container.Ulimit
- // BuildArgs needs to be a *string instead of just a string so that
- // we can tell the difference between "" (empty string) and no value
- // at all (nil). See the parsing of buildArgs in
- // api/server/router/build/build_routes.go for even more info.
- BuildArgs map[string]*string
- AuthConfigs map[string]registry.AuthConfig
- Context io.Reader
- Labels map[string]string
- // squash the resulting image's layers to the parent
- // preserves the original image and creates a new one from the parent with all
- // the changes applied to a single layer
- Squash bool
- // CacheFrom specifies images that are used for matching cache. Images
- // specified here do not need to have a valid parent chain to match cache.
- CacheFrom []string
- SecurityOpt []string
- ExtraHosts []string // List of extra hosts
- Target string
- SessionID string
- Platform string
- // Version specifies the version of the underlying builder to use
- Version BuilderVersion
- // BuildID is an optional identifier that can be passed together with the
- // build request. The same identifier can be used to gracefully cancel the
- // build with the cancel request.
- BuildID string
- // Outputs defines configurations for exporting build results. Only supported
- // in BuildKit mode
- Outputs []ImageBuildOutput
-}
-
-// ImageBuildOutput defines configuration for exporting a build result
-type ImageBuildOutput struct {
- Type string
- Attrs map[string]string
-}
-
-// ImageBuildResponse holds information
-// returned by a server after building
-// an image.
-type ImageBuildResponse struct {
- Body io.ReadCloser
- OSType string
-}
diff --git a/client/client_interfaces.go b/client/client_interfaces.go
index f75f8f7..448ecd9 100644
--- a/client/client_interfaces.go
+++ b/client/client_interfaces.go
@@ -106,7 +106,7 @@
// ImageAPIClient defines API client methods for the images
type ImageAPIClient interface {
- ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error)
+ ImageBuild(ctx context.Context, context io.Reader, options ImageBuildOptions) (ImageBuildResponse, error)
BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (*build.CachePruneReport, error)
BuildCancel(ctx context.Context, id string) error
ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)
diff --git a/client/image_build.go b/client/image_build.go
index 94ec6c3..5c1634d 100644
--- a/client/image_build.go
+++ b/client/image_build.go
@@ -10,7 +10,6 @@
"strconv"
"strings"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/network"
)
@@ -18,15 +17,15 @@
// ImageBuild sends a request to the daemon to build images.
// The Body in the response implements an [io.ReadCloser] and it's up to the caller to
// close it.
-func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) {
+func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResponse, error) {
query, err := cli.imageBuildOptionsToQuery(ctx, options)
if err != nil {
- return build.ImageBuildResponse{}, err
+ return ImageBuildResponse{}, err
}
buf, err := json.Marshal(options.AuthConfigs)
if err != nil {
- return build.ImageBuildResponse{}, err
+ return ImageBuildResponse{}, err
}
headers := http.Header{}
@@ -35,16 +34,16 @@
resp, err := cli.postRaw(ctx, "/build", query, buildContext, headers)
if err != nil {
- return build.ImageBuildResponse{}, err
+ return ImageBuildResponse{}, err
}
- return build.ImageBuildResponse{
+ return ImageBuildResponse{
Body: resp.Body,
OSType: resp.Header.Get("Ostype"),
}, nil
}
-func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options build.ImageBuildOptions) (url.Values, error) {
+func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options ImageBuildOptions) (url.Values, error) {
query := url.Values{}
if len(options.Tags) > 0 {
query["t"] = options.Tags
diff --git a/client/image_build_opts.go b/client/image_build_opts.go
new file mode 100644
index 0000000..df51db0
--- /dev/null
+++ b/client/image_build_opts.go
@@ -0,0 +1,77 @@
+package client
+
+import (
+ "io"
+
+ "github.com/moby/moby/api/types/build"
+ "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/registry"
+)
+
+// ImageBuildOptions holds the information
+// necessary to build images.
+type ImageBuildOptions struct {
+ Tags []string
+ SuppressOutput bool
+ RemoteContext string
+ NoCache bool
+ Remove bool
+ ForceRemove bool
+ PullParent bool
+ Isolation container.Isolation
+ CPUSetCPUs string
+ CPUSetMems string
+ CPUShares int64
+ CPUQuota int64
+ CPUPeriod int64
+ Memory int64
+ MemorySwap int64
+ CgroupParent string
+ NetworkMode string
+ ShmSize int64
+ Dockerfile string
+ Ulimits []*container.Ulimit
+ // BuildArgs needs to be a *string instead of just a string so that
+ // we can tell the difference between "" (empty string) and no value
+ // at all (nil). See the parsing of buildArgs in
+ // api/server/router/build/build_routes.go for even more info.
+ BuildArgs map[string]*string
+ AuthConfigs map[string]registry.AuthConfig
+ Context io.Reader
+ Labels map[string]string
+ // squash the resulting image's layers to the parent
+ // preserves the original image and creates a new one from the parent with all
+ // the changes applied to a single layer
+ Squash bool
+ // CacheFrom specifies images that are used for matching cache. Images
+ // specified here do not need to have a valid parent chain to match cache.
+ CacheFrom []string
+ SecurityOpt []string
+ ExtraHosts []string // List of extra hosts
+ Target string
+ SessionID string
+ Platform string
+ // Version specifies the version of the underlying builder to use
+ Version build.BuilderVersion
+ // BuildID is an optional identifier that can be passed together with the
+ // build request. The same identifier can be used to gracefully cancel the
+ // build with the cancel request.
+ BuildID string
+ // Outputs defines configurations for exporting build results. Only supported
+ // in BuildKit mode
+ Outputs []ImageBuildOutput
+}
+
+// ImageBuildOutput defines configuration for exporting a build result
+type ImageBuildOutput struct {
+ Type string
+ Attrs map[string]string
+}
+
+// ImageBuildResponse holds information
+// returned by a server after building
+// an image.
+type ImageBuildResponse struct {
+ Body io.ReadCloser
+ OSType string
+}
diff --git a/client/image_build_test.go b/client/image_build_test.go
index 235cc8a..481ac13 100644
--- a/client/image_build_test.go
+++ b/client/image_build_test.go
@@ -11,7 +11,6 @@
"testing"
cerrdefs "github.com/containerd/errdefs"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/registry"
"gotest.tools/v3/assert"
@@ -21,7 +20,7 @@
func TestImageBuildError(t *testing.T) {
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
assert.NilError(t, err)
- _, err = client.ImageBuild(context.Background(), nil, build.ImageBuildOptions{})
+ _, err = client.ImageBuild(context.Background(), nil, ImageBuildOptions{})
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
}
@@ -30,13 +29,13 @@
v2 := "value2"
emptyRegistryConfig := "bnVsbA=="
buildCases := []struct {
- buildOptions build.ImageBuildOptions
+ buildOptions ImageBuildOptions
expectedQueryParams map[string]string
expectedTags []string
expectedRegistryConfig string
}{
{
- buildOptions: build.ImageBuildOptions{
+ buildOptions: ImageBuildOptions{
SuppressOutput: true,
NoCache: true,
Remove: true,
@@ -53,7 +52,7 @@
expectedRegistryConfig: emptyRegistryConfig,
},
{
- buildOptions: build.ImageBuildOptions{
+ buildOptions: ImageBuildOptions{
SuppressOutput: false,
NoCache: false,
Remove: false,
@@ -71,7 +70,7 @@
expectedRegistryConfig: emptyRegistryConfig,
},
{
- buildOptions: build.ImageBuildOptions{
+ buildOptions: ImageBuildOptions{
RemoteContext: "remoteContext",
Isolation: container.Isolation("isolation"),
CPUSetCPUs: "2",
@@ -104,7 +103,7 @@
expectedRegistryConfig: emptyRegistryConfig,
},
{
- buildOptions: build.ImageBuildOptions{
+ buildOptions: ImageBuildOptions{
BuildArgs: map[string]*string{
"ARG1": &v1,
"ARG2": &v2,
@@ -119,7 +118,7 @@
expectedRegistryConfig: emptyRegistryConfig,
},
{
- buildOptions: build.ImageBuildOptions{
+ buildOptions: ImageBuildOptions{
Ulimits: []*container.Ulimit{
{
Name: "nproc",
@@ -141,7 +140,7 @@
expectedRegistryConfig: emptyRegistryConfig,
},
{
- buildOptions: build.ImageBuildOptions{
+ buildOptions: ImageBuildOptions{
AuthConfigs: map[string]registry.AuthConfig{
"https://index.docker.io/v1/": {
Auth: "dG90bwo=",
diff --git a/daemon/builder/backend/backend.go b/daemon/builder/backend/backend.go
index f975f30..a23d148 100644
--- a/daemon/builder/backend/backend.go
+++ b/daemon/builder/backend/backend.go
@@ -13,7 +13,6 @@
buildkit "github.com/moby/moby/v2/daemon/internal/builder-next"
"github.com/moby/moby/v2/daemon/internal/image"
"github.com/moby/moby/v2/daemon/internal/stringid"
- "github.com/moby/moby/v2/daemon/server/backend"
"github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/pkg/errors"
"google.golang.org/grpc"
@@ -27,7 +26,7 @@
// Builder defines interface for running a build
type Builder interface {
- Build(context.Context, backend.BuildConfig) (*builder.Result, error)
+ Build(context.Context, buildbackend.BuildConfig) (*builder.Result, error)
}
// Backend provides build functionality to the API router
@@ -51,7 +50,7 @@
}
// Build builds an image from a Source
-func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string, error) {
+func (b *Backend) Build(ctx context.Context, config buildbackend.BuildConfig) (string, error) {
options := config.Options
useBuildKit := options.Version == build.BuilderBuildKit
diff --git a/daemon/builder/builder.go b/daemon/builder/builder.go
index fdeb352..ba42e43 100644
--- a/daemon/builder/builder.go
+++ b/daemon/builder/builder.go
@@ -13,6 +13,7 @@
"github.com/moby/moby/v2/daemon/internal/image"
"github.com/moby/moby/v2/daemon/internal/layer"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
@@ -52,7 +53,7 @@
// ImageBackend are the interface methods required from an image component
type ImageBackend interface {
- GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (Image, ROLayer, error)
+ GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts buildbackend.GetImageAndLayerOptions) (Image, ROLayer, error)
}
// ExecBackend contains the interface methods required for executing containers
diff --git a/daemon/builder/dockerfile/builder.go b/daemon/builder/dockerfile/builder.go
index 3cc4a8c..4b90b56 100644
--- a/daemon/builder/dockerfile/builder.go
+++ b/daemon/builder/dockerfile/builder.go
@@ -18,7 +18,7 @@
"github.com/moby/moby/v2/daemon/builder"
"github.com/moby/moby/v2/daemon/builder/remotecontext"
"github.com/moby/moby/v2/daemon/internal/stringid"
- "github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/moby/v2/errdefs"
"github.com/moby/sys/user"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -62,7 +62,7 @@
}
// Build starts a new build from a BuildConfig
-func (bm *BuildManager) Build(ctx context.Context, config backend.BuildConfig) (*builder.Result, error) {
+func (bm *BuildManager) Build(ctx context.Context, config buildbackend.BuildConfig) (*builder.Result, error) {
buildsTriggered.Inc()
if config.Options.Dockerfile == "" {
config.Options.Dockerfile = builder.DefaultDockerfileName
@@ -98,9 +98,9 @@
// builderOptions are the dependencies required by the builder
type builderOptions struct {
- Options *build.ImageBuildOptions
+ Options *buildbackend.BuildOptions
Backend builder.Backend
- ProgressWriter backend.ProgressWriter
+ ProgressWriter buildbackend.ProgressWriter
PathCache pathCache
IDMapping user.IdentityMapping
}
@@ -108,11 +108,11 @@
// Builder is a Dockerfile builder
// It implements the builder.Backend interface.
type Builder struct {
- options *build.ImageBuildOptions
+ options *buildbackend.BuildOptions
Stdout io.Writer
Stderr io.Writer
- Aux backend.AuxEmitter
+ Aux buildbackend.AuxEmitter
Output io.Writer
docker builder.Backend
@@ -130,7 +130,7 @@
func newBuilder(ctx context.Context, options builderOptions) (*Builder, error) {
config := options.Options
if config == nil {
- config = new(build.ImageBuildOptions)
+ config = &buildbackend.BuildOptions{}
}
imgProber, err := newImageProber(ctx, options.Backend, config.CacheFrom, config.NoCache)
@@ -217,7 +217,7 @@
return &builder.Result{ImageID: state.imageID, FromImage: state.baseImage}, nil
}
-func emitImageID(aux backend.AuxEmitter, state *dispatchState) error {
+func emitImageID(aux buildbackend.AuxEmitter, state *dispatchState) error {
if aux == nil || state.imageID == "" {
return nil
}
@@ -343,7 +343,7 @@
}
b, err := newBuilder(ctx, builderOptions{
- Options: &build.ImageBuildOptions{NoCache: true},
+ Options: &buildbackend.BuildOptions{NoCache: true},
})
if err != nil {
return nil, err
diff --git a/daemon/builder/dockerfile/dispatchers_test.go b/daemon/builder/dockerfile/dispatchers_test.go
index 1d4762b..da7e964 100644
--- a/daemon/builder/dockerfile/dispatchers_test.go
+++ b/daemon/builder/dockerfile/dispatchers_test.go
@@ -11,12 +11,12 @@
"github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/moby/buildkit/frontend/dockerfile/shell"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/v2/daemon/builder"
"github.com/moby/moby/v2/daemon/internal/image"
"github.com/moby/moby/v2/daemon/pkg/oci"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -24,19 +24,18 @@
func newBuilderWithMockBackend(t *testing.T) *Builder {
t.Helper()
mockBackend := &MockBackend{}
- opts := &build.ImageBuildOptions{}
ctx := context.Background()
imageProber, err := newImageProber(ctx, mockBackend, nil, false)
assert.NilError(t, err, "Could not create image prober")
b := &Builder{
- options: opts,
+ options: &buildbackend.BuildOptions{},
docker: mockBackend,
Stdout: new(bytes.Buffer),
disableCommit: true,
imageSources: newImageSources(builderOptions{
- Options: opts,
+ Options: &buildbackend.BuildOptions{},
Backend: mockBackend,
}),
imageProber: imageProber,
diff --git a/daemon/builder/dockerfile/imagecontext.go b/daemon/builder/dockerfile/imagecontext.go
index ae44878..1f08a27 100644
--- a/daemon/builder/dockerfile/imagecontext.go
+++ b/daemon/builder/dockerfile/imagecontext.go
@@ -8,7 +8,7 @@
"github.com/containerd/platforms"
"github.com/moby/moby/v2/daemon/builder"
dockerimage "github.com/moby/moby/v2/daemon/internal/image"
- "github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@@ -25,15 +25,15 @@
func newImageSources(options builderOptions) *imageSources {
getAndMount := func(ctx context.Context, idOrRef string, localOnly bool, platform *ocispec.Platform) (builder.Image, builder.ROLayer, error) {
- pullOption := backend.PullOptionNoPull
+ pullOption := buildbackend.PullOptionNoPull
if !localOnly {
if options.Options.PullParent {
- pullOption = backend.PullOptionForcePull
+ pullOption = buildbackend.PullOptionForcePull
} else {
- pullOption = backend.PullOptionPreferLocal
+ pullOption = buildbackend.PullOptionPreferLocal
}
}
- return options.Backend.GetImageAndReleasableLayer(ctx, idOrRef, backend.GetImageAndLayerOptions{
+ return options.Backend.GetImageAndReleasableLayer(ctx, idOrRef, buildbackend.GetImageAndLayerOptions{
PullOption: pullOption,
AuthConfig: options.Options.AuthConfigs,
Output: options.ProgressWriter.Output,
diff --git a/daemon/builder/dockerfile/internals.go b/daemon/builder/dockerfile/internals.go
index 9693576..d2d0626 100644
--- a/daemon/builder/dockerfile/internals.go
+++ b/daemon/builder/dockerfile/internals.go
@@ -16,7 +16,6 @@
"github.com/containerd/platforms"
"github.com/moby/go-archive"
"github.com/moby/go-archive/chrootarchive"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/v2/daemon/builder"
@@ -24,6 +23,7 @@
"github.com/moby/moby/v2/daemon/internal/stringid"
networkSettings "github.com/moby/moby/v2/daemon/network"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@@ -340,7 +340,7 @@
return ctr.ID, nil
}
-func hostConfigFromOptions(options *build.ImageBuildOptions) *container.HostConfig {
+func hostConfigFromOptions(options *buildbackend.BuildOptions) *container.HostConfig {
resources := container.Resources{
CgroupParent: options.CgroupParent,
CPUShares: options.CPUShares,
diff --git a/daemon/builder/dockerfile/internals_linux_test.go b/daemon/builder/dockerfile/internals_linux_test.go
index 07fba0c..0c8ec37 100644
--- a/daemon/builder/dockerfile/internals_linux_test.go
+++ b/daemon/builder/dockerfile/internals_linux_test.go
@@ -6,7 +6,7 @@
"path/filepath"
"testing"
- "github.com/moby/moby/api/types/build"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/sys/user"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@@ -58,7 +58,7 @@
expected identity
}{
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UIDNoMap",
chownStr: "1",
idMapping: unmapped,
@@ -66,7 +66,7 @@
expected: identity{UID: 1, GID: 1},
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UIDGIDNoMap",
chownStr: "0:1",
idMapping: unmapped,
@@ -74,7 +74,7 @@
expected: identity{UID: 0, GID: 1},
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UIDWithMap",
chownStr: "0",
idMapping: remapped,
@@ -82,7 +82,7 @@
expected: identity{UID: 100000, GID: 100000},
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UIDGIDWithMap",
chownStr: "1:33",
idMapping: remapped,
@@ -90,7 +90,7 @@
expected: identity{UID: 100001, GID: 100033},
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UserNoMap",
chownStr: "bin:5555",
idMapping: unmapped,
@@ -98,7 +98,7 @@
expected: identity{UID: 1, GID: 5555},
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "GroupWithMap",
chownStr: "0:unicorn",
idMapping: remapped,
@@ -106,7 +106,7 @@
expected: identity{UID: 100000, GID: 101002},
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UserOnlyWithMap",
chownStr: "unicorn",
idMapping: remapped,
@@ -131,7 +131,7 @@
descr string
}{
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "BadChownFlagFormat",
chownStr: "bob:1:555",
idMapping: unmapped,
@@ -139,7 +139,7 @@
descr: "invalid chown string format: bob:1:555",
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "UserNoExist",
chownStr: "bob",
idMapping: unmapped,
@@ -147,7 +147,7 @@
descr: "can't find uid for user bob: no such user: bob",
},
{
- builder: &Builder{options: &build.ImageBuildOptions{Platform: "linux"}},
+ builder: &Builder{options: &buildbackend.BuildOptions{Platform: "linux"}},
name: "GroupNoExist",
chownStr: "root:bob",
idMapping: unmapped,
diff --git a/daemon/builder/dockerfile/internals_test.go b/daemon/builder/dockerfile/internals_test.go
index 24c87de..b751613 100644
--- a/daemon/builder/dockerfile/internals_test.go
+++ b/daemon/builder/dockerfile/internals_test.go
@@ -8,13 +8,12 @@
"testing"
"github.com/moby/go-archive"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/v2/daemon/builder"
"github.com/moby/moby/v2/daemon/builder/remotecontext"
"github.com/moby/moby/v2/daemon/internal/image"
"github.com/moby/moby/v2/daemon/internal/layer"
- "github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/opencontainers/go-digest"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@@ -75,8 +74,8 @@
dockerfilePath = builder.DefaultDockerfileName
}
- config := backend.BuildConfig{
- Options: &build.ImageBuildOptions{Dockerfile: dockerfilePath},
+ config := buildbackend.BuildConfig{
+ Options: &buildbackend.BuildOptions{Dockerfile: dockerfilePath},
Source: tarStream,
}
_, _, err = remotecontext.Detect(config)
diff --git a/daemon/builder/dockerfile/mockbackend_test.go b/daemon/builder/dockerfile/mockbackend_test.go
index d44d1a0..5f42b39 100644
--- a/daemon/builder/dockerfile/mockbackend_test.go
+++ b/daemon/builder/dockerfile/mockbackend_test.go
@@ -12,6 +12,7 @@
"github.com/moby/moby/v2/daemon/internal/image"
"github.com/moby/moby/v2/daemon/internal/layer"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
@@ -62,7 +63,7 @@
return nil
}
-func (m *MockBackend) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
+func (m *MockBackend) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts buildbackend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
if m.getImageFunc != nil {
return m.getImageFunc(refOrID)
}
diff --git a/daemon/builder/remotecontext/detect.go b/daemon/builder/remotecontext/detect.go
index ae81c80..8cc23b6 100644
--- a/daemon/builder/remotecontext/detect.go
+++ b/daemon/builder/remotecontext/detect.go
@@ -15,7 +15,7 @@
"github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/moby/moby/v2/daemon/builder"
"github.com/moby/moby/v2/daemon/builder/remotecontext/urlutil"
- "github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/moby/v2/errdefs"
"github.com/moby/patternmatcher"
"github.com/moby/patternmatcher/ignorefile"
@@ -28,7 +28,7 @@
// Detect returns a context and dockerfile from remote location or local
// archive.
-func Detect(config backend.BuildConfig) (remote builder.Source, dockerfile *parser.Result, _ error) {
+func Detect(config buildbackend.BuildConfig) (remote builder.Source, dockerfile *parser.Result, _ error) {
remoteURL := config.Options.RemoteContext
switch {
case remoteURL == "":
diff --git a/daemon/containerd/image_builder.go b/daemon/containerd/image_builder.go
index df3696e..8d2b4eb 100644
--- a/daemon/containerd/image_builder.go
+++ b/daemon/containerd/image_builder.go
@@ -33,6 +33,7 @@
"github.com/moby/moby/v2/daemon/internal/layer"
"github.com/moby/moby/v2/daemon/internal/stringid"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/moby/v2/errdefs"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/identity"
@@ -64,7 +65,7 @@
// GetImageAndReleasableLayer returns an image and releaseable layer for a
// reference or ID. Every call to GetImageAndReleasableLayer MUST call
// releasableLayer.Release() to prevent leaking of layers.
-func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
+func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts buildbackend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
if refOrID == "" { // FROM scratch
if runtime.GOOS == "windows" {
return nil, nil, errors.New(`"FROM scratch" is not supported on Windows`)
@@ -80,10 +81,10 @@
}, nil
}
- if opts.PullOption != backend.PullOptionForcePull {
+ if opts.PullOption != buildbackend.PullOptionForcePull {
// TODO(laurazard): same as below
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{Platform: opts.Platform})
- if err != nil && opts.PullOption == backend.PullOptionNoPull {
+ if err != nil && opts.PullOption == buildbackend.PullOptionNoPull {
return nil, nil, err
}
imgDesc, err := i.resolveDescriptor(ctx, refOrID)
diff --git a/daemon/image_service.go b/daemon/image_service.go
index 4683035..b4a4365 100644
--- a/daemon/image_service.go
+++ b/daemon/image_service.go
@@ -16,6 +16,7 @@
"github.com/moby/moby/v2/daemon/internal/image"
"github.com/moby/moby/v2/daemon/internal/layer"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/moby/v2/daemon/server/imagebackend"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -48,7 +49,7 @@
// Layers
- GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error)
+ GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts buildbackend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error)
CreateLayer(container *container.Container, initFunc layer.MountInit) (container.RWLayer, error)
CreateLayerFromImage(img *image.Image, layerName string, rwLayerOpts *layer.CreateRWLayerOpts) (container.RWLayer, error)
GetLayerByID(cid string) (container.RWLayer, error)
diff --git a/daemon/images/image_builder.go b/daemon/images/image_builder.go
index 5f209ce..bcf8e65 100644
--- a/daemon/images/image_builder.go
+++ b/daemon/images/image_builder.go
@@ -17,6 +17,7 @@
"github.com/moby/moby/v2/daemon/internal/layer"
"github.com/moby/moby/v2/daemon/internal/stringid"
"github.com/moby/moby/v2/daemon/server/backend"
+ "github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
@@ -195,7 +196,7 @@
// GetImageAndReleasableLayer returns an image and releaseable layer for a reference or ID.
// Every call to GetImageAndReleasableLayer MUST call releasableLayer.Release() to prevent
// leaking of layers.
-func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
+func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts buildbackend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
if refOrID == "" { // FROM scratch
if runtime.GOOS == "windows" {
return nil, nil, errors.New(`"FROM scratch" is not supported on Windows`)
@@ -209,9 +210,9 @@
return nil, lyr, err
}
- if opts.PullOption != backend.PullOptionForcePull {
+ if opts.PullOption != buildbackend.PullOptionForcePull {
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{Platform: opts.Platform})
- if err != nil && opts.PullOption == backend.PullOptionNoPull {
+ if err != nil && opts.PullOption == buildbackend.PullOptionNoPull {
return nil, nil, err
}
if err != nil && !cerrdefs.IsNotFound(err) {
diff --git a/daemon/internal/builder-next/builder.go b/daemon/internal/builder-next/builder.go
index 5838f62..81e7c01 100644
--- a/daemon/internal/builder-next/builder.go
+++ b/daemon/internal/builder-next/builder.go
@@ -32,7 +32,6 @@
"github.com/moby/moby/v2/daemon/internal/timestamp"
"github.com/moby/moby/v2/daemon/libnetwork"
"github.com/moby/moby/v2/daemon/pkg/opts"
- "github.com/moby/moby/v2/daemon/server/backend"
"github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/moby/v2/errdefs"
"github.com/moby/sys/user"
@@ -243,7 +242,7 @@
}
// Build executes a build request
-func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
+func (b *Builder) Build(ctx context.Context, opt buildbackend.BuildConfig) (*builder.Result, error) {
if len(opt.Options.Outputs) > 1 {
return nil, errors.Errorf("multiple outputs not supported")
}
diff --git a/daemon/server/backend/build.go b/daemon/server/backend/build.go
deleted file mode 100644
index ba5f247..0000000
--- a/daemon/server/backend/build.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package backend
-
-import (
- "io"
-
- "github.com/moby/moby/api/types/build"
- "github.com/moby/moby/api/types/registry"
- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
-)
-
-// PullOption defines different modes for accessing images
-type PullOption int
-
-const (
- // PullOptionNoPull only returns local images
- PullOptionNoPull PullOption = iota
- // PullOptionForcePull always tries to pull a ref from the registry first
- PullOptionForcePull
- // PullOptionPreferLocal uses local image if it exists, otherwise pulls
- PullOptionPreferLocal
-)
-
-// ProgressWriter is a data object to transport progress streams to the client
-type ProgressWriter struct {
- Output io.Writer
- StdoutFormatter io.Writer
- StderrFormatter io.Writer
- AuxFormatter AuxEmitter
- ProgressReaderFunc func(io.ReadCloser) io.ReadCloser
-}
-
-// AuxEmitter is an interface for emitting aux messages during build progress
-type AuxEmitter interface {
- Emit(string, any) error
-}
-
-// BuildConfig is the configuration used by a BuildManager to start a build
-type BuildConfig struct {
- Source io.ReadCloser
- ProgressWriter ProgressWriter
- Options *build.ImageBuildOptions
-}
-
-// GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer
-type GetImageAndLayerOptions struct {
- PullOption PullOption
- AuthConfig map[string]registry.AuthConfig
- Output io.Writer
- Platform *ocispec.Platform
-}
diff --git a/daemon/server/buildbackend/build.go b/daemon/server/buildbackend/build.go
index bcab277..798894b 100644
--- a/daemon/server/buildbackend/build.go
+++ b/daemon/server/buildbackend/build.go
@@ -1,6 +1,15 @@
package buildbackend
-import "github.com/moby/moby/api/types/filters"
+import (
+ "io"
+
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+
+ "github.com/moby/moby/api/types/build"
+ "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/filters"
+ "github.com/moby/moby/api/types/registry"
+)
type CachePruneOptions struct {
All bool
@@ -9,3 +18,104 @@
MinFreeSpace int64
Filters filters.Args
}
+
+// PullOption defines different modes for accessing images
+type PullOption int
+
+const (
+ // PullOptionNoPull only returns local images
+ PullOptionNoPull PullOption = iota
+ // PullOptionForcePull always tries to pull a ref from the registry first
+ PullOptionForcePull
+ // PullOptionPreferLocal uses local image if it exists, otherwise pulls
+ PullOptionPreferLocal
+)
+
+// ProgressWriter is a data object to transport progress streams to the client
+type ProgressWriter struct {
+ Output io.Writer
+ StdoutFormatter io.Writer
+ StderrFormatter io.Writer
+ AuxFormatter AuxEmitter
+ ProgressReaderFunc func(io.ReadCloser) io.ReadCloser
+}
+
+// AuxEmitter is an interface for emitting aux messages during build progress
+type AuxEmitter interface {
+ Emit(string, any) error
+}
+
+// BuildConfig is the configuration used by a BuildManager to start a build
+type BuildConfig struct {
+ Source io.ReadCloser
+ ProgressWriter ProgressWriter
+ Options *BuildOptions
+}
+
+// BuildOptions holds the information
+// necessary to build images.
+type BuildOptions struct {
+ Tags []string
+ SuppressOutput bool
+ RemoteContext string
+ NoCache bool
+ Remove bool
+ ForceRemove bool
+ PullParent bool
+ Isolation container.Isolation
+ CPUSetCPUs string
+ CPUSetMems string
+ CPUShares int64
+ CPUQuota int64
+ CPUPeriod int64
+ Memory int64
+ MemorySwap int64
+ CgroupParent string
+ NetworkMode string
+ ShmSize int64
+ Dockerfile string
+ Ulimits []*container.Ulimit
+ // BuildArgs needs to be a *string instead of just a string so that
+ // we can tell the difference between "" (empty string) and no value
+ // at all (nil). See the parsing of buildArgs in
+ // api/server/router/build/build_routes.go for even more info.
+ BuildArgs map[string]*string
+ AuthConfigs map[string]registry.AuthConfig
+ Context io.Reader
+ Labels map[string]string
+ // squash the resulting image's layers to the parent
+ // preserves the original image and creates a new one from the parent with all
+ // the changes applied to a single layer
+ Squash bool
+ // CacheFrom specifies images that are used for matching cache. Images
+ // specified here do not need to have a valid parent chain to match cache.
+ CacheFrom []string
+ SecurityOpt []string
+ ExtraHosts []string // List of extra hosts
+ Target string
+ SessionID string
+ Platform string
+ // Version specifies the version of the underlying builder to use
+ Version build.BuilderVersion
+ // BuildID is an optional identifier that can be passed together with the
+ // build request. The same identifier can be used to gracefully cancel the
+ // build with the cancel request.
+ BuildID string
+ // Outputs defines configurations for exporting build results. Only supported
+ // in BuildKit mode
+ Outputs []BuildOutput
+}
+
+// BuildOutput defines configuration for exporting a build result
+type BuildOutput struct {
+ Type string
+ Attrs map[string]string
+}
+
+// GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer
+type GetImageAndLayerOptions struct {
+ PullOption PullOption
+ AuthConfig map[string]registry.AuthConfig
+ Output io.Writer
+ Platform *ocispec.Platform
+}
diff --git a/daemon/server/router/build/backend.go b/daemon/server/router/build/backend.go
index ee45a13..6841cb4 100644
--- a/daemon/server/router/build/backend.go
+++ b/daemon/server/router/build/backend.go
@@ -4,7 +4,6 @@
"context"
"github.com/moby/moby/api/types/build"
- "github.com/moby/moby/v2/daemon/server/backend"
"github.com/moby/moby/v2/daemon/server/buildbackend"
)
@@ -12,7 +11,7 @@
type Backend interface {
// Build a Docker image returning the id of the image
// TODO: make this return a reference instead of string
- Build(context.Context, backend.BuildConfig) (string, error)
+ Build(context.Context, buildbackend.BuildConfig) (string, error)
// PruneCache prunes the build cache.
PruneCache(context.Context, buildbackend.CachePruneOptions) (*build.CachePruneReport, error)
diff --git a/daemon/server/router/build/build_routes.go b/daemon/server/router/build/build_routes.go
index 06d8305..a90074b 100644
--- a/daemon/server/router/build/build_routes.go
+++ b/daemon/server/router/build/build_routes.go
@@ -23,7 +23,6 @@
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/api/types/registry"
"github.com/moby/moby/api/types/versions"
- "github.com/moby/moby/v2/daemon/server/backend"
"github.com/moby/moby/v2/daemon/server/buildbackend"
"github.com/moby/moby/v2/daemon/server/httputils"
"github.com/moby/moby/v2/pkg/ioutils"
@@ -36,8 +35,8 @@
func (e invalidParam) InvalidParameter() {}
-func newImageBuildOptions(ctx context.Context, r *http.Request) (*build.ImageBuildOptions, error) {
- options := &build.ImageBuildOptions{
+func newImageBuildOptions(ctx context.Context, r *http.Request) (*buildbackend.BuildOptions, error) {
+ options := &buildbackend.BuildOptions{
Version: build.BuilderV1, // Builder V1 is the default, but can be overridden
Dockerfile: r.FormValue("dockerfile"),
SuppressOutput: httputils.BoolValue(r, "q"),
@@ -82,7 +81,7 @@
if versions.GreaterThanOrEqualTo(version, "1.40") {
outputsJSON := r.FormValue("outputs")
if outputsJSON != "" {
- var outputs []build.ImageBuildOutput
+ var outputs []buildbackend.BuildOutput
if err := json.Unmarshal([]byte(outputsJSON), &outputs); err != nil {
return nil, invalidParam{errors.Wrap(err, "invalid outputs specified")}
}
@@ -314,7 +313,7 @@
wantAux := versions.GreaterThanOrEqualTo(version, "1.30")
- imgID, err := br.backend.Build(ctx, backend.BuildConfig{
+ imgID, err := br.backend.Build(ctx, buildbackend.BuildConfig{
Source: body,
Options: buildOptions,
ProgressWriter: buildProgressWriter(out, wantAux, createProgressReader),
@@ -360,7 +359,7 @@
return s.w.Write(b)
}
-func buildProgressWriter(out io.Writer, wantAux bool, createProgressReader func(io.ReadCloser) io.ReadCloser) backend.ProgressWriter {
+func buildProgressWriter(out io.Writer, wantAux bool, createProgressReader func(io.ReadCloser) io.ReadCloser) buildbackend.ProgressWriter {
// see https://github.com/moby/moby/pull/21406
out = &syncWriter{w: out}
@@ -369,7 +368,7 @@
aux = &streamformatter.AuxFormatter{Writer: out}
}
- return backend.ProgressWriter{
+ return buildbackend.ProgressWriter{
Output: out,
StdoutFormatter: streamformatter.NewStdoutWriter(out),
StderrFormatter: streamformatter.NewStderrWriter(out),
diff --git a/integration/build/build_cgroupns_linux_test.go b/integration/build/build_cgroupns_linux_test.go
index 1923628..f4bf3cb 100644
--- a/integration/build/build_cgroupns_linux_test.go
+++ b/integration/build/build_cgroupns_linux_test.go
@@ -7,7 +7,7 @@
"strings"
"testing"
- "github.com/moby/moby/api/types/build"
+ "github.com/moby/moby/client"
"github.com/moby/moby/client/pkg/jsonmessage"
"github.com/moby/moby/v2/integration/internal/requirement"
"github.com/moby/moby/v2/testutil"
@@ -51,14 +51,12 @@
source := fakecontext.New(t, "", fakecontext.WithDockerfile(dockerfile))
defer source.Close()
- client := d.NewClientT(t)
- resp, err := client.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- Tags: []string{"buildcgroupns"},
- })
+ apiClient := d.NewClientT(t)
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ Tags: []string{"buildcgroupns"},
+ })
assert.NilError(t, err)
defer resp.Body.Close()
diff --git a/integration/build/build_squash_test.go b/integration/build/build_squash_test.go
index d9e4629..3c1c4b8 100644
--- a/integration/build/build_squash_test.go
+++ b/integration/build/build_squash_test.go
@@ -7,7 +7,6 @@
"testing"
"github.com/moby/moby/api/pkg/stdcopy"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/client"
"github.com/moby/moby/v2/integration/internal/container"
"github.com/moby/moby/v2/testutil"
@@ -51,13 +50,11 @@
defer source.Close()
name := strings.ToLower(t.Name())
- resp, err := apiClient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- Tags: []string{name},
- })
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ Tags: []string{name},
+ })
assert.NilError(t, err)
_, err = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
@@ -70,7 +67,7 @@
// build with squash
resp, err = apiClient.ImageBuild(ctx,
source.AsTarReader(t),
- build.ImageBuildOptions{
+ client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
Squash: true,
diff --git a/integration/build/build_test.go b/integration/build/build_test.go
index 4c3648b..9f2ae88 100644
--- a/integration/build/build_test.go
+++ b/integration/build/build_test.go
@@ -110,7 +110,7 @@
_, err := tw.Write(dockerfile)
assert.NilError(t, err)
assert.NilError(t, tw.Close())
- resp, err := apiClient.ImageBuild(ctx, buff, build.ImageBuildOptions{Remove: tc.rm, ForceRemove: tc.forceRm, NoCache: true})
+ resp, err := apiClient.ImageBuild(ctx, buff, client.ImageBuildOptions{Remove: tc.rm, ForceRemove: tc.forceRm, NoCache: true})
assert.NilError(t, err)
defer resp.Body.Close()
filter, err := buildContainerIdsFilter(resp.Body)
@@ -163,16 +163,12 @@
t.Run(target, func(t *testing.T) {
imgName := strings.ToLower(t.Name())
- resp, err := apiclient.ImageBuild(
- ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- Target: target,
- Tags: []string{imgName},
- },
- )
+ resp, err := apiclient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ Target: target,
+ Tags: []string{imgName},
+ })
assert.NilError(t, err)
out := bytes.NewBuffer(nil)
@@ -213,13 +209,11 @@
apiclient := testEnv.APIClient()
imgName := strings.ToLower(t.Name())
- resp, err := apiclient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- Tags: []string{imgName},
- })
+ resp, err := apiclient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ Tags: []string{imgName},
+ })
assert.NilError(t, err)
_, err = io.Copy(io.Discard, resp.Body)
assert.Check(t, resp.Body.Close())
@@ -260,15 +254,13 @@
apiclient := testEnv.APIClient()
// For `target-a` build
- resp, err := apiclient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- Tags: []string{imgName},
- Labels: testLabels,
- Target: "target-a",
- })
+ resp, err := apiclient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ Tags: []string{imgName},
+ Labels: testLabels,
+ Target: "target-a",
+ })
assert.NilError(t, err)
_, err = io.Copy(io.Discard, resp.Body)
assert.Check(t, resp.Body.Close())
@@ -289,7 +281,7 @@
delete(testLabels, "label-a")
resp, err = apiclient.ImageBuild(ctx,
source.AsTarReader(t),
- build.ImageBuildOptions{
+ client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
Tags: []string{imgName},
@@ -328,12 +320,10 @@
defer source.Close()
apiclient := testEnv.APIClient()
- resp, err := apiclient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- })
+ resp, err := apiclient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ })
assert.NilError(t, err)
_, err = io.Copy(io.Discard, resp.Body)
assert.Check(t, resp.Body.Close())
@@ -364,12 +354,10 @@
defer source.Close()
apiclient := testEnv.APIClient()
- resp, err := apiclient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- })
+ resp, err := apiclient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ })
out := bytes.NewBuffer(nil)
assert.NilError(t, err)
@@ -410,12 +398,10 @@
assert.NilError(t, err)
apiclient := testEnv.APIClient()
- resp, err := apiclient.ImageBuild(ctx,
- buf,
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- })
+ resp, err := apiclient.ImageBuild(ctx, buf, client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ })
out := bytes.NewBuffer(nil)
assert.NilError(t, err)
@@ -435,7 +421,7 @@
resp, err = apiclient.ImageBuild(ctx,
buf,
- build.ImageBuildOptions{
+ client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
})
@@ -472,12 +458,10 @@
defer source.Close()
apiClient := testEnv.APIClient()
- resp, err := apiClient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- })
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ })
out := bytes.NewBuffer(nil)
assert.NilError(t, err)
@@ -518,12 +502,10 @@
assert.NilError(t, err)
apiClient := testEnv.APIClient()
- resp, err := apiClient.ImageBuild(ctx,
- buf,
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- })
+ resp, err := apiClient.ImageBuild(ctx, buf, client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ })
out := bytes.NewBuffer(nil)
assert.NilError(t, err)
@@ -559,12 +541,10 @@
assert.NilError(t, err)
apiClient := testEnv.APIClient()
- resp, err := apiClient.ImageBuild(ctx,
- buf,
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- })
+ resp, err := apiClient.ImageBuild(ctx, buf, client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ })
out := bytes.NewBuffer(nil)
assert.NilError(t, err)
@@ -626,7 +606,7 @@
_, err = apiClient.ImageBuild(ctx,
buf,
- build.ImageBuildOptions{
+ client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
})
@@ -653,15 +633,11 @@
t.Run(target, func(t *testing.T) {
ctx := testutil.StartSpan(ctx, t)
- resp, err := apiClient.ImageBuild(
- ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: true,
- ForceRemove: true,
- Target: target,
- },
- )
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: true,
+ ForceRemove: true,
+ Target: target,
+ })
assert.NilError(t, err)
out := bytes.NewBuffer(nil)
@@ -684,7 +660,7 @@
err := w.Close()
assert.NilError(t, err)
- _, err = testEnv.APIClient().ImageBuild(ctx, buf, build.ImageBuildOptions{
+ _, err = testEnv.APIClient().ImageBuild(ctx, buf, client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
Platform: "foobar",
@@ -713,7 +689,7 @@
apiClient := testEnv.APIClient()
buildAndGetID := func() string {
- resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), build.ImageBuildOptions{
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
Version: build.BuilderV1,
})
assert.NilError(t, err)
@@ -752,7 +728,7 @@
since := time.Now()
- resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), build.ImageBuildOptions{
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
Version: builderVersion,
NoCache: true,
})
@@ -807,7 +783,7 @@
apiClient := testEnv.APIClient()
buildImage := func(imgName string) error {
- resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), build.ImageBuildOptions{
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
Tags: []string{imgName},
diff --git a/integration/build/build_userns_linux_test.go b/integration/build/build_userns_linux_test.go
index 6b574f0..9437f72 100644
--- a/integration/build/build_userns_linux_test.go
+++ b/integration/build/build_userns_linux_test.go
@@ -10,7 +10,6 @@
"testing"
"github.com/moby/moby/api/pkg/stdcopy"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/client"
"github.com/moby/moby/client/pkg/jsonmessage"
"github.com/moby/moby/v2/integration/internal/container"
@@ -64,11 +63,9 @@
source := fakecontext.New(t, "", fakecontext.WithDockerfile(dockerfile))
defer source.Close()
- resp, err := clientUserRemap.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Tags: []string{imageTag},
- })
+ resp, err := clientUserRemap.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Tags: []string{imageTag},
+ })
assert.NilError(t, err)
defer resp.Body.Close()
diff --git a/integration/capabilities/capabilities_linux_test.go b/integration/capabilities/capabilities_linux_test.go
index 50c38fe..bd6f0c6 100644
--- a/integration/capabilities/capabilities_linux_test.go
+++ b/integration/capabilities/capabilities_linux_test.go
@@ -7,9 +7,8 @@
"testing"
"github.com/moby/moby/api/pkg/stdcopy"
- "github.com/moby/moby/api/types/build"
containertypes "github.com/moby/moby/api/types/container"
- client2 "github.com/moby/moby/client"
+ "github.com/moby/moby/client"
"github.com/moby/moby/v2/integration/internal/container"
"github.com/moby/moby/v2/testutil"
"github.com/moby/moby/v2/testutil/fakecontext"
@@ -32,14 +31,12 @@
source := fakecontext.New(t, "", fakecontext.WithDockerfile(withFileCapability))
defer source.Close()
- client := testEnv.APIClient()
+ apiClient := testEnv.APIClient()
// Build image
- resp, err := client.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Tags: []string{imageTag},
- })
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Tags: []string{imageTag},
+ })
assert.NilError(t, err)
_, err = io.Copy(io.Discard, resp.Body)
assert.NilError(t, err)
@@ -78,11 +75,11 @@
container.WithCmd("/bin/cat", "/txt"),
container.WithSecurityOpt("no-new-privileges=true"),
)
- cid := container.Run(ctx, t, client, opts...)
- poll.WaitOn(t, container.IsInState(ctx, client, cid, containertypes.StateExited))
+ cid := container.Run(ctx, t, apiClient, opts...)
+ poll.WaitOn(t, container.IsInState(ctx, apiClient, cid, containertypes.StateExited))
// Assert on outputs
- logReader, err := client.ContainerLogs(ctx, cid, client2.ContainerLogsOptions{
+ logReader, err := apiClient.ContainerLogs(ctx, cid, client.ContainerLogsOptions{
ShowStdout: true,
ShowStderr: true,
})
diff --git a/integration/container/copy_test.go b/integration/container/copy_test.go
index 6ddb9a7..8b344a3 100644
--- a/integration/container/copy_test.go
+++ b/integration/container/copy_test.go
@@ -213,7 +213,7 @@
`))
defer buildCtx.Close()
- resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), build.ImageBuildOptions{})
+ resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), client.ImageBuildOptions{})
assert.NilError(t, err)
defer resp.Body.Close()
@@ -287,7 +287,7 @@
`))
defer buildCtx.Close()
- resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), build.ImageBuildOptions{})
+ resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), client.ImageBuildOptions{})
assert.NilError(t, err)
defer resp.Body.Close()
diff --git a/integration/image/history_test.go b/integration/image/history_test.go
index 180c489..de2d2f6 100644
--- a/integration/image/history_test.go
+++ b/integration/image/history_test.go
@@ -68,7 +68,7 @@
defer buildCtx.Close()
// Build the image for a non-native platform
- resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), buildtypes.ImageBuildOptions{
+ resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), client.ImageBuildOptions{
Version: buildtypes.BuilderBuildKit,
Tags: []string{"cross-platform-test"},
Platform: platforms.FormatAll(nonNativePlatform),
diff --git a/integration/internal/build/build.go b/integration/internal/build/build.go
index 1f79ce0..40ae23b 100644
--- a/integration/internal/build/build.go
+++ b/integration/internal/build/build.go
@@ -18,7 +18,7 @@
// Do builds an image from the given context and returns the image ID.
func Do(ctx context.Context, t *testing.T, apiClient client.APIClient, buildCtx *fakecontext.Fake) string {
- resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), build.ImageBuildOptions{})
+ resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), client.ImageBuildOptions{})
if resp.Body != nil {
defer resp.Body.Close()
}
diff --git a/integration/volume/mount_test.go b/integration/volume/mount_test.go
index a220777..6e3b0f0 100644
--- a/integration/volume/mount_test.go
+++ b/integration/volume/mount_test.go
@@ -9,7 +9,6 @@
"strings"
"testing"
- "github.com/moby/moby/api/types/build"
containertypes "github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/mount"
"github.com/moby/moby/api/types/network"
@@ -320,13 +319,11 @@
)
defer source.Close()
- resp, err := apiClient.ImageBuild(ctx,
- source.AsTarReader(t),
- build.ImageBuildOptions{
- Remove: false,
- ForceRemove: false,
- Tags: []string{imgName},
- })
+ resp, err := apiClient.ImageBuild(ctx, source.AsTarReader(t), client.ImageBuildOptions{
+ Remove: false,
+ ForceRemove: false,
+ Tags: []string{imgName},
+ })
assert.NilError(t, err)
out := bytes.NewBuffer(nil)
diff --git a/testutil/fakestorage/fixtures.go b/testutil/fakestorage/fixtures.go
index ca0f2b3..9e55ea8 100644
--- a/testutil/fakestorage/fixtures.go
+++ b/testutil/fakestorage/fixtures.go
@@ -10,7 +10,7 @@
"testing"
"github.com/moby/go-archive"
- "github.com/moby/moby/api/types/build"
+ "github.com/moby/moby/client"
"gotest.tools/v3/assert"
)
@@ -76,7 +76,7 @@
assert.NilError(t, err)
apiClient := testEnv.APIClient()
- resp, err := apiClient.ImageBuild(context.Background(), reader, build.ImageBuildOptions{
+ resp, err := apiClient.ImageBuild(context.Background(), reader, client.ImageBuildOptions{
Remove: true,
ForceRemove: true,
Tags: []string{"httpserver"},
diff --git a/testutil/fakestorage/storage.go b/testutil/fakestorage/storage.go
index a716e8b..f8d5e3b 100644
--- a/testutil/fakestorage/storage.go
+++ b/testutil/fakestorage/storage.go
@@ -11,7 +11,6 @@
"strings"
"testing"
- "github.com/moby/moby/api/types/build"
containertypes "github.com/moby/moby/api/types/container"
"github.com/moby/moby/client"
"github.com/moby/moby/v2/testutil"
@@ -145,7 +144,7 @@
COPY . /static`); err != nil {
t.Fatal(err)
}
- resp, err := c.ImageBuild(context.Background(), ctx.AsTarReader(t), build.ImageBuildOptions{
+ resp, err := c.ImageBuild(context.Background(), ctx.AsTarReader(t), client.ImageBuildOptions{
NoCache: true,
Tags: []string{imgName},
})
diff --git a/vendor/github.com/moby/moby/api/types/build/build.go b/vendor/github.com/moby/moby/api/types/build/build.go
index a798802..db98397 100644
--- a/vendor/github.com/moby/moby/api/types/build/build.go
+++ b/vendor/github.com/moby/moby/api/types/build/build.go
@@ -1,12 +1,5 @@
package build
-import (
- "io"
-
- "github.com/moby/moby/api/types/container"
- "github.com/moby/moby/api/types/registry"
-)
-
// BuilderVersion sets the version of underlying builder to use
type BuilderVersion string
@@ -21,71 +14,3 @@
type Result struct {
ID string
}
-
-// ImageBuildOptions holds the information
-// necessary to build images.
-type ImageBuildOptions struct {
- Tags []string
- SuppressOutput bool
- RemoteContext string
- NoCache bool
- Remove bool
- ForceRemove bool
- PullParent bool
- Isolation container.Isolation
- CPUSetCPUs string
- CPUSetMems string
- CPUShares int64
- CPUQuota int64
- CPUPeriod int64
- Memory int64
- MemorySwap int64
- CgroupParent string
- NetworkMode string
- ShmSize int64
- Dockerfile string
- Ulimits []*container.Ulimit
- // BuildArgs needs to be a *string instead of just a string so that
- // we can tell the difference between "" (empty string) and no value
- // at all (nil). See the parsing of buildArgs in
- // api/server/router/build/build_routes.go for even more info.
- BuildArgs map[string]*string
- AuthConfigs map[string]registry.AuthConfig
- Context io.Reader
- Labels map[string]string
- // squash the resulting image's layers to the parent
- // preserves the original image and creates a new one from the parent with all
- // the changes applied to a single layer
- Squash bool
- // CacheFrom specifies images that are used for matching cache. Images
- // specified here do not need to have a valid parent chain to match cache.
- CacheFrom []string
- SecurityOpt []string
- ExtraHosts []string // List of extra hosts
- Target string
- SessionID string
- Platform string
- // Version specifies the version of the underlying builder to use
- Version BuilderVersion
- // BuildID is an optional identifier that can be passed together with the
- // build request. The same identifier can be used to gracefully cancel the
- // build with the cancel request.
- BuildID string
- // Outputs defines configurations for exporting build results. Only supported
- // in BuildKit mode
- Outputs []ImageBuildOutput
-}
-
-// ImageBuildOutput defines configuration for exporting a build result
-type ImageBuildOutput struct {
- Type string
- Attrs map[string]string
-}
-
-// ImageBuildResponse holds information
-// returned by a server after building
-// an image.
-type ImageBuildResponse struct {
- Body io.ReadCloser
- OSType string
-}
diff --git a/vendor/github.com/moby/moby/client/client_interfaces.go b/vendor/github.com/moby/moby/client/client_interfaces.go
index f75f8f7..448ecd9 100644
--- a/vendor/github.com/moby/moby/client/client_interfaces.go
+++ b/vendor/github.com/moby/moby/client/client_interfaces.go
@@ -106,7 +106,7 @@
// ImageAPIClient defines API client methods for the images
type ImageAPIClient interface {
- ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error)
+ ImageBuild(ctx context.Context, context io.Reader, options ImageBuildOptions) (ImageBuildResponse, error)
BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (*build.CachePruneReport, error)
BuildCancel(ctx context.Context, id string) error
ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)
diff --git a/vendor/github.com/moby/moby/client/image_build.go b/vendor/github.com/moby/moby/client/image_build.go
index 94ec6c3..5c1634d 100644
--- a/vendor/github.com/moby/moby/client/image_build.go
+++ b/vendor/github.com/moby/moby/client/image_build.go
@@ -10,7 +10,6 @@
"strconv"
"strings"
- "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/network"
)
@@ -18,15 +17,15 @@
// ImageBuild sends a request to the daemon to build images.
// The Body in the response implements an [io.ReadCloser] and it's up to the caller to
// close it.
-func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) {
+func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResponse, error) {
query, err := cli.imageBuildOptionsToQuery(ctx, options)
if err != nil {
- return build.ImageBuildResponse{}, err
+ return ImageBuildResponse{}, err
}
buf, err := json.Marshal(options.AuthConfigs)
if err != nil {
- return build.ImageBuildResponse{}, err
+ return ImageBuildResponse{}, err
}
headers := http.Header{}
@@ -35,16 +34,16 @@
resp, err := cli.postRaw(ctx, "/build", query, buildContext, headers)
if err != nil {
- return build.ImageBuildResponse{}, err
+ return ImageBuildResponse{}, err
}
- return build.ImageBuildResponse{
+ return ImageBuildResponse{
Body: resp.Body,
OSType: resp.Header.Get("Ostype"),
}, nil
}
-func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options build.ImageBuildOptions) (url.Values, error) {
+func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options ImageBuildOptions) (url.Values, error) {
query := url.Values{}
if len(options.Tags) > 0 {
query["t"] = options.Tags
diff --git a/vendor/github.com/moby/moby/client/image_build_opts.go b/vendor/github.com/moby/moby/client/image_build_opts.go
new file mode 100644
index 0000000..df51db0
--- /dev/null
+++ b/vendor/github.com/moby/moby/client/image_build_opts.go
@@ -0,0 +1,77 @@
+package client
+
+import (
+ "io"
+
+ "github.com/moby/moby/api/types/build"
+ "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/registry"
+)
+
+// ImageBuildOptions holds the information
+// necessary to build images.
+type ImageBuildOptions struct {
+ Tags []string
+ SuppressOutput bool
+ RemoteContext string
+ NoCache bool
+ Remove bool
+ ForceRemove bool
+ PullParent bool
+ Isolation container.Isolation
+ CPUSetCPUs string
+ CPUSetMems string
+ CPUShares int64
+ CPUQuota int64
+ CPUPeriod int64
+ Memory int64
+ MemorySwap int64
+ CgroupParent string
+ NetworkMode string
+ ShmSize int64
+ Dockerfile string
+ Ulimits []*container.Ulimit
+ // BuildArgs needs to be a *string instead of just a string so that
+ // we can tell the difference between "" (empty string) and no value
+ // at all (nil). See the parsing of buildArgs in
+ // api/server/router/build/build_routes.go for even more info.
+ BuildArgs map[string]*string
+ AuthConfigs map[string]registry.AuthConfig
+ Context io.Reader
+ Labels map[string]string
+ // squash the resulting image's layers to the parent
+ // preserves the original image and creates a new one from the parent with all
+ // the changes applied to a single layer
+ Squash bool
+ // CacheFrom specifies images that are used for matching cache. Images
+ // specified here do not need to have a valid parent chain to match cache.
+ CacheFrom []string
+ SecurityOpt []string
+ ExtraHosts []string // List of extra hosts
+ Target string
+ SessionID string
+ Platform string
+ // Version specifies the version of the underlying builder to use
+ Version build.BuilderVersion
+ // BuildID is an optional identifier that can be passed together with the
+ // build request. The same identifier can be used to gracefully cancel the
+ // build with the cancel request.
+ BuildID string
+ // Outputs defines configurations for exporting build results. Only supported
+ // in BuildKit mode
+ Outputs []ImageBuildOutput
+}
+
+// ImageBuildOutput defines configuration for exporting a build result
+type ImageBuildOutput struct {
+ Type string
+ Attrs map[string]string
+}
+
+// ImageBuildResponse holds information
+// returned by a server after building
+// an image.
+type ImageBuildResponse struct {
+ Body io.ReadCloser
+ OSType string
+}