mirror of https://github.com/containers/podman.git
vendor: update github.com/docker/docker to v28.2.2
Two incomptable changes, they removed the BridgeNfIP6tables and BridgeNfIptables fields so we must drop them. As they are not important ones that should not cause problems. Second, they moved to using DockerOCIImageConfig from another new module. The json format did not chnage so this is not an external API break. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
4871ad1dc6
commit
d44f0afa84
4
go.mod
4
go.mod
|
@ -27,7 +27,7 @@ require (
|
||||||
github.com/cyphar/filepath-securejoin v0.4.1
|
github.com/cyphar/filepath-securejoin v0.4.1
|
||||||
github.com/digitalocean/go-qemu v0.0.0-20250212194115-ee9b0668d242
|
github.com/digitalocean/go-qemu v0.0.0-20250212194115-ee9b0668d242
|
||||||
github.com/docker/distribution v2.8.3+incompatible
|
github.com/docker/distribution v2.8.3+incompatible
|
||||||
github.com/docker/docker v28.1.1+incompatible
|
github.com/docker/docker v28.2.2+incompatible
|
||||||
github.com/docker/go-connections v0.5.0
|
github.com/docker/go-connections v0.5.0
|
||||||
github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8
|
github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8
|
||||||
github.com/docker/go-units v0.5.0
|
github.com/docker/go-units v0.5.0
|
||||||
|
@ -46,6 +46,7 @@ require (
|
||||||
github.com/mattn/go-shellwords v1.0.12
|
github.com/mattn/go-shellwords v1.0.12
|
||||||
github.com/mattn/go-sqlite3 v1.14.28
|
github.com/mattn/go-sqlite3 v1.14.28
|
||||||
github.com/mdlayher/vsock v1.2.1
|
github.com/mdlayher/vsock v1.2.1
|
||||||
|
github.com/moby/docker-image-spec v1.3.1
|
||||||
github.com/moby/sys/capability v0.4.0
|
github.com/moby/sys/capability v0.4.0
|
||||||
github.com/moby/sys/user v0.4.0
|
github.com/moby/sys/user v0.4.0
|
||||||
github.com/moby/term v0.5.2
|
github.com/moby/term v0.5.2
|
||||||
|
@ -152,7 +153,6 @@ require (
|
||||||
github.com/mistifyio/go-zfs/v3 v3.0.1 // indirect
|
github.com/mistifyio/go-zfs/v3 v3.0.1 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/moby/buildkit v0.22.0 // indirect
|
github.com/moby/buildkit v0.22.0 // indirect
|
||||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
|
||||||
github.com/moby/go-archive v0.1.0 // indirect
|
github.com/moby/go-archive v0.1.0 // indirect
|
||||||
github.com/moby/patternmatcher v0.6.0 // indirect
|
github.com/moby/patternmatcher v0.6.0 // indirect
|
||||||
github.com/moby/sys/mountinfo v0.7.2 // indirect
|
github.com/moby/sys/mountinfo v0.7.2 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -121,8 +121,8 @@ github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5M
|
||||||
github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I=
|
github.com/docker/docker v28.2.2+incompatible h1:CjwRSksz8Yo4+RmQ339Dp/D2tGO5JxwYeqtMOEe0LDw=
|
||||||
github.com/docker/docker v28.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
github.com/docker/docker v28.2.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||||
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
|
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
|
||||||
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
|
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
|
||||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||||
|
|
|
@ -28,8 +28,9 @@ import (
|
||||||
dockerContainer "github.com/docker/docker/api/types/container"
|
dockerContainer "github.com/docker/docker/api/types/container"
|
||||||
dockerImage "github.com/docker/docker/api/types/image"
|
dockerImage "github.com/docker/docker/api/types/image"
|
||||||
dockerStorage "github.com/docker/docker/api/types/storage"
|
dockerStorage "github.com/docker/docker/api/types/storage"
|
||||||
"github.com/docker/go-connections/nat"
|
dockerSpec "github.com/moby/docker-image-spec/specs-go/v1"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
|
imageSpec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -353,15 +354,12 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ports, err := portsToPortSet(info.Config.ExposedPorts)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: many fields in Config still need wiring
|
// TODO: many fields in Config still need wiring
|
||||||
config := dockerContainer.Config{
|
config := dockerSpec.DockerOCIImageConfig{
|
||||||
|
ImageConfig: imageSpec.ImageConfig{
|
||||||
User: info.User,
|
User: info.User,
|
||||||
ExposedPorts: ports,
|
ExposedPorts: info.Config.ExposedPorts,
|
||||||
Env: info.Config.Env,
|
Env: info.Config.Env,
|
||||||
Cmd: info.Config.Cmd,
|
Cmd: info.Config.Cmd,
|
||||||
Volumes: info.Config.Volumes,
|
Volumes: info.Config.Volumes,
|
||||||
|
@ -369,6 +367,7 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
||||||
Entrypoint: info.Config.Entrypoint,
|
Entrypoint: info.Config.Entrypoint,
|
||||||
Labels: info.Labels,
|
Labels: info.Labels,
|
||||||
StopSignal: info.Config.StopSignal,
|
StopSignal: info.Config.StopSignal,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
rootfs := dockerImage.RootFS{}
|
rootfs := dockerImage.RootFS{}
|
||||||
|
@ -413,33 +412,6 @@ func imageDataToImageInspect(ctx context.Context, l *libimage.Image) (*handlers.
|
||||||
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
|
return &handlers.ImageInspect{InspectResponse: dockerImageInspect}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// portsToPortSet converts libpod's exposed ports to docker's structs
|
|
||||||
func portsToPortSet(input map[string]struct{}) (nat.PortSet, error) {
|
|
||||||
ports := make(nat.PortSet)
|
|
||||||
for k := range input {
|
|
||||||
proto, port := nat.SplitProtoPort(k)
|
|
||||||
switch proto {
|
|
||||||
// See the OCI image spec for details:
|
|
||||||
// https://github.com/opencontainers/image-spec/blob/e562b04403929d582d449ae5386ff79dd7961a11/config.md#properties
|
|
||||||
case "tcp", "":
|
|
||||||
p, err := nat.NewPort("tcp", port)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to create tcp port from %s: %w", k, err)
|
|
||||||
}
|
|
||||||
ports[p] = struct{}{}
|
|
||||||
case "udp":
|
|
||||||
p, err := nat.NewPort("udp", port)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to create tcp port from %s: %w", k, err)
|
|
||||||
}
|
|
||||||
ports[p] = struct{}{}
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("invalid port proto %q in %q", proto, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ports, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetImages(w http.ResponseWriter, r *http.Request) {
|
func GetImages(w http.ResponseWriter, r *http.Request) {
|
||||||
decoder := utils.GetDecoder(r)
|
decoder := utils.GetDecoder(r)
|
||||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||||
|
|
|
@ -56,8 +56,6 @@ func GetInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
info := &handlers.Info{
|
info := &handlers.Info{
|
||||||
Info: dockerSystem.Info{
|
Info: dockerSystem.Info{
|
||||||
Architecture: goRuntime.GOARCH,
|
Architecture: goRuntime.GOARCH,
|
||||||
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled,
|
|
||||||
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
|
|
||||||
CPUCfsPeriod: sysInfo.CPUCfsPeriod,
|
CPUCfsPeriod: sysInfo.CPUCfsPeriod,
|
||||||
CPUCfsQuota: sysInfo.CPUCfsQuota,
|
CPUCfsQuota: sysInfo.CPUCfsQuota,
|
||||||
CPUSet: sysInfo.Cpuset,
|
CPUSet: sysInfo.Cpuset,
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/containers/podman/v5/pkg/domain/entities"
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
||||||
docker "github.com/docker/docker/api/types"
|
docker "github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
dockerImage "github.com/docker/docker/api/types/image"
|
dockerImage "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
|
@ -94,7 +95,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) {
|
||||||
Images: imgs,
|
Images: imgs,
|
||||||
Containers: ctnrs,
|
Containers: ctnrs,
|
||||||
Volumes: vols,
|
Volumes: vols,
|
||||||
BuildCache: []*docker.BuildCache{},
|
BuildCache: []*build.CacheRecord{},
|
||||||
BuilderSize: 0,
|
BuilderSize: 0,
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package errhttp provides utility functions for translating errors to
|
||||||
|
// and from a HTTP context.
|
||||||
|
//
|
||||||
|
// The functions ToHTTP and ToNative can be used to map server-side and
|
||||||
|
// client-side errors to the correct types.
|
||||||
|
package errhttp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/containerd/errdefs"
|
||||||
|
"github.com/containerd/errdefs/pkg/internal/cause"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ToHTTP returns the best status code for the given error
|
||||||
|
func ToHTTP(err error) int {
|
||||||
|
switch {
|
||||||
|
case errdefs.IsNotFound(err):
|
||||||
|
return http.StatusNotFound
|
||||||
|
case errdefs.IsInvalidArgument(err):
|
||||||
|
return http.StatusBadRequest
|
||||||
|
case errdefs.IsConflict(err):
|
||||||
|
return http.StatusConflict
|
||||||
|
case errdefs.IsNotModified(err):
|
||||||
|
return http.StatusNotModified
|
||||||
|
case errdefs.IsFailedPrecondition(err):
|
||||||
|
return http.StatusPreconditionFailed
|
||||||
|
case errdefs.IsUnauthorized(err):
|
||||||
|
return http.StatusUnauthorized
|
||||||
|
case errdefs.IsPermissionDenied(err):
|
||||||
|
return http.StatusForbidden
|
||||||
|
case errdefs.IsResourceExhausted(err):
|
||||||
|
return http.StatusTooManyRequests
|
||||||
|
case errdefs.IsInternal(err):
|
||||||
|
return http.StatusInternalServerError
|
||||||
|
case errdefs.IsNotImplemented(err):
|
||||||
|
return http.StatusNotImplemented
|
||||||
|
case errdefs.IsUnavailable(err):
|
||||||
|
return http.StatusServiceUnavailable
|
||||||
|
case errdefs.IsUnknown(err):
|
||||||
|
var unexpected cause.ErrUnexpectedStatus
|
||||||
|
if errors.As(err, &unexpected) && unexpected.Status >= 200 && unexpected.Status < 600 {
|
||||||
|
return unexpected.Status
|
||||||
|
}
|
||||||
|
return http.StatusInternalServerError
|
||||||
|
default:
|
||||||
|
return http.StatusInternalServerError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToNative returns the error best matching the HTTP status code
|
||||||
|
func ToNative(statusCode int) error {
|
||||||
|
switch statusCode {
|
||||||
|
case http.StatusNotFound:
|
||||||
|
return errdefs.ErrNotFound
|
||||||
|
case http.StatusBadRequest:
|
||||||
|
return errdefs.ErrInvalidArgument
|
||||||
|
case http.StatusConflict:
|
||||||
|
return errdefs.ErrConflict
|
||||||
|
case http.StatusPreconditionFailed:
|
||||||
|
return errdefs.ErrFailedPrecondition
|
||||||
|
case http.StatusUnauthorized:
|
||||||
|
return errdefs.ErrUnauthenticated
|
||||||
|
case http.StatusForbidden:
|
||||||
|
return errdefs.ErrPermissionDenied
|
||||||
|
case http.StatusNotModified:
|
||||||
|
return errdefs.ErrNotModified
|
||||||
|
case http.StatusTooManyRequests:
|
||||||
|
return errdefs.ErrResourceExhausted
|
||||||
|
case http.StatusInternalServerError:
|
||||||
|
return errdefs.ErrInternal
|
||||||
|
case http.StatusNotImplemented:
|
||||||
|
return errdefs.ErrNotImplemented
|
||||||
|
case http.StatusServiceUnavailable:
|
||||||
|
return errdefs.ErrUnavailable
|
||||||
|
default:
|
||||||
|
return cause.ErrUnexpectedStatus{Status: statusCode}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
# This file lists all contributors to the repository.
|
# This file lists all contributors to the repository.
|
||||||
# See hack/generate-authors.sh to make modifications.
|
# See hack/generate-authors.sh to make modifications.
|
||||||
|
|
||||||
|
17neverends <ionianrise@gmail.com>
|
||||||
7sunarni <710720732@qq.com>
|
7sunarni <710720732@qq.com>
|
||||||
Aanand Prasad <aanand.prasad@gmail.com>
|
Aanand Prasad <aanand.prasad@gmail.com>
|
||||||
Aarni Koskela <akx@iki.fi>
|
Aarni Koskela <akx@iki.fi>
|
||||||
|
@ -189,6 +190,7 @@ Anes Hasicic <anes.hasicic@gmail.com>
|
||||||
Angel Velazquez <angelcar@amazon.com>
|
Angel Velazquez <angelcar@amazon.com>
|
||||||
Anil Belur <askb23@gmail.com>
|
Anil Belur <askb23@gmail.com>
|
||||||
Anil Madhavapeddy <anil@recoil.org>
|
Anil Madhavapeddy <anil@recoil.org>
|
||||||
|
Anirudh Aithal <aithal@amazon.com>
|
||||||
Ankit Jain <ajatkj@yahoo.co.in>
|
Ankit Jain <ajatkj@yahoo.co.in>
|
||||||
Ankush Agarwal <ankushagarwal11@gmail.com>
|
Ankush Agarwal <ankushagarwal11@gmail.com>
|
||||||
Anonmily <michelle@michelleliu.io>
|
Anonmily <michelle@michelleliu.io>
|
||||||
|
@ -227,7 +229,7 @@ Arun Gupta <arun.gupta@gmail.com>
|
||||||
Asad Saeeduddin <masaeedu@gmail.com>
|
Asad Saeeduddin <masaeedu@gmail.com>
|
||||||
Asbjørn Enge <asbjorn@hanafjedle.net>
|
Asbjørn Enge <asbjorn@hanafjedle.net>
|
||||||
Ashly Mathew <ashly.mathew@sap.com>
|
Ashly Mathew <ashly.mathew@sap.com>
|
||||||
Austin Vazquez <macedonv@amazon.com>
|
Austin Vazquez <austin.vazquez.dev@gmail.com>
|
||||||
averagehuman <averagehuman@users.noreply.github.com>
|
averagehuman <averagehuman@users.noreply.github.com>
|
||||||
Avi Das <andas222@gmail.com>
|
Avi Das <andas222@gmail.com>
|
||||||
Avi Kivity <avi@scylladb.com>
|
Avi Kivity <avi@scylladb.com>
|
||||||
|
@ -377,6 +379,7 @@ Chen Qiu <cheney-90@hotmail.com>
|
||||||
Cheng-mean Liu <soccerl@microsoft.com>
|
Cheng-mean Liu <soccerl@microsoft.com>
|
||||||
Chengfei Shang <cfshang@alauda.io>
|
Chengfei Shang <cfshang@alauda.io>
|
||||||
Chengguang Xu <cgxu519@gmx.com>
|
Chengguang Xu <cgxu519@gmx.com>
|
||||||
|
Chengyu Zhu <hudson@cyzhu.com>
|
||||||
Chentianze <cmoman@126.com>
|
Chentianze <cmoman@126.com>
|
||||||
Chenyang Yan <memory.yancy@gmail.com>
|
Chenyang Yan <memory.yancy@gmail.com>
|
||||||
chenyuzhu <chenyuzhi@oschina.cn>
|
chenyuzhu <chenyuzhi@oschina.cn>
|
||||||
|
@ -1209,6 +1212,7 @@ K. Heller <pestophagous@gmail.com>
|
||||||
Kai Blin <kai@samba.org>
|
Kai Blin <kai@samba.org>
|
||||||
Kai Qiang Wu (Kennan) <wkq5325@gmail.com>
|
Kai Qiang Wu (Kennan) <wkq5325@gmail.com>
|
||||||
Kaijie Chen <chen@kaijie.org>
|
Kaijie Chen <chen@kaijie.org>
|
||||||
|
Kaita Nakamura <kaita.nakamura0830@gmail.com>
|
||||||
Kamil Domański <kamil@domanski.co>
|
Kamil Domański <kamil@domanski.co>
|
||||||
Kamjar Gerami <kami.gerami@gmail.com>
|
Kamjar Gerami <kami.gerami@gmail.com>
|
||||||
Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
|
Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
|
||||||
|
@ -1485,6 +1489,7 @@ Matthias Kühnle <git.nivoc@neverbox.com>
|
||||||
Matthias Rampke <mr@soundcloud.com>
|
Matthias Rampke <mr@soundcloud.com>
|
||||||
Matthieu Fronton <m@tthieu.fr>
|
Matthieu Fronton <m@tthieu.fr>
|
||||||
Matthieu Hauglustaine <matt.hauglustaine@gmail.com>
|
Matthieu Hauglustaine <matt.hauglustaine@gmail.com>
|
||||||
|
Matthieu MOREL <matthieu.morel35@gmail.com>
|
||||||
Mattias Jernberg <nostrad@gmail.com>
|
Mattias Jernberg <nostrad@gmail.com>
|
||||||
Mauricio Garavaglia <mauricio@medallia.com>
|
Mauricio Garavaglia <mauricio@medallia.com>
|
||||||
mauriyouth <mauriyouth@gmail.com>
|
mauriyouth <mauriyouth@gmail.com>
|
||||||
|
@ -1874,6 +1879,7 @@ Robert Obryk <robryk@gmail.com>
|
||||||
Robert Schneider <mail@shakeme.info>
|
Robert Schneider <mail@shakeme.info>
|
||||||
Robert Shade <robert.shade@gmail.com>
|
Robert Shade <robert.shade@gmail.com>
|
||||||
Robert Stern <lexandro2000@gmail.com>
|
Robert Stern <lexandro2000@gmail.com>
|
||||||
|
Robert Sturla <robertsturla@outlook.com>
|
||||||
Robert Terhaar <rterhaar@atlanticdynamic.com>
|
Robert Terhaar <rterhaar@atlanticdynamic.com>
|
||||||
Robert Wallis <smilingrob@gmail.com>
|
Robert Wallis <smilingrob@gmail.com>
|
||||||
Robert Wang <robert@arctic.tw>
|
Robert Wang <robert@arctic.tw>
|
||||||
|
|
|
@ -3,7 +3,7 @@ package api // import "github.com/docker/docker/api"
|
||||||
// Common constants for daemon and client.
|
// Common constants for daemon and client.
|
||||||
const (
|
const (
|
||||||
// DefaultVersion of the current REST API.
|
// DefaultVersion of the current REST API.
|
||||||
DefaultVersion = "1.49"
|
DefaultVersion = "1.50"
|
||||||
|
|
||||||
// MinSupportedAPIVersion is the minimum API version that can be supported
|
// MinSupportedAPIVersion is the minimum API version that can be supported
|
||||||
// by the API server, specified as "major.minor". Note that the daemon
|
// by the API server, specified as "major.minor". Note that the daemon
|
||||||
|
|
|
@ -19,10 +19,10 @@ produces:
|
||||||
consumes:
|
consumes:
|
||||||
- "application/json"
|
- "application/json"
|
||||||
- "text/plain"
|
- "text/plain"
|
||||||
basePath: "/v1.49"
|
basePath: "/v1.50"
|
||||||
info:
|
info:
|
||||||
title: "Docker Engine API"
|
title: "Docker Engine API"
|
||||||
version: "1.49"
|
version: "1.50"
|
||||||
x-logo:
|
x-logo:
|
||||||
url: "https://docs.docker.com/assets/images/logo-docker-main.png"
|
url: "https://docs.docker.com/assets/images/logo-docker-main.png"
|
||||||
description: |
|
description: |
|
||||||
|
@ -55,8 +55,8 @@ info:
|
||||||
the URL is not supported by the daemon, a HTTP `400 Bad Request` error message
|
the URL is not supported by the daemon, a HTTP `400 Bad Request` error message
|
||||||
is returned.
|
is returned.
|
||||||
|
|
||||||
If you omit the version-prefix, the current version of the API (v1.49) is used.
|
If you omit the version-prefix, the current version of the API (v1.50) is used.
|
||||||
For example, calling `/info` is the same as calling `/v1.49/info`. Using the
|
For example, calling `/info` is the same as calling `/v1.50/info`. Using the
|
||||||
API without a version-prefix is deprecated and will be removed in a future release.
|
API without a version-prefix is deprecated and will be removed in a future release.
|
||||||
|
|
||||||
Engine releases in the near future should support this version of the API,
|
Engine releases in the near future should support this version of the API,
|
||||||
|
@ -1428,63 +1428,10 @@ definitions:
|
||||||
when starting a container from the image.
|
when starting a container from the image.
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
Hostname:
|
|
||||||
description: |
|
|
||||||
The hostname to use for the container, as a valid RFC 1123 hostname.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always empty. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "string"
|
|
||||||
example: ""
|
|
||||||
Domainname:
|
|
||||||
description: |
|
|
||||||
The domain name to use for the container.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always empty. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "string"
|
|
||||||
example: ""
|
|
||||||
User:
|
User:
|
||||||
description: "The user that commands are run as inside the container."
|
description: "The user that commands are run as inside the container."
|
||||||
type: "string"
|
type: "string"
|
||||||
example: "web:web"
|
example: "web:web"
|
||||||
AttachStdin:
|
|
||||||
description: |
|
|
||||||
Whether to attach to `stdin`.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always false. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
AttachStdout:
|
|
||||||
description: |
|
|
||||||
Whether to attach to `stdout`.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always false. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
AttachStderr:
|
|
||||||
description: |
|
|
||||||
Whether to attach to `stderr`.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always false. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
ExposedPorts:
|
ExposedPorts:
|
||||||
description: |
|
description: |
|
||||||
An object mapping ports to an empty object in the form:
|
An object mapping ports to an empty object in the form:
|
||||||
|
@ -1501,39 +1448,6 @@ definitions:
|
||||||
"80/tcp": {},
|
"80/tcp": {},
|
||||||
"443/tcp": {}
|
"443/tcp": {}
|
||||||
}
|
}
|
||||||
Tty:
|
|
||||||
description: |
|
|
||||||
Attach standard streams to a TTY, including `stdin` if it is not closed.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always false. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
OpenStdin:
|
|
||||||
description: |
|
|
||||||
Open `stdin`
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always false. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
StdinOnce:
|
|
||||||
description: |
|
|
||||||
Close `stdin` after one attached client disconnects.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always false. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
Env:
|
Env:
|
||||||
description: |
|
description: |
|
||||||
A list of environment variables to set inside the container in the
|
A list of environment variables to set inside the container in the
|
||||||
|
@ -1559,18 +1473,6 @@ definitions:
|
||||||
default: false
|
default: false
|
||||||
example: false
|
example: false
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
Image:
|
|
||||||
description: |
|
|
||||||
The name (or reference) of the image to use when creating the container,
|
|
||||||
or which was used when the container was created.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always empty. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "string"
|
|
||||||
default: ""
|
|
||||||
example: ""
|
|
||||||
Volumes:
|
Volumes:
|
||||||
description: |
|
description: |
|
||||||
An object mapping mount point paths inside the container to empty
|
An object mapping mount point paths inside the container to empty
|
||||||
|
@ -1599,30 +1501,6 @@ definitions:
|
||||||
items:
|
items:
|
||||||
type: "string"
|
type: "string"
|
||||||
example: []
|
example: []
|
||||||
NetworkDisabled:
|
|
||||||
description: |
|
|
||||||
Disable networking for the container.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always omitted. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
example: false
|
|
||||||
x-nullable: true
|
|
||||||
MacAddress:
|
|
||||||
description: |
|
|
||||||
MAC address of the container.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always omitted. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "string"
|
|
||||||
default: ""
|
|
||||||
example: ""
|
|
||||||
x-nullable: true
|
|
||||||
OnBuild:
|
OnBuild:
|
||||||
description: |
|
description: |
|
||||||
`ONBUILD` metadata that were defined in the image's `Dockerfile`.
|
`ONBUILD` metadata that were defined in the image's `Dockerfile`.
|
||||||
|
@ -1645,17 +1523,6 @@ definitions:
|
||||||
type: "string"
|
type: "string"
|
||||||
example: "SIGTERM"
|
example: "SIGTERM"
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
StopTimeout:
|
|
||||||
description: |
|
|
||||||
Timeout to stop a container in seconds.
|
|
||||||
|
|
||||||
<p><br /></p>
|
|
||||||
|
|
||||||
> **Deprecated**: this field is not part of the image specification and is
|
|
||||||
> always omitted. It must not be used, and will be removed in API v1.48.
|
|
||||||
type: "integer"
|
|
||||||
default: 10
|
|
||||||
x-nullable: true
|
|
||||||
Shell:
|
Shell:
|
||||||
description: |
|
description: |
|
||||||
Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell.
|
Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell.
|
||||||
|
@ -1666,19 +1533,11 @@ definitions:
|
||||||
example: ["/bin/sh", "-c"]
|
example: ["/bin/sh", "-c"]
|
||||||
# FIXME(thaJeztah): temporarily using a full example to remove some "omitempty" fields. Remove once the fields are removed.
|
# FIXME(thaJeztah): temporarily using a full example to remove some "omitempty" fields. Remove once the fields are removed.
|
||||||
example:
|
example:
|
||||||
"Hostname": ""
|
|
||||||
"Domainname": ""
|
|
||||||
"User": "web:web"
|
"User": "web:web"
|
||||||
"AttachStdin": false
|
|
||||||
"AttachStdout": false
|
|
||||||
"AttachStderr": false
|
|
||||||
"ExposedPorts": {
|
"ExposedPorts": {
|
||||||
"80/tcp": {},
|
"80/tcp": {},
|
||||||
"443/tcp": {}
|
"443/tcp": {}
|
||||||
}
|
}
|
||||||
"Tty": false
|
|
||||||
"OpenStdin": false
|
|
||||||
"StdinOnce": false
|
|
||||||
"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"]
|
"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"]
|
||||||
"Cmd": ["/bin/sh"]
|
"Cmd": ["/bin/sh"]
|
||||||
"Healthcheck": {
|
"Healthcheck": {
|
||||||
|
@ -1690,7 +1549,6 @@ definitions:
|
||||||
"StartInterval": 0
|
"StartInterval": 0
|
||||||
}
|
}
|
||||||
"ArgsEscaped": true
|
"ArgsEscaped": true
|
||||||
"Image": ""
|
|
||||||
"Volumes": {
|
"Volumes": {
|
||||||
"/app/data": {},
|
"/app/data": {},
|
||||||
"/app/config": {}
|
"/app/config": {}
|
||||||
|
@ -2956,6 +2814,23 @@ definitions:
|
||||||
progressDetail:
|
progressDetail:
|
||||||
$ref: "#/definitions/ProgressDetail"
|
$ref: "#/definitions/ProgressDetail"
|
||||||
|
|
||||||
|
DeviceInfo:
|
||||||
|
type: "object"
|
||||||
|
description: |
|
||||||
|
DeviceInfo represents a device that can be used by a container.
|
||||||
|
properties:
|
||||||
|
Source:
|
||||||
|
type: "string"
|
||||||
|
example: "cdi"
|
||||||
|
description: |
|
||||||
|
The origin device driver.
|
||||||
|
ID:
|
||||||
|
type: "string"
|
||||||
|
example: "vendor.com/gpu=0"
|
||||||
|
description: |
|
||||||
|
The unique identifier for the device within its source driver.
|
||||||
|
For CDI devices, this would be an FQDN like "vendor.com/gpu=0".
|
||||||
|
|
||||||
ErrorDetail:
|
ErrorDetail:
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
|
@ -6858,6 +6733,15 @@ definitions:
|
||||||
example: "24"
|
example: "24"
|
||||||
FirewallBackend:
|
FirewallBackend:
|
||||||
$ref: "#/definitions/FirewallInfo"
|
$ref: "#/definitions/FirewallInfo"
|
||||||
|
DiscoveredDevices:
|
||||||
|
description: |
|
||||||
|
List of devices discovered by device drivers.
|
||||||
|
|
||||||
|
Each device includes information about its source driver, kind, name,
|
||||||
|
and additional driver-specific attributes.
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/DeviceInfo"
|
||||||
Warnings:
|
Warnings:
|
||||||
description: |
|
description: |
|
||||||
List of warnings / informational messages about missing features, or
|
List of warnings / informational messages about missing features, or
|
||||||
|
@ -9934,6 +9818,18 @@ paths:
|
||||||
description: "Do not delete untagged parent images"
|
description: "Do not delete untagged parent images"
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
default: false
|
default: false
|
||||||
|
- name: "platforms"
|
||||||
|
in: "query"
|
||||||
|
description: |
|
||||||
|
Select platform-specific content to delete.
|
||||||
|
Multiple values are accepted.
|
||||||
|
Each platform is a OCI platform encoded as a JSON string.
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
# This should be OCIPlatform
|
||||||
|
# but $ref is not supported for array in query in Swagger 2.0
|
||||||
|
# $ref: "#/definitions/OCIPlatform"
|
||||||
|
type: "string"
|
||||||
tags: ["Image"]
|
tags: ["Image"]
|
||||||
/images/search:
|
/images/search:
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -160,7 +160,7 @@ type ImageInspectOpts struct {
|
||||||
type CommitConfig struct {
|
type CommitConfig struct {
|
||||||
Author string
|
Author string
|
||||||
Comment string
|
Comment string
|
||||||
Config *container.Config
|
Config *container.Config // TODO(thaJeztah); change this to [dockerspec.DockerOCIImageConfig]
|
||||||
ContainerConfig *container.Config
|
ContainerConfig *container.Config
|
||||||
ContainerID string
|
ContainerID string
|
||||||
ContainerMountLabel string
|
ContainerMountLabel string
|
||||||
|
|
|
@ -3,7 +3,7 @@ package backend // import "github.com/docker/docker/api/types/backend"
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/pkg/streamformatter"
|
"github.com/docker/docker/pkg/streamformatter"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
@ -34,7 +34,7 @@ type ProgressWriter struct {
|
||||||
type BuildConfig struct {
|
type BuildConfig struct {
|
||||||
Source io.ReadCloser
|
Source io.ReadCloser
|
||||||
ProgressWriter ProgressWriter
|
ProgressWriter ProgressWriter
|
||||||
Options *types.ImageBuildOptions
|
Options *build.ImageBuildOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer
|
// GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BuilderVersion sets the version of underlying builder to use
|
||||||
|
type BuilderVersion string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BuilderV1 is the first generation builder in docker daemon
|
||||||
|
BuilderV1 BuilderVersion = "1"
|
||||||
|
// BuilderBuildKit is builder based on moby/buildkit project
|
||||||
|
BuilderBuildKit BuilderVersion = "2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Result contains the image id of a successful build.
|
||||||
|
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
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CacheRecord contains information about a build cache record.
|
||||||
|
type CacheRecord struct {
|
||||||
|
// ID is the unique ID of the build cache record.
|
||||||
|
ID string
|
||||||
|
// Parent is the ID of the parent build cache record.
|
||||||
|
//
|
||||||
|
// Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead.
|
||||||
|
Parent string `json:"Parent,omitempty"`
|
||||||
|
// Parents is the list of parent build cache record IDs.
|
||||||
|
Parents []string `json:" Parents,omitempty"`
|
||||||
|
// Type is the cache record type.
|
||||||
|
Type string
|
||||||
|
// Description is a description of the build-step that produced the build cache.
|
||||||
|
Description string
|
||||||
|
// InUse indicates if the build cache is in use.
|
||||||
|
InUse bool
|
||||||
|
// Shared indicates if the build cache is shared.
|
||||||
|
Shared bool
|
||||||
|
// Size is the amount of disk space used by the build cache (in bytes).
|
||||||
|
Size int64
|
||||||
|
// CreatedAt is the date and time at which the build cache was created.
|
||||||
|
CreatedAt time.Time
|
||||||
|
// LastUsedAt is the date and time at which the build cache was last used.
|
||||||
|
LastUsedAt *time.Time
|
||||||
|
UsageCount int
|
||||||
|
}
|
||||||
|
|
||||||
|
// CachePruneOptions hold parameters to prune the build cache.
|
||||||
|
type CachePruneOptions struct {
|
||||||
|
All bool
|
||||||
|
ReservedSpace int64
|
||||||
|
MaxUsedSpace int64
|
||||||
|
MinFreeSpace int64
|
||||||
|
Filters filters.Args
|
||||||
|
|
||||||
|
KeepStorage int64 // Deprecated: deprecated in API 1.48.
|
||||||
|
}
|
||||||
|
|
||||||
|
// CachePruneReport contains the response for Engine API:
|
||||||
|
// POST "/build/prune"
|
||||||
|
type CachePruneReport struct {
|
||||||
|
CachesDeleted []string
|
||||||
|
SpaceReclaimed uint64
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package build
|
||||||
|
|
||||||
|
// CacheDiskUsage contains disk usage for the build cache.
|
||||||
|
type CacheDiskUsage struct {
|
||||||
|
TotalSize int64
|
||||||
|
Reclaimable int64
|
||||||
|
Items []*CacheRecord
|
||||||
|
}
|
|
@ -3,12 +3,7 @@ package types // import "github.com/docker/docker/api/types"
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/container"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
|
||||||
"github.com/docker/docker/api/types/registry"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewHijackedResponse initializes a [HijackedResponse] type.
|
// NewHijackedResponse initializes a [HijackedResponse] type.
|
||||||
|
@ -51,165 +46,6 @@ func (h *HijackedResponse) CloseWrite() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuilderVersion sets the version of underlying builder to use
|
|
||||||
type BuilderVersion string
|
|
||||||
|
|
||||||
const (
|
|
||||||
// BuilderV1 is the first generation builder in docker daemon
|
|
||||||
BuilderV1 BuilderVersion = "1"
|
|
||||||
// BuilderBuildKit is builder based on moby/buildkit project
|
|
||||||
BuilderBuildKit BuilderVersion = "2"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ImageBuildResponse holds information
|
|
||||||
// returned by a server after building
|
|
||||||
// an image.
|
|
||||||
type ImageBuildResponse struct {
|
|
||||||
Body io.ReadCloser
|
|
||||||
OSType string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NodeListOptions holds parameters to list nodes with.
|
|
||||||
type NodeListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
}
|
|
||||||
|
|
||||||
// NodeRemoveOptions holds parameters to remove nodes with.
|
|
||||||
type NodeRemoveOptions struct {
|
|
||||||
Force bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceCreateOptions contains the options to use when creating a service.
|
|
||||||
type ServiceCreateOptions struct {
|
|
||||||
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
|
||||||
// use when updating the service.
|
|
||||||
//
|
|
||||||
// This field follows the format of the X-Registry-Auth header.
|
|
||||||
EncodedRegistryAuth string
|
|
||||||
|
|
||||||
// QueryRegistry indicates whether the service update requires
|
|
||||||
// contacting a registry. A registry may be contacted to retrieve
|
|
||||||
// the image digest and manifest, which in turn can be used to update
|
|
||||||
// platform or other information about the service.
|
|
||||||
QueryRegistry bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
|
||||||
const (
|
|
||||||
RegistryAuthFromSpec = "spec"
|
|
||||||
RegistryAuthFromPreviousSpec = "previous-spec"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ServiceUpdateOptions contains the options to be used for updating services.
|
|
||||||
type ServiceUpdateOptions struct {
|
|
||||||
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
|
||||||
// use when updating the service.
|
|
||||||
//
|
|
||||||
// This field follows the format of the X-Registry-Auth header.
|
|
||||||
EncodedRegistryAuth string
|
|
||||||
|
|
||||||
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
|
|
||||||
// into this field. While it does open API users up to racy writes, most
|
|
||||||
// users may not need that level of consistency in practice.
|
|
||||||
|
|
||||||
// RegistryAuthFrom specifies where to find the registry authorization
|
|
||||||
// credentials if they are not given in EncodedRegistryAuth. Valid
|
|
||||||
// values are "spec" and "previous-spec".
|
|
||||||
RegistryAuthFrom string
|
|
||||||
|
|
||||||
// Rollback indicates whether a server-side rollback should be
|
|
||||||
// performed. When this is set, the provided spec will be ignored.
|
|
||||||
// The valid values are "previous" and "none". An empty value is the
|
|
||||||
// same as "none".
|
|
||||||
Rollback string
|
|
||||||
|
|
||||||
// QueryRegistry indicates whether the service update requires
|
|
||||||
// contacting a registry. A registry may be contacted to retrieve
|
|
||||||
// the image digest and manifest, which in turn can be used to update
|
|
||||||
// platform or other information about the service.
|
|
||||||
QueryRegistry bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceListOptions holds parameters to list services with.
|
|
||||||
type ServiceListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
|
|
||||||
// Status indicates whether the server should include the service task
|
|
||||||
// count of running and desired tasks.
|
|
||||||
Status bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
|
||||||
// operation.
|
|
||||||
type ServiceInspectOptions struct {
|
|
||||||
InsertDefaults bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// TaskListOptions holds parameters to list tasks with.
|
|
||||||
type TaskListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginRemoveOptions holds parameters to remove plugins.
|
// PluginRemoveOptions holds parameters to remove plugins.
|
||||||
type PluginRemoveOptions struct {
|
type PluginRemoveOptions struct {
|
||||||
Force bool
|
Force bool
|
||||||
|
@ -243,13 +79,6 @@ type PluginInstallOptions struct {
|
||||||
Args []string
|
Args []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SwarmUnlockKeyResponse contains the response for Engine API:
|
|
||||||
// GET /swarm/unlockkey
|
|
||||||
type SwarmUnlockKeyResponse struct {
|
|
||||||
// UnlockKey is the unlock key in ASCII-armored format.
|
|
||||||
UnlockKey string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginCreateOptions hold all options to plugin create.
|
// PluginCreateOptions hold all options to plugin create.
|
||||||
type PluginCreateOptions struct {
|
type PluginCreateOptions struct {
|
||||||
RepoName string
|
RepoName string
|
||||||
|
|
|
@ -104,7 +104,7 @@ type MountPoint struct {
|
||||||
// State stores container's running state
|
// State stores container's running state
|
||||||
// it's part of ContainerJSONBase and returned by "inspect" command
|
// it's part of ContainerJSONBase and returned by "inspect" command
|
||||||
type State struct {
|
type State struct {
|
||||||
Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
|
Status ContainerState // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
|
||||||
Running bool
|
Running bool
|
||||||
Paused bool
|
Paused bool
|
||||||
Restarting bool
|
Restarting bool
|
||||||
|
@ -132,7 +132,7 @@ type Summary struct {
|
||||||
SizeRw int64 `json:",omitempty"`
|
SizeRw int64 `json:",omitempty"`
|
||||||
SizeRootFs int64 `json:",omitempty"`
|
SizeRootFs int64 `json:",omitempty"`
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
State string
|
State ContainerState
|
||||||
Status string
|
Status string
|
||||||
HostConfig struct {
|
HostConfig struct {
|
||||||
NetworkMode string `json:",omitempty"`
|
NetworkMode string `json:",omitempty"`
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package container
|
||||||
|
|
||||||
|
// DiskUsage contains disk usage for containers.
|
||||||
|
type DiskUsage struct {
|
||||||
|
TotalSize int64
|
||||||
|
Reclaimable int64
|
||||||
|
Items []*Summary
|
||||||
|
}
|
|
@ -1,18 +1,27 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HealthStatus is a string representation of the container's health.
|
||||||
|
//
|
||||||
|
// It currently is an alias for string, but may become a distinct type in future.
|
||||||
|
type HealthStatus = string
|
||||||
|
|
||||||
// Health states
|
// Health states
|
||||||
const (
|
const (
|
||||||
NoHealthcheck = "none" // Indicates there is no healthcheck
|
NoHealthcheck HealthStatus = "none" // Indicates there is no healthcheck
|
||||||
Starting = "starting" // Starting indicates that the container is not yet ready
|
Starting HealthStatus = "starting" // Starting indicates that the container is not yet ready
|
||||||
Healthy = "healthy" // Healthy indicates that the container is running correctly
|
Healthy HealthStatus = "healthy" // Healthy indicates that the container is running correctly
|
||||||
Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem
|
Unhealthy HealthStatus = "unhealthy" // Unhealthy indicates that the container has a problem
|
||||||
)
|
)
|
||||||
|
|
||||||
// Health stores information about the container's healthcheck results
|
// Health stores information about the container's healthcheck results
|
||||||
type Health struct {
|
type Health struct {
|
||||||
Status string // Status is one of [Starting], [Healthy] or [Unhealthy].
|
Status HealthStatus // Status is one of [Starting], [Healthy] or [Unhealthy].
|
||||||
FailingStreak int // FailingStreak is the number of consecutive failures
|
FailingStreak int // FailingStreak is the number of consecutive failures
|
||||||
Log []*HealthcheckResult // Log contains the last few results (oldest first)
|
Log []*HealthcheckResult // Log contains the last few results (oldest first)
|
||||||
}
|
}
|
||||||
|
@ -24,3 +33,18 @@ type HealthcheckResult struct {
|
||||||
ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe
|
ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe
|
||||||
Output string // Output from last check
|
Output string // Output from last check
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var validHealths = []string{
|
||||||
|
NoHealthcheck, Starting, Healthy, Unhealthy,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateHealthStatus checks if the provided string is a valid
|
||||||
|
// container [HealthStatus].
|
||||||
|
func ValidateHealthStatus(s HealthStatus) error {
|
||||||
|
switch s {
|
||||||
|
case NoHealthcheck, Starting, Healthy, Unhealthy:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return errInvalidParameter{error: fmt.Errorf("invalid value for health (%s): must be one of %s", s, strings.Join(validHealths, ", "))}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ func (n NetworkMode) IsDefault() bool {
|
||||||
|
|
||||||
// IsPrivate indicates whether container uses its private network stack.
|
// IsPrivate indicates whether container uses its private network stack.
|
||||||
func (n NetworkMode) IsPrivate() bool {
|
func (n NetworkMode) IsPrivate() bool {
|
||||||
return !(n.IsHost() || n.IsContainer())
|
return !n.IsHost() && !n.IsContainer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsContainer indicates whether container uses a container network stack.
|
// IsContainer indicates whether container uses a container network stack.
|
||||||
|
@ -230,7 +230,7 @@ type PidMode string
|
||||||
|
|
||||||
// IsPrivate indicates whether the container uses its own new pid namespace.
|
// IsPrivate indicates whether the container uses its own new pid namespace.
|
||||||
func (n PidMode) IsPrivate() bool {
|
func (n PidMode) IsPrivate() bool {
|
||||||
return !(n.IsHost() || n.IsContainer())
|
return !n.IsHost() && !n.IsContainer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHost indicates whether the container uses the host's pid namespace.
|
// IsHost indicates whether the container uses the host's pid namespace.
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package container
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ContainerState is a string representation of the container's current state.
|
||||||
|
//
|
||||||
|
// It currently is an alias for string, but may become a distinct type in the future.
|
||||||
|
type ContainerState = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
StateCreated ContainerState = "created" // StateCreated indicates the container is created, but not (yet) started.
|
||||||
|
StateRunning ContainerState = "running" // StateRunning indicates that the container is running.
|
||||||
|
StatePaused ContainerState = "paused" // StatePaused indicates that the container's current state is paused.
|
||||||
|
StateRestarting ContainerState = "restarting" // StateRestarting indicates that the container is currently restarting.
|
||||||
|
StateRemoving ContainerState = "removing" // StateRemoving indicates that the container is being removed.
|
||||||
|
StateExited ContainerState = "exited" // StateExited indicates that the container exited.
|
||||||
|
StateDead ContainerState = "dead" // StateDead indicates that the container failed to be deleted. Containers in this state are attempted to be cleaned up when the daemon restarts.
|
||||||
|
)
|
||||||
|
|
||||||
|
var validStates = []ContainerState{
|
||||||
|
StateCreated, StateRunning, StatePaused, StateRestarting, StateRemoving, StateExited, StateDead,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateContainerState checks if the provided string is a valid
|
||||||
|
// container [ContainerState].
|
||||||
|
func ValidateContainerState(s ContainerState) error {
|
||||||
|
switch s {
|
||||||
|
case StateCreated, StateRunning, StatePaused, StateRestarting, StateRemoving, StateExited, StateDead:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return errInvalidParameter{error: fmt.Errorf("invalid value for state (%s): must be one of %s", s, strings.Join(validStates, ", "))}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StateStatus is used to return container wait results.
|
||||||
|
// Implements exec.ExitCode interface.
|
||||||
|
// This type is needed as State include a sync.Mutex field which make
|
||||||
|
// copying it unsafe.
|
||||||
|
type StateStatus struct {
|
||||||
|
exitCode int
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExitCode returns current exitcode for the state.
|
||||||
|
func (s StateStatus) ExitCode() int {
|
||||||
|
return s.exitCode
|
||||||
|
}
|
||||||
|
|
||||||
|
// Err returns current error for the state. Returns nil if the container had
|
||||||
|
// exited on its own.
|
||||||
|
func (s StateStatus) Err() error {
|
||||||
|
return s.err
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStateStatus returns a new StateStatus with the given exit code and error.
|
||||||
|
func NewStateStatus(exitCode int, err error) StateStatus {
|
||||||
|
return StateStatus{
|
||||||
|
exitCode: exitCode,
|
||||||
|
err: err,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package image
|
||||||
|
|
||||||
|
// DiskUsage contains disk usage for images.
|
||||||
|
type DiskUsage struct {
|
||||||
|
TotalSize int64
|
||||||
|
Reclaimable int64
|
||||||
|
Items []*Summary
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package image
|
||||||
import (
|
import (
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/storage"
|
"github.com/docker/docker/api/types/storage"
|
||||||
|
dockerspec "github.com/moby/docker-image-spec/specs-go/v1"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ type InspectResponse struct {
|
||||||
// Author is the name of the author that was specified when committing the
|
// Author is the name of the author that was specified when committing the
|
||||||
// image, or as specified through MAINTAINER (deprecated) in the Dockerfile.
|
// image, or as specified through MAINTAINER (deprecated) in the Dockerfile.
|
||||||
Author string
|
Author string
|
||||||
Config *container.Config
|
Config *dockerspec.DockerOCIImageConfig
|
||||||
|
|
||||||
// Architecture is the hardware CPU architecture that the image runs on.
|
// Architecture is the hardware CPU architecture that the image runs on.
|
||||||
Architecture string
|
Architecture string
|
||||||
|
|
|
@ -83,6 +83,7 @@ type ListOptions struct {
|
||||||
|
|
||||||
// RemoveOptions holds parameters to remove images.
|
// RemoveOptions holds parameters to remove images.
|
||||||
type RemoveOptions struct {
|
type RemoveOptions struct {
|
||||||
|
Platforms []ocispec.Platform
|
||||||
Force bool
|
Force bool
|
||||||
PruneChildren bool
|
PruneChildren bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
)
|
||||||
|
|
||||||
// Config represents a config.
|
// Config represents a config.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -44,3 +48,15 @@ type ConfigReference struct {
|
||||||
ConfigID string
|
ConfigID string
|
||||||
ConfigName string
|
ConfigName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConfigCreateResponse contains the information returned to a client
|
||||||
|
// on the creation of a new config.
|
||||||
|
type ConfigCreateResponse struct {
|
||||||
|
// ID is the id of the created config.
|
||||||
|
ID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigListOptions holds parameters to list configs
|
||||||
|
type ConfigListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
|
import "github.com/docker/docker/api/types/filters"
|
||||||
|
|
||||||
// Node represents a node.
|
// Node represents a node.
|
||||||
type Node struct {
|
type Node struct {
|
||||||
|
@ -137,3 +138,13 @@ const (
|
||||||
type Topology struct {
|
type Topology struct {
|
||||||
Segments map[string]string `json:",omitempty"`
|
Segments map[string]string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeListOptions holds parameters to list nodes with.
|
||||||
|
type NodeListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeRemoveOptions holds parameters to remove nodes with.
|
||||||
|
type NodeRemoveOptions struct {
|
||||||
|
Force bool
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
)
|
||||||
|
|
||||||
// Secret represents a secret.
|
// Secret represents a secret.
|
||||||
type Secret struct {
|
type Secret struct {
|
||||||
|
@ -48,3 +52,15 @@ type SecretReference struct {
|
||||||
SecretID string
|
SecretID string
|
||||||
SecretName string
|
SecretName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SecretCreateResponse contains the information returned to a client
|
||||||
|
// on the creation of a new secret.
|
||||||
|
type SecretCreateResponse struct {
|
||||||
|
// ID is the id of the created secret.
|
||||||
|
ID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// SecretListOptions holds parameters to list secrets
|
||||||
|
type SecretListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
)
|
||||||
|
|
||||||
// Service represents a service.
|
// Service represents a service.
|
||||||
type Service struct {
|
type Service struct {
|
||||||
|
@ -200,3 +204,69 @@ type JobStatus struct {
|
||||||
// Swarm manager.
|
// Swarm manager.
|
||||||
LastExecution time.Time `json:",omitempty"`
|
LastExecution time.Time `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServiceCreateOptions contains the options to use when creating a service.
|
||||||
|
type ServiceCreateOptions struct {
|
||||||
|
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
||||||
|
// use when updating the service.
|
||||||
|
//
|
||||||
|
// This field follows the format of the X-Registry-Auth header.
|
||||||
|
EncodedRegistryAuth string
|
||||||
|
|
||||||
|
// QueryRegistry indicates whether the service update requires
|
||||||
|
// contacting a registry. A registry may be contacted to retrieve
|
||||||
|
// the image digest and manifest, which in turn can be used to update
|
||||||
|
// platform or other information about the service.
|
||||||
|
QueryRegistry bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
||||||
|
const (
|
||||||
|
RegistryAuthFromSpec = "spec"
|
||||||
|
RegistryAuthFromPreviousSpec = "previous-spec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServiceUpdateOptions contains the options to be used for updating services.
|
||||||
|
type ServiceUpdateOptions struct {
|
||||||
|
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
||||||
|
// use when updating the service.
|
||||||
|
//
|
||||||
|
// This field follows the format of the X-Registry-Auth header.
|
||||||
|
EncodedRegistryAuth string
|
||||||
|
|
||||||
|
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
|
||||||
|
// into this field. While it does open API users up to racy writes, most
|
||||||
|
// users may not need that level of consistency in practice.
|
||||||
|
|
||||||
|
// RegistryAuthFrom specifies where to find the registry authorization
|
||||||
|
// credentials if they are not given in EncodedRegistryAuth. Valid
|
||||||
|
// values are "spec" and "previous-spec".
|
||||||
|
RegistryAuthFrom string
|
||||||
|
|
||||||
|
// Rollback indicates whether a server-side rollback should be
|
||||||
|
// performed. When this is set, the provided spec will be ignored.
|
||||||
|
// The valid values are "previous" and "none". An empty value is the
|
||||||
|
// same as "none".
|
||||||
|
Rollback string
|
||||||
|
|
||||||
|
// QueryRegistry indicates whether the service update requires
|
||||||
|
// contacting a registry. A registry may be contacted to retrieve
|
||||||
|
// the image digest and manifest, which in turn can be used to update
|
||||||
|
// platform or other information about the service.
|
||||||
|
QueryRegistry bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceListOptions holds parameters to list services with.
|
||||||
|
type ServiceListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
|
||||||
|
// Status indicates whether the server should include the service task
|
||||||
|
// count of running and desired tasks.
|
||||||
|
Status bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||||
|
// operation.
|
||||||
|
type ServiceInspectOptions struct {
|
||||||
|
InsertDefaults bool
|
||||||
|
}
|
||||||
|
|
|
@ -235,3 +235,10 @@ type UpdateFlags struct {
|
||||||
RotateManagerToken bool
|
RotateManagerToken bool
|
||||||
RotateManagerUnlockKey bool
|
RotateManagerUnlockKey bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnlockKeyResponse contains the response for Engine API:
|
||||||
|
// GET /swarm/unlockkey
|
||||||
|
type UnlockKeyResponse struct {
|
||||||
|
// UnlockKey is the unlock key in ASCII-armored format.
|
||||||
|
UnlockKey string
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm/runtime"
|
"github.com/docker/docker/api/types/swarm/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -223,3 +224,8 @@ type VolumeAttachment struct {
|
||||||
// in the ContainerSpec, that this volume fulfills.
|
// in the ContainerSpec, that this volume fulfills.
|
||||||
Target string `json:",omitempty"`
|
Target string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TaskListOptions holds parameters to list tasks with.
|
||||||
|
type TaskListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/docker/api/types/build"
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
|
"github.com/docker/docker/api/types/volume"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DiskUsage contains response of Engine API for API 1.49 and greater:
|
||||||
|
// GET "/system/df"
|
||||||
|
type DiskUsage struct {
|
||||||
|
Images *image.DiskUsage
|
||||||
|
Containers *container.DiskUsage
|
||||||
|
Volumes *volume.DiskUsage
|
||||||
|
BuildCache *build.CacheDiskUsage
|
||||||
|
}
|
|
@ -29,8 +29,6 @@ type Info struct {
|
||||||
CPUSet bool
|
CPUSet bool
|
||||||
PidsLimit bool
|
PidsLimit bool
|
||||||
IPv4Forwarding bool
|
IPv4Forwarding bool
|
||||||
BridgeNfIptables bool `json:"BridgeNfIptables"` // Deprecated: netfilter module is now loaded on-demand and no longer during daemon startup, making this field obsolete. This field is always false and will be removed in the next release.
|
|
||||||
BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` // Deprecated: netfilter module is now loaded on-demand and no longer during daemon startup, making this field obsolete. This field is always false and will be removed in the next release.
|
|
||||||
Debug bool
|
Debug bool
|
||||||
NFd int
|
NFd int
|
||||||
OomKillDisable bool
|
OomKillDisable bool
|
||||||
|
@ -75,6 +73,7 @@ type Info struct {
|
||||||
DefaultAddressPools []NetworkAddressPool `json:",omitempty"`
|
DefaultAddressPools []NetworkAddressPool `json:",omitempty"`
|
||||||
FirewallBackend *FirewallInfo `json:"FirewallBackend,omitempty"`
|
FirewallBackend *FirewallInfo `json:"FirewallBackend,omitempty"`
|
||||||
CDISpecDirs []string
|
CDISpecDirs []string
|
||||||
|
DiscoveredDevices []DeviceInfo `json:",omitempty"`
|
||||||
|
|
||||||
Containerd *ContainerdInfo `json:",omitempty"`
|
Containerd *ContainerdInfo `json:",omitempty"`
|
||||||
|
|
||||||
|
@ -160,3 +159,12 @@ type FirewallInfo struct {
|
||||||
// Info is a list of label/value pairs, containing information related to the firewall.
|
// Info is a list of label/value pairs, containing information related to the firewall.
|
||||||
Info [][2]string `json:"Info,omitempty"`
|
Info [][2]string `json:"Info,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeviceInfo represents a discoverable device from a device driver.
|
||||||
|
type DeviceInfo struct {
|
||||||
|
// Source indicates the origin device driver.
|
||||||
|
Source string `json:"Source"`
|
||||||
|
// ID is the unique identifier for the device.
|
||||||
|
// Example: CDI FQDN like "vendor.com/gpu=0", or other driver-specific device ID
|
||||||
|
ID string `json:"ID"`
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
||||||
|
|
||||||
var format string
|
var format string
|
||||||
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
||||||
parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3)
|
parseInLocation := !strings.ContainsAny(value, "zZ+") && strings.Count(value, "-") != 3
|
||||||
|
|
||||||
if strings.Contains(value, ".") {
|
if strings.Contains(value, ".") {
|
||||||
if parseInLocation {
|
if parseInLocation {
|
||||||
|
@ -105,23 +105,23 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
||||||
// since := time.Unix(seconds, nanoseconds)
|
// since := time.Unix(seconds, nanoseconds)
|
||||||
//
|
//
|
||||||
// returns seconds as defaultSeconds if value == ""
|
// returns seconds as defaultSeconds if value == ""
|
||||||
func ParseTimestamps(value string, defaultSeconds int64) (seconds int64, nanoseconds int64, err error) {
|
func ParseTimestamps(value string, defaultSeconds int64) (seconds int64, nanoseconds int64, _ error) {
|
||||||
if value == "" {
|
if value == "" {
|
||||||
return defaultSeconds, 0, nil
|
return defaultSeconds, 0, nil
|
||||||
}
|
}
|
||||||
return parseTimestamp(value)
|
return parseTimestamp(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTimestamp(value string) (sec int64, nsec int64, err error) {
|
func parseTimestamp(value string) (seconds int64, nanoseconds int64, _ error) {
|
||||||
s, n, ok := strings.Cut(value, ".")
|
s, n, ok := strings.Cut(value, ".")
|
||||||
sec, err = strconv.ParseInt(s, 10, 64)
|
sec, err := strconv.ParseInt(s, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sec, 0, err
|
return sec, 0, err
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
return sec, 0, nil
|
return sec, 0, nil
|
||||||
}
|
}
|
||||||
nsec, err = strconv.ParseInt(n, 10, 64)
|
nsec, err := strconv.ParseInt(n, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sec, nsec, err
|
return sec, nsec, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package types // import "github.com/docker/docker/api/types"
|
package types // import "github.com/docker/docker/api/types"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"github.com/docker/docker/api/types/build"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/filters"
|
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
|
@ -24,7 +22,7 @@ type Ping struct {
|
||||||
APIVersion string
|
APIVersion string
|
||||||
OSType string
|
OSType string
|
||||||
Experimental bool
|
Experimental bool
|
||||||
BuilderVersion BuilderVersion
|
BuilderVersion build.BuilderVersion
|
||||||
|
|
||||||
// SwarmStatus provides information about the current swarm status of the
|
// SwarmStatus provides information about the current swarm status of the
|
||||||
// engine, obtained from the "Swarm" header in the API response.
|
// engine, obtained from the "Swarm" header in the API response.
|
||||||
|
@ -91,41 +89,10 @@ type DiskUsage struct {
|
||||||
Images []*image.Summary
|
Images []*image.Summary
|
||||||
Containers []*container.Summary
|
Containers []*container.Summary
|
||||||
Volumes []*volume.Volume
|
Volumes []*volume.Volume
|
||||||
BuildCache []*BuildCache
|
BuildCache []*build.CacheRecord
|
||||||
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
|
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildCachePruneReport contains the response for Engine API:
|
|
||||||
// POST "/build/prune"
|
|
||||||
type BuildCachePruneReport struct {
|
|
||||||
CachesDeleted []string
|
|
||||||
SpaceReclaimed uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecretCreateResponse contains the information returned to a client
|
|
||||||
// on the creation of a new secret.
|
|
||||||
type SecretCreateResponse struct {
|
|
||||||
// ID is the id of the created secret.
|
|
||||||
ID string
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecretListOptions holds parameters to list secrets
|
|
||||||
type SecretListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConfigCreateResponse contains the information returned to a client
|
|
||||||
// on the creation of a new config.
|
|
||||||
type ConfigCreateResponse struct {
|
|
||||||
// ID is the id of the created config.
|
|
||||||
ID string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConfigListOptions holds parameters to list configs
|
|
||||||
type ConfigListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushResult contains the tag, manifest digest, and manifest size from the
|
// PushResult contains the tag, manifest digest, and manifest size from the
|
||||||
// push. It's used to signal this information to the trust code in the client
|
// push. It's used to signal this information to the trust code in the client
|
||||||
// so it can sign the manifest if necessary.
|
// so it can sign the manifest if necessary.
|
||||||
|
@ -134,46 +101,3 @@ type PushResult struct {
|
||||||
Digest string
|
Digest string
|
||||||
Size int
|
Size int
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildResult contains the image id of a successful build
|
|
||||||
type BuildResult struct {
|
|
||||||
ID string
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildCache contains information about a build cache record.
|
|
||||||
type BuildCache struct {
|
|
||||||
// ID is the unique ID of the build cache record.
|
|
||||||
ID string
|
|
||||||
// Parent is the ID of the parent build cache record.
|
|
||||||
//
|
|
||||||
// Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead.
|
|
||||||
Parent string `json:"Parent,omitempty"`
|
|
||||||
// Parents is the list of parent build cache record IDs.
|
|
||||||
Parents []string `json:" Parents,omitempty"`
|
|
||||||
// Type is the cache record type.
|
|
||||||
Type string
|
|
||||||
// Description is a description of the build-step that produced the build cache.
|
|
||||||
Description string
|
|
||||||
// InUse indicates if the build cache is in use.
|
|
||||||
InUse bool
|
|
||||||
// Shared indicates if the build cache is shared.
|
|
||||||
Shared bool
|
|
||||||
// Size is the amount of disk space used by the build cache (in bytes).
|
|
||||||
Size int64
|
|
||||||
// CreatedAt is the date and time at which the build cache was created.
|
|
||||||
CreatedAt time.Time
|
|
||||||
// LastUsedAt is the date and time at which the build cache was last used.
|
|
||||||
LastUsedAt *time.Time
|
|
||||||
UsageCount int
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildCachePruneOptions hold parameters to prune the build cache
|
|
||||||
type BuildCachePruneOptions struct {
|
|
||||||
All bool
|
|
||||||
ReservedSpace int64
|
|
||||||
MaxUsedSpace int64
|
|
||||||
MinFreeSpace int64
|
|
||||||
Filters filters.Args
|
|
||||||
|
|
||||||
KeepStorage int64 // Deprecated: deprecated in API 1.48.
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,10 +3,12 @@ package types
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/common"
|
"github.com/docker/docker/api/types/common"
|
||||||
"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/image"
|
||||||
"github.com/docker/docker/api/types/storage"
|
"github.com/docker/docker/api/types/storage"
|
||||||
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IDResponse Response to an API call that returns just an Id.
|
// IDResponse Response to an API call that returns just an Id.
|
||||||
|
@ -113,3 +115,127 @@ type ImageInspect = image.InspectResponse
|
||||||
//
|
//
|
||||||
// Deprecated: moved to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
|
// Deprecated: moved to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
|
||||||
type RequestPrivilegeFunc func(context.Context) (string, error)
|
type RequestPrivilegeFunc func(context.Context) (string, error)
|
||||||
|
|
||||||
|
// SecretCreateResponse contains the information returned to a client
|
||||||
|
// on the creation of a new secret.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.SecretCreateResponse].
|
||||||
|
type SecretCreateResponse = swarm.SecretCreateResponse
|
||||||
|
|
||||||
|
// SecretListOptions holds parameters to list secrets
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.SecretListOptions].
|
||||||
|
type SecretListOptions = swarm.SecretListOptions
|
||||||
|
|
||||||
|
// ConfigCreateResponse contains the information returned to a client
|
||||||
|
// on the creation of a new config.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ConfigCreateResponse].
|
||||||
|
type ConfigCreateResponse = swarm.ConfigCreateResponse
|
||||||
|
|
||||||
|
// ConfigListOptions holds parameters to list configs
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ConfigListOptions].
|
||||||
|
type ConfigListOptions = swarm.ConfigListOptions
|
||||||
|
|
||||||
|
// NodeListOptions holds parameters to list nodes with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.NodeListOptions].
|
||||||
|
type NodeListOptions = swarm.NodeListOptions
|
||||||
|
|
||||||
|
// NodeRemoveOptions holds parameters to remove nodes with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.NodeRemoveOptions].
|
||||||
|
type NodeRemoveOptions = swarm.NodeRemoveOptions
|
||||||
|
|
||||||
|
// TaskListOptions holds parameters to list tasks with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.TaskListOptions].
|
||||||
|
type TaskListOptions = swarm.TaskListOptions
|
||||||
|
|
||||||
|
// ServiceCreateOptions contains the options to use when creating a service.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceCreateOptions].
|
||||||
|
type ServiceCreateOptions = swarm.ServiceCreateOptions
|
||||||
|
|
||||||
|
// ServiceUpdateOptions contains the options to be used for updating services.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceCreateOptions].
|
||||||
|
type ServiceUpdateOptions = swarm.ServiceUpdateOptions
|
||||||
|
|
||||||
|
const (
|
||||||
|
RegistryAuthFromSpec = swarm.RegistryAuthFromSpec // Deprecated: use [swarm.RegistryAuthFromSpec].
|
||||||
|
RegistryAuthFromPreviousSpec = swarm.RegistryAuthFromPreviousSpec // Deprecated: use [swarm.RegistryAuthFromPreviousSpec].
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServiceListOptions holds parameters to list services with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceListOptions].
|
||||||
|
type ServiceListOptions = swarm.ServiceListOptions
|
||||||
|
|
||||||
|
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||||
|
// operation.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceInspectOptions].
|
||||||
|
type ServiceInspectOptions = swarm.ServiceInspectOptions
|
||||||
|
|
||||||
|
// SwarmUnlockKeyResponse contains the response for Engine API:
|
||||||
|
// GET /swarm/unlockkey
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.UnlockKeyResponse].
|
||||||
|
type SwarmUnlockKeyResponse = swarm.UnlockKeyResponse
|
||||||
|
|
||||||
|
// BuildCache contains information about a build cache record.
|
||||||
|
//
|
||||||
|
// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead.
|
||||||
|
type BuildCache = build.CacheRecord
|
||||||
|
|
||||||
|
// BuildCachePruneOptions hold parameters to prune the build cache
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.CachePruneOptions].
|
||||||
|
type BuildCachePruneOptions = build.CachePruneOptions
|
||||||
|
|
||||||
|
// BuildCachePruneReport contains the response for Engine API:
|
||||||
|
// POST "/build/prune"
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.CachePruneReport].
|
||||||
|
type BuildCachePruneReport = build.CachePruneReport
|
||||||
|
|
||||||
|
// BuildResult contains the image id of a successful build/
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.Result].
|
||||||
|
type BuildResult = build.Result
|
||||||
|
|
||||||
|
// ImageBuildOptions holds the information
|
||||||
|
// necessary to build images.
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.ImageBuildOptions].
|
||||||
|
type ImageBuildOptions = build.ImageBuildOptions
|
||||||
|
|
||||||
|
// ImageBuildOutput defines configuration for exporting a build result
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.ImageBuildOutput].
|
||||||
|
type ImageBuildOutput = build.ImageBuildOutput
|
||||||
|
|
||||||
|
// ImageBuildResponse holds information
|
||||||
|
// returned by a server after building
|
||||||
|
// an image.
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.ImageBuildResponse].
|
||||||
|
type ImageBuildResponse = build.ImageBuildResponse
|
||||||
|
|
||||||
|
// BuilderVersion sets the version of underlying builder to use
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.BuilderVersion].
|
||||||
|
type BuilderVersion = build.BuilderVersion
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BuilderV1 is the first generation builder in docker daemon
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.BuilderV1].
|
||||||
|
BuilderV1 = build.BuilderV1
|
||||||
|
// BuilderBuildKit is builder based on moby/buildkit project
|
||||||
|
//
|
||||||
|
// Deprecated: use [build.BuilderBuildKit].
|
||||||
|
BuilderBuildKit = build.BuilderBuildKit
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package volume
|
||||||
|
|
||||||
|
// DiskUsage contains disk usage for volumes.
|
||||||
|
type DiskUsage struct {
|
||||||
|
TotalSize int64
|
||||||
|
Reclaimable int64
|
||||||
|
Items []*Volume
|
||||||
|
}
|
|
@ -6,13 +6,13 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BuildCachePrune requests the daemon to delete unused cache data
|
// BuildCachePrune requests the daemon to delete unused cache data
|
||||||
func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
|
func (cli *Client) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
|
||||||
if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil {
|
if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePru
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
report := types.BuildCachePruneReport{}
|
report := build.CachePruneReport{}
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&report); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&report); err != nil {
|
||||||
return nil, errors.Wrap(err, "error retrieving disk usage")
|
return nil, errors.Wrap(err, "error retrieving disk usage")
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
@ -109,8 +110,8 @@ type DistributionAPIClient interface {
|
||||||
|
|
||||||
// ImageAPIClient defines API client methods for the images
|
// ImageAPIClient defines API client methods for the images
|
||||||
type ImageAPIClient interface {
|
type ImageAPIClient interface {
|
||||||
ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
|
ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error)
|
||||||
BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error)
|
BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error)
|
||||||
BuildCancel(ctx context.Context, id string) error
|
BuildCancel(ctx context.Context, id string) error
|
||||||
ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error)
|
ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error)
|
||||||
ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
||||||
|
@ -154,8 +155,8 @@ type NetworkAPIClient interface {
|
||||||
// NodeAPIClient defines API client methods for the nodes
|
// NodeAPIClient defines API client methods for the nodes
|
||||||
type NodeAPIClient interface {
|
type NodeAPIClient interface {
|
||||||
NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
|
NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
|
||||||
NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
|
NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
|
NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error
|
||||||
NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,22 +176,22 @@ type PluginAPIClient interface {
|
||||||
|
|
||||||
// ServiceAPIClient defines API client methods for the services
|
// ServiceAPIClient defines API client methods for the services
|
||||||
type ServiceAPIClient interface {
|
type ServiceAPIClient interface {
|
||||||
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
|
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
|
||||||
ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
|
||||||
ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
|
ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
ServiceRemove(ctx context.Context, serviceID string) error
|
ServiceRemove(ctx context.Context, serviceID string) error
|
||||||
ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
|
ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
|
||||||
TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
|
TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
|
||||||
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
|
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
|
||||||
TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
|
TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SwarmAPIClient defines API client methods for the swarm
|
// SwarmAPIClient defines API client methods for the swarm
|
||||||
type SwarmAPIClient interface {
|
type SwarmAPIClient interface {
|
||||||
SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
|
SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
|
||||||
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
||||||
SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
|
SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error)
|
||||||
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
||||||
SwarmLeave(ctx context.Context, force bool) error
|
SwarmLeave(ctx context.Context, force bool) error
|
||||||
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
||||||
|
@ -219,8 +220,8 @@ type VolumeAPIClient interface {
|
||||||
|
|
||||||
// SecretAPIClient defines API client methods for secrets
|
// SecretAPIClient defines API client methods for secrets
|
||||||
type SecretAPIClient interface {
|
type SecretAPIClient interface {
|
||||||
SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error)
|
SecretList(ctx context.Context, options swarm.SecretListOptions) ([]swarm.Secret, error)
|
||||||
SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error)
|
SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error)
|
||||||
SecretRemove(ctx context.Context, id string) error
|
SecretRemove(ctx context.Context, id string) error
|
||||||
SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
|
SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
|
||||||
SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
|
SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
|
||||||
|
@ -228,8 +229,8 @@ type SecretAPIClient interface {
|
||||||
|
|
||||||
// ConfigAPIClient defines API client methods for configs
|
// ConfigAPIClient defines API client methods for configs
|
||||||
type ConfigAPIClient interface {
|
type ConfigAPIClient interface {
|
||||||
ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error)
|
ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error)
|
||||||
ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error)
|
ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)
|
||||||
ConfigRemove(ctx context.Context, id string) error
|
ConfigRemove(ctx context.Context, id string) error
|
||||||
ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
|
ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
|
||||||
ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
|
ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
|
||||||
|
|
|
@ -4,13 +4,12 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigCreate creates a new config.
|
// ConfigCreate creates a new config.
|
||||||
func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
|
func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error) {
|
||||||
var response types.ConfigCreateResponse
|
var response swarm.ConfigCreateResponse
|
||||||
if err := cli.NewVersionError(ctx, "1.30", "config create"); err != nil {
|
if err := cli.NewVersionError(ctx, "1.30", "config create"); err != nil {
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,12 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigList returns the list of configs.
|
// ConfigList returns the list of configs.
|
||||||
func (cli *Client) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
|
func (cli *Client) ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
|
||||||
if err := cli.NewVersionError(ctx, "1.30", "config list"); err != nil {
|
if err := cli.NewVersionError(ctx, "1.30", "config list"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,11 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
|
"github.com/containerd/errdefs/pkg/errhttp"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// errConnectionFailed implements an error returned when connection failed.
|
// errConnectionFailed implements an error returned when connection failed.
|
||||||
|
@ -48,9 +50,11 @@ func connectionFailed(host string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsErrNotFound returns true if the error is a NotFound error, which is returned
|
// IsErrNotFound returns true if the error is a NotFound error, which is returned
|
||||||
// by the API when some object is not found. It is an alias for [errdefs.IsNotFound].
|
// by the API when some object is not found. It is an alias for [cerrdefs.IsNotFound].
|
||||||
|
//
|
||||||
|
// Deprecated: use [cerrdefs.IsNotFound] instead.
|
||||||
func IsErrNotFound(err error) bool {
|
func IsErrNotFound(err error) bool {
|
||||||
return errdefs.IsNotFound(err)
|
return cerrdefs.IsNotFound(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
type objectNotFoundError struct {
|
type objectNotFoundError struct {
|
||||||
|
@ -83,3 +87,43 @@ func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature str
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type httpError struct {
|
||||||
|
err error
|
||||||
|
errdef error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *httpError) Error() string {
|
||||||
|
return e.err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *httpError) Unwrap() error {
|
||||||
|
return e.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *httpError) Is(target error) bool {
|
||||||
|
return errors.Is(e.errdef, target)
|
||||||
|
}
|
||||||
|
|
||||||
|
// httpErrorFromStatusCode creates an errdef error, based on the provided HTTP status-code
|
||||||
|
func httpErrorFromStatusCode(err error, statusCode int) error {
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
base := errhttp.ToNative(statusCode)
|
||||||
|
if base != nil {
|
||||||
|
return &httpError{err: err, errdef: base}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case statusCode >= http.StatusOK && statusCode < http.StatusBadRequest:
|
||||||
|
// it's a client error
|
||||||
|
return err
|
||||||
|
case statusCode >= http.StatusBadRequest && statusCode < http.StatusInternalServerError:
|
||||||
|
return &httpError{err: err, errdef: cerrdefs.ErrInvalidArgument}
|
||||||
|
case statusCode >= http.StatusInternalServerError && statusCode < 600:
|
||||||
|
return &httpError{err: err, errdef: cerrdefs.ErrInternal}
|
||||||
|
default:
|
||||||
|
return &httpError{err: err, errdef: cerrdefs.ErrUnknown}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
)
|
)
|
||||||
|
@ -18,15 +18,15 @@ import (
|
||||||
// ImageBuild sends a request to the daemon to build images.
|
// 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
|
// The Body in the response implements an io.ReadCloser and it's up to the caller to
|
||||||
// close it.
|
// close it.
|
||||||
func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
|
func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) {
|
||||||
query, err := cli.imageBuildOptionsToQuery(ctx, options)
|
query, err := cli.imageBuildOptionsToQuery(ctx, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ImageBuildResponse{}, err
|
return build.ImageBuildResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := json.Marshal(options.AuthConfigs)
|
buf, err := json.Marshal(options.AuthConfigs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ImageBuildResponse{}, err
|
return build.ImageBuildResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
|
@ -35,16 +35,16 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio
|
||||||
|
|
||||||
resp, err := cli.postRaw(ctx, "/build", query, buildContext, headers)
|
resp, err := cli.postRaw(ctx, "/build", query, buildContext, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ImageBuildResponse{}, err
|
return build.ImageBuildResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return types.ImageBuildResponse{
|
return build.ImageBuildResponse{
|
||||||
Body: resp.Body,
|
Body: resp.Body,
|
||||||
OSType: getDockerOS(resp.Header.Get("Server")),
|
OSType: getDockerOS(resp.Header.Get("Server")),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options types.ImageBuildOptions) (url.Values, error) {
|
func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options build.ImageBuildOptions) (url.Values, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if len(options.Tags) > 0 {
|
if len(options.Tags) > 0 {
|
||||||
query["t"] = options.Tags
|
query["t"] = options.Tags
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImagePull requests the docker host to pull an image from a remote registry.
|
// ImagePull requests the docker host to pull an image from a remote registry.
|
||||||
|
@ -35,7 +35,7 @@ func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.P
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
|
resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
return nil, privilegeErr
|
return nil, privilegeErr
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImagePush requests the docker host to push an image to a remote registry.
|
// ImagePush requests the docker host to push an image to a remote registry.
|
||||||
|
@ -52,7 +52,7 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options image.Pu
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := cli.tryImagePush(ctx, ref.Name(), query, options.RegistryAuth)
|
resp, err := cli.tryImagePush(ctx, ref.Name(), query, options.RegistryAuth)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
return nil, privilegeErr
|
return nil, privilegeErr
|
||||||
|
|
|
@ -19,6 +19,14 @@ func (cli *Client) ImageRemove(ctx context.Context, imageID string, options imag
|
||||||
query.Set("noprune", "1")
|
query.Set("noprune", "1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(options.Platforms) > 0 {
|
||||||
|
p, err := encodePlatforms(options.Platforms...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
query["platforms"] = p
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := cli.delete(ctx, "/images/"+imageID, query, nil)
|
resp, err := cli.delete(ctx, "/images/"+imageID, query, nil)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImageSearch makes the docker host search by a term in a remote registry.
|
// ImageSearch makes the docker host search by a term in a remote registry.
|
||||||
|
@ -32,7 +32,7 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options registr
|
||||||
|
|
||||||
resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth)
|
resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
return results, privilegeErr
|
return results, privilegeErr
|
||||||
|
|
|
@ -5,13 +5,12 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeList returns the list of nodes.
|
// NodeList returns the list of nodes.
|
||||||
func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
func (cli *Client) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
|
|
@ -4,11 +4,11 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeRemove removes a Node.
|
// NodeRemove removes a Node.
|
||||||
func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error {
|
func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error {
|
||||||
nodeID, err := trimID("node", nodeID)
|
nodeID, err := trimID("node", nodeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/build"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ func parsePingResponse(cli *Client, resp *http.Response) (types.Ping, error) {
|
||||||
ping.Experimental = true
|
ping.Experimental = true
|
||||||
}
|
}
|
||||||
if bv := resp.Header.Get("Builder-Version"); bv != "" {
|
if bv := resp.Header.Get("Builder-Version"); bv != "" {
|
||||||
ping.BuilderVersion = types.BuilderVersion(bv)
|
ping.BuilderVersion = build.BuilderVersion(bv)
|
||||||
}
|
}
|
||||||
if si := resp.Header.Get("Swarm"); si != "" {
|
if si := resp.Header.Get("Swarm"); si != "" {
|
||||||
state, role, _ := strings.Cut(si, "/")
|
state, role, _ := strings.Cut(si, "/")
|
||||||
|
|
|
@ -7,15 +7,15 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PluginInstall installs a plugin
|
// PluginInstall installs a plugin
|
||||||
func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) {
|
func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (_ io.ReadCloser, retErr error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil {
|
if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil {
|
||||||
return nil, errors.Wrap(err, "invalid remote reference")
|
return nil, errors.Wrap(err, "invalid remote reference")
|
||||||
|
@ -45,7 +45,7 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if retErr != nil {
|
||||||
delResp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil)
|
delResp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil)
|
||||||
ensureReaderClosed(delResp)
|
ensureReaderClosed(delResp)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, privileg
|
||||||
|
|
||||||
func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, options types.PluginInstallOptions) (types.PluginPrivileges, error) {
|
func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, options types.PluginInstallOptions) (types.PluginPrivileges, error) {
|
||||||
resp, err := cli.tryPluginPrivileges(ctx, query, options.RegistryAuth)
|
resp, err := cli.tryPluginPrivileges(ctx, query, options.RegistryAuth)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
// todo: do inspect before to check existing name before checking privileges
|
// todo: do inspect before to check existing name before checking privileges
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -116,10 +115,8 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
|
||||||
|
|
||||||
resp, err := cli.doRequest(req)
|
resp, err := cli.doRequest(req)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, context.Canceled):
|
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
|
||||||
return nil, errdefs.Cancelled(err)
|
return nil, err
|
||||||
case errors.Is(err, context.DeadlineExceeded):
|
|
||||||
return nil, errdefs.Deadline(err)
|
|
||||||
case err == nil:
|
case err == nil:
|
||||||
return resp, cli.checkResponseErr(resp)
|
return resp, cli.checkResponseErr(resp)
|
||||||
default:
|
default:
|
||||||
|
@ -195,11 +192,11 @@ func (cli *Client) checkResponseErr(serverResp *http.Response) (retErr error) {
|
||||||
if serverResp == nil {
|
if serverResp == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if serverResp.StatusCode >= 200 && serverResp.StatusCode < 400 {
|
if serverResp.StatusCode >= http.StatusOK && serverResp.StatusCode < http.StatusBadRequest {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
retErr = errdefs.FromStatusCode(retErr, serverResp.StatusCode)
|
retErr = httpErrorFromStatusCode(retErr, serverResp.StatusCode)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var body []byte
|
var body []byte
|
||||||
|
|
|
@ -4,22 +4,21 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SecretCreate creates a new secret.
|
// SecretCreate creates a new secret.
|
||||||
func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) {
|
func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error) {
|
||||||
if err := cli.NewVersionError(ctx, "1.25", "secret create"); err != nil {
|
if err := cli.NewVersionError(ctx, "1.25", "secret create"); err != nil {
|
||||||
return types.SecretCreateResponse{}, err
|
return swarm.SecretCreateResponse{}, err
|
||||||
}
|
}
|
||||||
resp, err := cli.post(ctx, "/secrets/create", nil, secret, nil)
|
resp, err := cli.post(ctx, "/secrets/create", nil, secret, nil)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.SecretCreateResponse{}, err
|
return swarm.SecretCreateResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var response types.SecretCreateResponse
|
var response swarm.SecretCreateResponse
|
||||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,12 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SecretList returns the list of secrets.
|
// SecretList returns the list of secrets.
|
||||||
func (cli *Client) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
|
func (cli *Client) SecretList(ctx context.Context, options swarm.SecretListOptions) ([]swarm.Secret, error) {
|
||||||
if err := cli.NewVersionError(ctx, "1.25", "secret list"); err != nil {
|
if err := cli.NewVersionError(ctx, "1.25", "secret list"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
|
@ -17,7 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceCreate creates a new service.
|
// ServiceCreate creates a new service.
|
||||||
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
|
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
|
||||||
var response swarm.ServiceCreateResponse
|
var response swarm.ServiceCreateResponse
|
||||||
|
|
||||||
// Make sure we negotiated (if the client is configured to do so),
|
// Make sure we negotiated (if the client is configured to do so),
|
||||||
|
|
|
@ -8,12 +8,11 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceInspectWithRaw returns the service information and the raw data.
|
// ServiceInspectWithRaw returns the service information and the raw data.
|
||||||
func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
serviceID, err := trimID("service", serviceID)
|
serviceID, err := trimID("service", serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return swarm.Service{}, nil, err
|
return swarm.Service{}, nil, err
|
||||||
|
|
|
@ -5,13 +5,12 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceList returns the list of services.
|
// ServiceList returns the list of services.
|
||||||
func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
func (cli *Client) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
|
@ -15,7 +14,7 @@ import (
|
||||||
// ServiceUpdate updates a Service. The version number is required to avoid conflicting writes.
|
// ServiceUpdate updates a Service. The version number is required to avoid conflicting writes.
|
||||||
// It should be the value as set *before* the update. You can find this value in the Meta field
|
// It should be the value as set *before* the update. You can find this value in the Meta field
|
||||||
// of swarm.Service, which can be found using ServiceInspectWithRaw.
|
// of swarm.Service, which can be found using ServiceInspectWithRaw.
|
||||||
func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
serviceID, err := trimID("service", serviceID)
|
serviceID, err := trimID("service", serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return swarm.ServiceUpdateResponse{}, err
|
return swarm.ServiceUpdateResponse{}, err
|
||||||
|
|
|
@ -4,18 +4,18 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmGetUnlockKey retrieves the swarm's unlock key.
|
// SwarmGetUnlockKey retrieves the swarm's unlock key.
|
||||||
func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
|
func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) {
|
||||||
resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil)
|
resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.SwarmUnlockKeyResponse{}, err
|
return swarm.UnlockKeyResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var response types.SwarmUnlockKeyResponse
|
var response swarm.UnlockKeyResponse
|
||||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,12 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TaskList returns the list of tasks.
|
// TaskList returns the list of tasks.
|
||||||
func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
func (cli *Client) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
"github.com/docker/docker/internal/lazyregexp"
|
"github.com/docker/docker/internal/lazyregexp"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
@ -90,7 +90,7 @@ func encodePlatforms(platform ...ocispec.Platform) ([]string, error) {
|
||||||
func encodePlatform(platform *ocispec.Platform) (string, error) {
|
func encodePlatform(platform *ocispec.Platform) (string, error) {
|
||||||
p, err := json.Marshal(platform)
|
p, err := json.Marshal(platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errdefs.InvalidParameter(fmt.Errorf("invalid platform: %v", err))
|
return "", fmt.Errorf("%w: invalid platform: %v", cerrdefs.ErrInvalidArgument, err)
|
||||||
}
|
}
|
||||||
return string(p), nil
|
return string(p), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
package errdefs
|
|
||||||
|
|
||||||
// ErrNotFound signals that the requested object doesn't exist
|
|
||||||
type ErrNotFound interface {
|
|
||||||
NotFound()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrInvalidParameter signals that the user input is invalid
|
|
||||||
type ErrInvalidParameter interface {
|
|
||||||
InvalidParameter()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrConflict signals that some internal state conflicts with the requested action and can't be performed.
|
|
||||||
// A change in state should be able to clear this error.
|
|
||||||
type ErrConflict interface {
|
|
||||||
Conflict()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action
|
|
||||||
type ErrUnauthorized interface {
|
|
||||||
Unauthorized()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrUnavailable signals that the requested action/subsystem is not available.
|
|
||||||
type ErrUnavailable interface {
|
|
||||||
Unavailable()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrForbidden signals that the requested action cannot be performed under any circumstances.
|
|
||||||
// When a ErrForbidden is returned, the caller should never retry the action.
|
|
||||||
type ErrForbidden interface {
|
|
||||||
Forbidden()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrSystem signals that some internal error occurred.
|
|
||||||
// An example of this would be a failed mount request.
|
|
||||||
type ErrSystem interface {
|
|
||||||
System()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrNotModified signals that an action can't be performed because it's already in the desired state
|
|
||||||
type ErrNotModified interface {
|
|
||||||
NotModified()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured.
|
|
||||||
type ErrNotImplemented interface {
|
|
||||||
NotImplemented()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrUnknown signals that the kind of error that occurred is not known.
|
|
||||||
type ErrUnknown interface {
|
|
||||||
Unknown()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrCancelled signals that the action was cancelled.
|
|
||||||
type ErrCancelled interface {
|
|
||||||
Cancelled()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrDeadline signals that the deadline was reached before the action completed.
|
|
||||||
type ErrDeadline interface {
|
|
||||||
DeadlineExceeded()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrDataLoss indicates that data was lost or there is data corruption.
|
|
||||||
type ErrDataLoss interface {
|
|
||||||
DataLoss()
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors.
|
|
||||||
// Errors that cross the package boundary should implement one (and only one) of these interfaces.
|
|
||||||
//
|
|
||||||
// Packages should not reference these interfaces directly, only implement them.
|
|
||||||
// To check if a particular error implements one of these interfaces, there are helper
|
|
||||||
// functions provided (e.g. `Is<SomeError>`) which can be used rather than asserting the interfaces directly.
|
|
||||||
// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`).
|
|
||||||
package errdefs // import "github.com/docker/docker/errdefs"
|
|
|
@ -1,305 +0,0 @@
|
||||||
package errdefs
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
type errNotFound struct{ error }
|
|
||||||
|
|
||||||
func (errNotFound) NotFound() {}
|
|
||||||
|
|
||||||
func (e errNotFound) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errNotFound) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotFound creates an [ErrNotFound] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrNotFound],
|
|
||||||
func NotFound(err error) error {
|
|
||||||
if err == nil || IsNotFound(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errNotFound{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errInvalidParameter struct{ error }
|
|
||||||
|
|
||||||
func (errInvalidParameter) InvalidParameter() {}
|
|
||||||
|
|
||||||
func (e errInvalidParameter) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errInvalidParameter) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// InvalidParameter creates an [ErrInvalidParameter] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrInvalidParameter],
|
|
||||||
func InvalidParameter(err error) error {
|
|
||||||
if err == nil || IsInvalidParameter(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errInvalidParameter{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errConflict struct{ error }
|
|
||||||
|
|
||||||
func (errConflict) Conflict() {}
|
|
||||||
|
|
||||||
func (e errConflict) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errConflict) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Conflict creates an [ErrConflict] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrConflict],
|
|
||||||
func Conflict(err error) error {
|
|
||||||
if err == nil || IsConflict(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errConflict{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errUnauthorized struct{ error }
|
|
||||||
|
|
||||||
func (errUnauthorized) Unauthorized() {}
|
|
||||||
|
|
||||||
func (e errUnauthorized) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errUnauthorized) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unauthorized creates an [ErrUnauthorized] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrUnauthorized],
|
|
||||||
func Unauthorized(err error) error {
|
|
||||||
if err == nil || IsUnauthorized(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errUnauthorized{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errUnavailable struct{ error }
|
|
||||||
|
|
||||||
func (errUnavailable) Unavailable() {}
|
|
||||||
|
|
||||||
func (e errUnavailable) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errUnavailable) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unavailable creates an [ErrUnavailable] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrUnavailable],
|
|
||||||
func Unavailable(err error) error {
|
|
||||||
if err == nil || IsUnavailable(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errUnavailable{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errForbidden struct{ error }
|
|
||||||
|
|
||||||
func (errForbidden) Forbidden() {}
|
|
||||||
|
|
||||||
func (e errForbidden) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errForbidden) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Forbidden creates an [ErrForbidden] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrForbidden],
|
|
||||||
func Forbidden(err error) error {
|
|
||||||
if err == nil || IsForbidden(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errForbidden{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errSystem struct{ error }
|
|
||||||
|
|
||||||
func (errSystem) System() {}
|
|
||||||
|
|
||||||
func (e errSystem) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errSystem) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// System creates an [ErrSystem] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrSystem],
|
|
||||||
func System(err error) error {
|
|
||||||
if err == nil || IsSystem(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errSystem{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errNotModified struct{ error }
|
|
||||||
|
|
||||||
func (errNotModified) NotModified() {}
|
|
||||||
|
|
||||||
func (e errNotModified) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errNotModified) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotModified creates an [ErrNotModified] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [NotModified],
|
|
||||||
func NotModified(err error) error {
|
|
||||||
if err == nil || IsNotModified(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errNotModified{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errNotImplemented struct{ error }
|
|
||||||
|
|
||||||
func (errNotImplemented) NotImplemented() {}
|
|
||||||
|
|
||||||
func (e errNotImplemented) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errNotImplemented) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotImplemented creates an [ErrNotImplemented] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrNotImplemented],
|
|
||||||
func NotImplemented(err error) error {
|
|
||||||
if err == nil || IsNotImplemented(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errNotImplemented{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errUnknown struct{ error }
|
|
||||||
|
|
||||||
func (errUnknown) Unknown() {}
|
|
||||||
|
|
||||||
func (e errUnknown) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errUnknown) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unknown creates an [ErrUnknown] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrUnknown],
|
|
||||||
func Unknown(err error) error {
|
|
||||||
if err == nil || IsUnknown(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errUnknown{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errCancelled struct{ error }
|
|
||||||
|
|
||||||
func (errCancelled) Cancelled() {}
|
|
||||||
|
|
||||||
func (e errCancelled) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errCancelled) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancelled creates an [ErrCancelled] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrCancelled],
|
|
||||||
func Cancelled(err error) error {
|
|
||||||
if err == nil || IsCancelled(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errCancelled{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errDeadline struct{ error }
|
|
||||||
|
|
||||||
func (errDeadline) DeadlineExceeded() {}
|
|
||||||
|
|
||||||
func (e errDeadline) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errDeadline) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deadline creates an [ErrDeadline] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrDeadline],
|
|
||||||
func Deadline(err error) error {
|
|
||||||
if err == nil || IsDeadline(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errDeadline{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errDataLoss struct{ error }
|
|
||||||
|
|
||||||
func (errDataLoss) DataLoss() {}
|
|
||||||
|
|
||||||
func (e errDataLoss) Cause() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errDataLoss) Unwrap() error {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataLoss creates an [ErrDataLoss] error from the given error.
|
|
||||||
// It returns the error as-is if it is either nil (no error) or already implements
|
|
||||||
// [ErrDataLoss],
|
|
||||||
func DataLoss(err error) error {
|
|
||||||
if err == nil || IsDataLoss(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return errDataLoss{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FromContext returns the error class from the passed in context
|
|
||||||
func FromContext(ctx context.Context) error {
|
|
||||||
e := ctx.Err()
|
|
||||||
if e == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if e == context.Canceled {
|
|
||||||
return Cancelled(e)
|
|
||||||
}
|
|
||||||
if e == context.DeadlineExceeded {
|
|
||||||
return Deadline(e)
|
|
||||||
}
|
|
||||||
return Unknown(e)
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package errdefs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FromStatusCode creates an errdef error, based on the provided HTTP status-code
|
|
||||||
func FromStatusCode(err error, statusCode int) error {
|
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
switch statusCode {
|
|
||||||
case http.StatusNotFound:
|
|
||||||
return NotFound(err)
|
|
||||||
case http.StatusBadRequest:
|
|
||||||
return InvalidParameter(err)
|
|
||||||
case http.StatusConflict:
|
|
||||||
return Conflict(err)
|
|
||||||
case http.StatusUnauthorized:
|
|
||||||
return Unauthorized(err)
|
|
||||||
case http.StatusServiceUnavailable:
|
|
||||||
return Unavailable(err)
|
|
||||||
case http.StatusForbidden:
|
|
||||||
return Forbidden(err)
|
|
||||||
case http.StatusNotModified:
|
|
||||||
return NotModified(err)
|
|
||||||
case http.StatusNotImplemented:
|
|
||||||
return NotImplemented(err)
|
|
||||||
case http.StatusInternalServerError:
|
|
||||||
if IsCancelled(err) || IsSystem(err) || IsUnknown(err) || IsDataLoss(err) || IsDeadline(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return System(err)
|
|
||||||
default:
|
|
||||||
switch {
|
|
||||||
case statusCode >= 200 && statusCode < 400:
|
|
||||||
// it's a client error
|
|
||||||
return err
|
|
||||||
case statusCode >= 400 && statusCode < 500:
|
|
||||||
return InvalidParameter(err)
|
|
||||||
case statusCode >= 500 && statusCode < 600:
|
|
||||||
return System(err)
|
|
||||||
default:
|
|
||||||
return Unknown(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,123 +0,0 @@
|
||||||
package errdefs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type causer interface {
|
|
||||||
Cause() error
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapErr interface {
|
|
||||||
Unwrap() error
|
|
||||||
}
|
|
||||||
|
|
||||||
func getImplementer(err error) error {
|
|
||||||
switch e := err.(type) {
|
|
||||||
case
|
|
||||||
ErrNotFound,
|
|
||||||
ErrInvalidParameter,
|
|
||||||
ErrConflict,
|
|
||||||
ErrUnauthorized,
|
|
||||||
ErrUnavailable,
|
|
||||||
ErrForbidden,
|
|
||||||
ErrSystem,
|
|
||||||
ErrNotModified,
|
|
||||||
ErrNotImplemented,
|
|
||||||
ErrCancelled,
|
|
||||||
ErrDeadline,
|
|
||||||
ErrDataLoss,
|
|
||||||
ErrUnknown:
|
|
||||||
return err
|
|
||||||
case causer:
|
|
||||||
return getImplementer(e.Cause())
|
|
||||||
case wrapErr:
|
|
||||||
return getImplementer(e.Unwrap())
|
|
||||||
default:
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsNotFound returns if the passed in error is an [ErrNotFound],
|
|
||||||
func IsNotFound(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrNotFound)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsInvalidParameter returns if the passed in error is an [ErrInvalidParameter].
|
|
||||||
func IsInvalidParameter(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrInvalidParameter)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsConflict returns if the passed in error is an [ErrConflict].
|
|
||||||
func IsConflict(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrConflict)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsUnauthorized returns if the passed in error is an [ErrUnauthorized].
|
|
||||||
func IsUnauthorized(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrUnauthorized)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsUnavailable returns if the passed in error is an [ErrUnavailable].
|
|
||||||
func IsUnavailable(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrUnavailable)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsForbidden returns if the passed in error is an [ErrForbidden].
|
|
||||||
func IsForbidden(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrForbidden)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSystem returns if the passed in error is an [ErrSystem].
|
|
||||||
func IsSystem(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrSystem)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsNotModified returns if the passed in error is an [ErrNotModified].
|
|
||||||
func IsNotModified(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrNotModified)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsNotImplemented returns if the passed in error is an [ErrNotImplemented].
|
|
||||||
func IsNotImplemented(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrNotImplemented)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsUnknown returns if the passed in error is an [ErrUnknown].
|
|
||||||
func IsUnknown(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrUnknown)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsCancelled returns if the passed in error is an [ErrCancelled].
|
|
||||||
func IsCancelled(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrCancelled)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsDeadline returns if the passed in error is an [ErrDeadline].
|
|
||||||
func IsDeadline(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrDeadline)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsDataLoss returns if the passed in error is an [ErrDataLoss].
|
|
||||||
func IsDataLoss(err error) bool {
|
|
||||||
_, ok := getImplementer(err).(ErrDataLoss)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsContext returns if the passed in error is due to context cancellation or deadline exceeded.
|
|
||||||
func IsContext(err error) bool {
|
|
||||||
return errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)
|
|
||||||
}
|
|
|
@ -36,7 +36,7 @@ func (e *joinError) Error() string {
|
||||||
}
|
}
|
||||||
stringErrs := make([]string, 0, len(e.errs))
|
stringErrs := make([]string, 0, len(e.errs))
|
||||||
for _, subErr := range e.errs {
|
for _, subErr := range e.errs {
|
||||||
stringErrs = append(stringErrs, strings.Replace(subErr.Error(), "\n", "\n\t", -1))
|
stringErrs = append(stringErrs, strings.ReplaceAll(subErr.Error(), "\n", "\n\t"))
|
||||||
}
|
}
|
||||||
return "* " + strings.Join(stringErrs, "\n* ")
|
return "* " + strings.Join(stringErrs, "\n* ")
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func NewProgressReader(in io.ReadCloser, out Output, size int64, id, action stri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Reader) Read(buf []byte) (n int, err error) {
|
func (p *Reader) Read(buf []byte) (int, error) {
|
||||||
read, err := p.in.Read(buf)
|
read, err := p.in.Read(buf)
|
||||||
p.current += int64(read)
|
p.current += int64(read)
|
||||||
updateEvery := int64(1024 * 512) // 512kB
|
updateEvery := int64(1024 * 512) // 512kB
|
||||||
|
|
|
@ -91,12 +91,12 @@ func NewStdWriter(w io.Writer, t StdType) io.Writer {
|
||||||
// In other words: if `err` is non nil, it indicates a real underlying error.
|
// In other words: if `err` is non nil, it indicates a real underlying error.
|
||||||
//
|
//
|
||||||
// `written` will hold the total number of bytes written to `dstout` and `dsterr`.
|
// `written` will hold the total number of bytes written to `dstout` and `dsterr`.
|
||||||
func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) {
|
func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {
|
||||||
var (
|
var (
|
||||||
buf = make([]byte, startingBufLen)
|
buf = make([]byte, startingBufLen)
|
||||||
bufLen = len(buf)
|
bufLen = len(buf)
|
||||||
nr, nw int
|
nr, nw int
|
||||||
er, ew error
|
err error
|
||||||
out io.Writer
|
out io.Writer
|
||||||
frameSize int
|
frameSize int
|
||||||
)
|
)
|
||||||
|
@ -105,16 +105,16 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
|
||||||
// Make sure we have at least a full header
|
// Make sure we have at least a full header
|
||||||
for nr < stdWriterPrefixLen {
|
for nr < stdWriterPrefixLen {
|
||||||
var nr2 int
|
var nr2 int
|
||||||
nr2, er = src.Read(buf[nr:])
|
nr2, err = src.Read(buf[nr:])
|
||||||
nr += nr2
|
nr += nr2
|
||||||
if er == io.EOF {
|
if err == io.EOF {
|
||||||
if nr < stdWriterPrefixLen {
|
if nr < stdWriterPrefixLen {
|
||||||
return written, nil
|
return written, nil
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if er != nil {
|
if err != nil {
|
||||||
return 0, er
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,16 +151,16 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
|
||||||
// While the amount of bytes read is less than the size of the frame + header, we keep reading
|
// While the amount of bytes read is less than the size of the frame + header, we keep reading
|
||||||
for nr < frameSize+stdWriterPrefixLen {
|
for nr < frameSize+stdWriterPrefixLen {
|
||||||
var nr2 int
|
var nr2 int
|
||||||
nr2, er = src.Read(buf[nr:])
|
nr2, err = src.Read(buf[nr:])
|
||||||
nr += nr2
|
nr += nr2
|
||||||
if er == io.EOF {
|
if err == io.EOF {
|
||||||
if nr < frameSize+stdWriterPrefixLen {
|
if nr < frameSize+stdWriterPrefixLen {
|
||||||
return written, nil
|
return written, nil
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if er != nil {
|
if err != nil {
|
||||||
return 0, er
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,9 +171,9 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the retrieved frame (without header)
|
// Write the retrieved frame (without header)
|
||||||
nw, ew = out.Write(buf[stdWriterPrefixLen : frameSize+stdWriterPrefixLen])
|
nw, err = out.Write(buf[stdWriterPrefixLen : frameSize+stdWriterPrefixLen])
|
||||||
if ew != nil {
|
if err != nil {
|
||||||
return 0, ew
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the frame has not been fully written: error
|
// If the frame has not been fully written: error
|
||||||
|
|
|
@ -80,6 +80,7 @@ github.com/containerd/errdefs
|
||||||
# github.com/containerd/errdefs/pkg v0.3.0
|
# github.com/containerd/errdefs/pkg v0.3.0
|
||||||
## explicit; go 1.22
|
## explicit; go 1.22
|
||||||
github.com/containerd/errdefs/pkg/errgrpc
|
github.com/containerd/errdefs/pkg/errgrpc
|
||||||
|
github.com/containerd/errdefs/pkg/errhttp
|
||||||
github.com/containerd/errdefs/pkg/internal/cause
|
github.com/containerd/errdefs/pkg/internal/cause
|
||||||
github.com/containerd/errdefs/pkg/internal/types
|
github.com/containerd/errdefs/pkg/internal/types
|
||||||
# github.com/containerd/log v0.1.0
|
# github.com/containerd/log v0.1.0
|
||||||
|
@ -428,12 +429,13 @@ github.com/distribution/reference
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/distribution/registry/api/errcode
|
github.com/docker/distribution/registry/api/errcode
|
||||||
github.com/docker/distribution/registry/api/v2
|
github.com/docker/distribution/registry/api/v2
|
||||||
# github.com/docker/docker v28.1.1+incompatible
|
# github.com/docker/docker v28.2.2+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/docker/api
|
github.com/docker/docker/api
|
||||||
github.com/docker/docker/api/types
|
github.com/docker/docker/api/types
|
||||||
github.com/docker/docker/api/types/backend
|
github.com/docker/docker/api/types/backend
|
||||||
github.com/docker/docker/api/types/blkiodev
|
github.com/docker/docker/api/types/blkiodev
|
||||||
|
github.com/docker/docker/api/types/build
|
||||||
github.com/docker/docker/api/types/checkpoint
|
github.com/docker/docker/api/types/checkpoint
|
||||||
github.com/docker/docker/api/types/common
|
github.com/docker/docker/api/types/common
|
||||||
github.com/docker/docker/api/types/container
|
github.com/docker/docker/api/types/container
|
||||||
|
@ -452,7 +454,6 @@ github.com/docker/docker/api/types/time
|
||||||
github.com/docker/docker/api/types/versions
|
github.com/docker/docker/api/types/versions
|
||||||
github.com/docker/docker/api/types/volume
|
github.com/docker/docker/api/types/volume
|
||||||
github.com/docker/docker/client
|
github.com/docker/docker/client
|
||||||
github.com/docker/docker/errdefs
|
|
||||||
github.com/docker/docker/internal/lazyregexp
|
github.com/docker/docker/internal/lazyregexp
|
||||||
github.com/docker/docker/internal/multierror
|
github.com/docker/docker/internal/multierror
|
||||||
github.com/docker/docker/pkg/archive
|
github.com/docker/docker/pkg/archive
|
||||||
|
|
Loading…
Reference in New Issue