mirror of https://github.com/docker/cli.git
[28.x] vendor github.com/docker/docker v28.5.0-dev
update to latest API version Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
2aca682657
commit
d1c3c3d888
|
|
@ -1017,7 +1017,7 @@ func TestParseLabelfileVariables(t *testing.T) {
|
|||
func TestParseEntryPoint(t *testing.T) {
|
||||
config, _, _, err := parseRun([]string{"--entrypoint=anything", "cmd", "img"})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual([]string(config.Entrypoint), []string{"anything"}))
|
||||
assert.Check(t, is.DeepEqual(config.Entrypoint, []string{"anything"}))
|
||||
}
|
||||
|
||||
func TestValidateDevice(t *testing.T) {
|
||||
|
|
|
|||
11
vendor.mod
11
vendor.mod
|
|
@ -6,6 +6,15 @@ module github.com/docker/cli
|
|||
|
||||
go 1.23.0
|
||||
|
||||
replace (
|
||||
// FIXME(thaJeztah): trying https://github.com/moby/moby/pull/50475
|
||||
github.com/docker/docker => github.com/thaJeztah/docker v24.0.0-rc.1.0.20250828172021-7be0e68004c1+incompatible
|
||||
|
||||
// FIXME(thaJeztah): temporarily need to pin on commits, otherwise go modules won't resolve until these are tagged.
|
||||
github.com/moby/moby/api => github.com/moby/moby/api v1.52.0-alpha.1.0.20250828160303-620b93135e44 // master
|
||||
github.com/moby/moby/client => github.com/moby/moby/client v0.1.0-alpha.0.0.20250828160303-620b93135e44 // master
|
||||
)
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.2
|
||||
github.com/containerd/errdefs v1.0.0
|
||||
|
|
@ -85,6 +94,8 @@ require (
|
|||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/miekg/pkcs11 v1.1.1 // indirect
|
||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||
github.com/moby/moby/api v1.52.0-alpha.1 // indirect
|
||||
github.com/moby/moby/client v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/moby/sys/user v0.4.0 // indirect
|
||||
github.com/moby/sys/userns v0.1.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
|
|
|
|||
10
vendor.sum
10
vendor.sum
|
|
@ -57,8 +57,6 @@ github.com/docker/cli-docs-tool v0.10.0/go.mod h1:5EM5zPnT2E7yCLERZmrDA234Vwn09f
|
|||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
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/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible h1:a4+xSvQFFYl8eRsVWyL3lwz1JubDEO77m1ovj3lFiXo=
|
||||
github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+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/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
|
||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||
|
|
@ -172,6 +170,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N
|
|||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
|
||||
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
|
||||
github.com/moby/moby/api v1.52.0-alpha.1.0.20250828160303-620b93135e44 h1:IRrLHRXRytJYqYWMpPj8wnoLDJxO5g1M/XPwILPhAt0=
|
||||
github.com/moby/moby/api v1.52.0-alpha.1.0.20250828160303-620b93135e44/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok=
|
||||
github.com/moby/moby/client v0.1.0-alpha.0.0.20250828160303-620b93135e44 h1:m7Rbw9nK324SJWvYc9ywPb+3X8tVd7NZB1kUs3t10UM=
|
||||
github.com/moby/moby/client v0.1.0-alpha.0.0.20250828160303-620b93135e44/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w=
|
||||
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
|
||||
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||
github.com/moby/swarmkit/v2 v2.0.0 h1:jkWQKQaJ4ltA61/mC9UdPe1McLma55RUcacTO+pPweY=
|
||||
|
|
@ -275,6 +277,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/thaJeztah/docker v24.0.0-rc.1.0.20250828172021-7be0e68004c1+incompatible h1:r2CEdrhGXC0Bu/siWlInKGGJBoy+V1U9kqRVmSDfgy0=
|
||||
github.com/thaJeztah/docker v24.0.0-rc.1.0.20250828172021-7be0e68004c1+incompatible/go.mod h1:eZ6Ef2GDr/8h8se23uenzFTrBHwc9jBEEnfrxqOb0Ss=
|
||||
github.com/theupdateframework/notary v0.7.1-0.20210315103452-bf96a202a09a h1:tlJ7tGUHvcvL1v3yR6NcCc9nOqh2L+CG6HWrYQtwzQ0=
|
||||
github.com/theupdateframework/notary v0.7.1-0.20210315103452-bf96a202a09a/go.mod h1:Y94A6rPp2OwNfP/7vmf8O2xx2IykP8pPXQ1DLouGnEw=
|
||||
github.com/tonistiigi/go-rosetta v0.0.0-20220804170347-3f4430f2d346 h1:TvtdmeYsYEij78hS4oxnwikoiLdIrgav3BA+CbhaDAI=
|
||||
|
|
@ -416,5 +420,7 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|||
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
||||
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
|
||||
k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk=
|
||||
pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
|
||||
tags.cncf.io/container-device-interface v0.8.0 h1:8bCFo/g9WODjWx3m6EYl3GfUG31eKJbaggyBDxEldRc=
|
||||
tags.cncf.io/container-device-interface v0.8.0/go.mod h1:Apb7N4VdILW0EVdEMRYXIDVRZfNJZ+kmEUss2kRRQ6Y=
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/common"
|
||||
"github.com/moby/moby/api/types/plugin"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// NewHijackedResponse initializes a [HijackedResponse] type.
|
||||
func NewHijackedResponse(conn net.Conn, mediaType string) client.HijackedResponse {
|
||||
return client.NewHijackedResponse(conn, mediaType)
|
||||
}
|
||||
|
||||
// HijackedResponse holds connection information for a hijacked request.
|
||||
type HijackedResponse = client.HijackedResponse
|
||||
|
||||
// CloseWriter is an interface that implements structs
|
||||
// that close input streams to prevent from writing.
|
||||
type CloseWriter = client.CloseWriter
|
||||
|
||||
// PluginRemoveOptions holds parameters to remove plugins.
|
||||
type PluginRemoveOptions = client.PluginRemoveOptions
|
||||
|
||||
// PluginEnableOptions holds parameters to enable plugins.
|
||||
type PluginEnableOptions = client.PluginEnableOptions
|
||||
|
||||
// PluginDisableOptions holds parameters to disable plugins.
|
||||
type PluginDisableOptions = client.PluginDisableOptions
|
||||
|
||||
// PluginInstallOptions holds parameters to install a plugin.
|
||||
type PluginInstallOptions = client.PluginInstallOptions
|
||||
|
||||
// PluginCreateOptions hold all options to plugin create.
|
||||
type PluginCreateOptions = client.PluginCreateOptions
|
||||
|
||||
// ErrorResponse Represents an error.
|
||||
type ErrorResponse = common.ErrorResponse
|
||||
|
||||
// Plugin A plugin for the Engine API
|
||||
type Plugin = plugin.Plugin
|
||||
|
||||
// PluginConfig The config of a plugin.
|
||||
type PluginConfig = plugin.Config
|
||||
|
||||
// PluginConfigArgs plugin config args
|
||||
type PluginConfigArgs = plugin.Args
|
||||
|
||||
// PluginConfigInterface The interface between Docker and the plugin
|
||||
type PluginConfigInterface = plugin.Interface
|
||||
|
||||
// PluginConfigLinux plugin config linux
|
||||
type PluginConfigLinux = plugin.LinuxConfig
|
||||
|
||||
// PluginConfigNetwork plugin config network
|
||||
type PluginConfigNetwork = plugin.NetworkConfig
|
||||
|
||||
// PluginConfigRootfs plugin config rootfs
|
||||
type PluginConfigRootfs = plugin.RootFS
|
||||
|
||||
// PluginConfigUser plugin config user
|
||||
type PluginConfigUser = plugin.User
|
||||
|
||||
// PluginSettings Settings that can be modified by users.
|
||||
type PluginSettings = plugin.Settings
|
||||
|
||||
// PluginDevice plugin device
|
||||
type PluginDevice = plugin.Device
|
||||
|
||||
// PluginEnv plugin env
|
||||
type PluginEnv = plugin.Env
|
||||
|
||||
// PluginInterfaceType plugin interface type
|
||||
type PluginInterfaceType = plugin.CapabilityID
|
||||
|
||||
// PluginMount plugin mount
|
||||
type PluginMount = plugin.Mount
|
||||
|
||||
// PluginsListResponse contains the response for the Engine API
|
||||
type PluginsListResponse = plugin.ListResponse
|
||||
|
||||
// PluginPrivilege describes a permission the user has to accept
|
||||
// upon installing a plugin.
|
||||
type PluginPrivilege = plugin.Privilege
|
||||
|
||||
// PluginPrivileges is a list of PluginPrivilege
|
||||
type PluginPrivileges = plugin.Privileges
|
||||
|
||||
const (
|
||||
// MediaTypeRawStream is vendor specific MIME-Type set for raw TTY streams
|
||||
MediaTypeRawStream = types.MediaTypeRawStream
|
||||
|
||||
// MediaTypeMultiplexedStream is vendor specific MIME-Type set for stdin/stdout/stderr multiplexed streams
|
||||
MediaTypeMultiplexedStream = types.MediaTypeMultiplexedStream
|
||||
)
|
||||
|
||||
// Ping contains response of Engine API:
|
||||
// GET "/_ping"
|
||||
type Ping = types.Ping
|
||||
|
||||
// ComponentVersion describes the version information for a specific component.
|
||||
type ComponentVersion = types.ComponentVersion
|
||||
|
||||
// Version contains response of Engine API:
|
||||
// GET "/version"
|
||||
type Version = types.Version
|
||||
|
||||
// DiskUsageObject represents an object type used for disk usage query filtering.
|
||||
type DiskUsageObject = system.DiskUsageObject
|
||||
|
||||
const (
|
||||
// ContainerObject represents a container DiskUsageObject.
|
||||
ContainerObject = system.ContainerObject
|
||||
// ImageObject represents an image DiskUsageObject.
|
||||
ImageObject = system.ImageObject
|
||||
// VolumeObject represents a volume DiskUsageObject.
|
||||
VolumeObject = system.VolumeObject
|
||||
// BuildCacheObject represents a build-cache DiskUsageObject.
|
||||
BuildCacheObject = system.BuildCacheObject
|
||||
)
|
||||
|
||||
// DiskUsageOptions holds parameters for system disk usage query.
|
||||
type DiskUsageOptions = client.DiskUsageOptions
|
||||
|
||||
// DiskUsage contains response of Engine API:
|
||||
// GET "/system/df"
|
||||
type DiskUsage = system.DiskUsage
|
||||
|
||||
// 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
|
||||
// so it can sign the manifest if necessary.
|
||||
type PushResult = types.PushResult
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package auxprogress
|
||||
|
||||
import "github.com/moby/moby/api/types/auxprogress"
|
||||
|
||||
// ManifestPushedInsteadOfIndex is a note that is sent when a manifest is pushed
|
||||
// instead of an index. It is sent when the pushed image is an multi-platform
|
||||
// index, but the whole index couldn't be pushed.
|
||||
type ManifestPushedInsteadOfIndex = auxprogress.ManifestPushedInsteadOfIndex
|
||||
|
||||
// ContentMissing is a note that is sent when push fails because the content is missing.
|
||||
type ContentMissing = auxprogress.ContentMissing
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package blkiodev
|
||||
|
||||
import "github.com/moby/moby/api/types/blkiodev"
|
||||
|
||||
// WeightDevice is a structure that holds device:weight pair
|
||||
type WeightDevice = blkiodev.WeightDevice
|
||||
|
||||
// ThrottleDevice is a structure that holds device:rate_per_second pair
|
||||
type ThrottleDevice = blkiodev.ThrottleDevice
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package build
|
||||
|
||||
import "github.com/moby/moby/api/types/build"
|
||||
|
||||
// BuilderVersion sets the version of underlying builder to use
|
||||
type BuilderVersion = build.BuilderVersion
|
||||
|
||||
const (
|
||||
// BuilderV1 is the first generation builder in docker daemon
|
||||
BuilderV1 = build.BuilderV1
|
||||
// BuilderBuildKit is builder based on moby/buildkit project
|
||||
BuilderBuildKit = build.BuilderBuildKit
|
||||
)
|
||||
|
||||
// Result contains the image id of a successful build.
|
||||
type Result = build.Result
|
||||
|
||||
// ImageBuildOptions holds the information
|
||||
// necessary to build images.
|
||||
type ImageBuildOptions = build.ImageBuildOptions
|
||||
|
||||
// ImageBuildOutput defines configuration for exporting a build result
|
||||
type ImageBuildOutput = build.ImageBuildOutput
|
||||
|
||||
// ImageBuildResponse holds information
|
||||
// returned by a server after building
|
||||
// an image.
|
||||
type ImageBuildResponse = build.ImageBuildResponse
|
||||
|
||||
// CacheRecord contains information about a build cache record.
|
||||
type CacheRecord = build.CacheRecord
|
||||
|
||||
// CachePruneOptions hold parameters to prune the build cache.
|
||||
type CachePruneOptions = build.CachePruneOptions
|
||||
|
||||
// CachePruneReport contains the response for Engine API:
|
||||
// POST "/build/prune"
|
||||
type CachePruneReport = build.CachePruneReport
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package checkpoint
|
||||
|
||||
import "github.com/moby/moby/api/types/checkpoint"
|
||||
|
||||
// Summary represents the details of a checkpoint when listing endpoints.
|
||||
type Summary = checkpoint.Summary
|
||||
|
||||
// CreateOptions holds parameters to create a checkpoint from a container.
|
||||
type CreateOptions = checkpoint.CreateOptions
|
||||
|
||||
// ListOptions holds parameters to list checkpoints for a container.
|
||||
type ListOptions = checkpoint.ListOptions
|
||||
|
||||
// DeleteOptions holds parameters to delete a checkpoint from a container.
|
||||
type DeleteOptions = checkpoint.DeleteOptions
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"net"
|
||||
)
|
||||
|
||||
// NewHijackedResponse initializes a [HijackedResponse] type.
|
||||
func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse {
|
||||
return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType}
|
||||
}
|
||||
|
||||
// HijackedResponse holds connection information for a hijacked request.
|
||||
type HijackedResponse struct {
|
||||
mediaType string
|
||||
Conn net.Conn
|
||||
Reader *bufio.Reader
|
||||
}
|
||||
|
||||
// Close closes the hijacked connection and reader.
|
||||
func (h *HijackedResponse) Close() {
|
||||
h.Conn.Close()
|
||||
}
|
||||
|
||||
// MediaType let client know if HijackedResponse hold a raw or multiplexed stream.
|
||||
// returns false if HTTP Content-Type is not relevant, and container must be inspected
|
||||
func (h *HijackedResponse) MediaType() (string, bool) {
|
||||
if h.mediaType == "" {
|
||||
return "", false
|
||||
}
|
||||
return h.mediaType, true
|
||||
}
|
||||
|
||||
// CloseWriter is an interface that implements structs
|
||||
// that close input streams to prevent from writing.
|
||||
type CloseWriter interface {
|
||||
CloseWrite() error
|
||||
}
|
||||
|
||||
// CloseWrite closes a readWriter for writing.
|
||||
func (h *HijackedResponse) CloseWrite() error {
|
||||
if conn, ok := h.Conn.(CloseWriter); ok {
|
||||
return conn.CloseWrite()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PluginRemoveOptions holds parameters to remove plugins.
|
||||
type PluginRemoveOptions struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
// PluginEnableOptions holds parameters to enable plugins.
|
||||
type PluginEnableOptions struct {
|
||||
Timeout int
|
||||
}
|
||||
|
||||
// PluginDisableOptions holds parameters to disable plugins.
|
||||
type PluginDisableOptions struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
// PluginInstallOptions holds parameters to install a plugin.
|
||||
type PluginInstallOptions struct {
|
||||
Disabled bool
|
||||
AcceptAllPermissions bool
|
||||
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
||||
RemoteRef string // RemoteRef is the plugin name on the registry
|
||||
|
||||
// PrivilegeFunc is a function that clients can supply to retry operations
|
||||
// after getting an authorization error. This function returns the registry
|
||||
// authentication header value in base64 encoded format, or an error if the
|
||||
// privilege request fails.
|
||||
//
|
||||
// For details, refer to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
|
||||
PrivilegeFunc func(context.Context) (string, error)
|
||||
AcceptPermissionsFunc func(context.Context, PluginPrivileges) (bool, error)
|
||||
Args []string
|
||||
}
|
||||
|
||||
// PluginCreateOptions hold all options to plugin create.
|
||||
type PluginCreateOptions struct {
|
||||
RepoName string
|
||||
}
|
||||
|
|
@ -0,0 +1,404 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// ChangeType Kind of change
|
||||
//
|
||||
// Can be one of:
|
||||
//
|
||||
// - `0`: Modified ("C")
|
||||
// - `1`: Added ("A")
|
||||
// - `2`: Deleted ("D")
|
||||
//
|
||||
// swagger:model ChangeType
|
||||
type ChangeType = container.ChangeType
|
||||
|
||||
const (
|
||||
// ChangeModify represents the modify operation.
|
||||
ChangeModify = container.ChangeModify
|
||||
// ChangeAdd represents the add operation.
|
||||
ChangeAdd = container.ChangeAdd
|
||||
// ChangeDelete represents the delete operation.
|
||||
ChangeDelete = container.ChangeDelete
|
||||
)
|
||||
|
||||
// CommitResponse response for the commit API call, containing the ID of the
|
||||
// image that was produced.
|
||||
type CommitResponse = container.CommitResponse
|
||||
|
||||
// MinimumDuration puts a minimum on user configured duration.
|
||||
// This is to prevent API error on time unit. For example, API may
|
||||
// set 3 as healthcheck interval with intention of 3 seconds, but
|
||||
// Docker interprets it as 3 nanoseconds.
|
||||
const MinimumDuration = container.MinimumDuration
|
||||
|
||||
// StopOptions holds the options to stop or restart a container.
|
||||
type StopOptions = container.StopOptions
|
||||
|
||||
// HealthConfig holds configuration settings for the HEALTHCHECK feature.
|
||||
type HealthConfig = container.HealthConfig
|
||||
|
||||
// Config contains the configuration data about a container.
|
||||
// It should hold only portable information about the container.
|
||||
// Here, "portable" means "independent from the host we are running on".
|
||||
// Non-portable information *should* appear in HostConfig.
|
||||
// All fields added to this struct must be marked `omitempty` to keep getting
|
||||
// predictable hashes from the old `v1Compatibility` configuration.
|
||||
type Config = container.Config
|
||||
|
||||
// ContainerUpdateOKBody OK response to ContainerUpdate operation
|
||||
//
|
||||
// Deprecated: use [container.UpdateResponse]. This alias will be removed in the next release.
|
||||
type ContainerUpdateOKBody = container.UpdateResponse
|
||||
|
||||
// ContainerTopOKBody OK response to ContainerTop operation
|
||||
//
|
||||
// Deprecated: use [container.TopResponse]. This alias will be removed in the next release.
|
||||
type ContainerTopOKBody = container.TopResponse
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/containers/prune"
|
||||
type PruneReport = container.PruneReport
|
||||
|
||||
// PathStat is used to encode the header from
|
||||
// GET "/containers/{name:.*}/archive"
|
||||
// "Name" is the file or directory name.
|
||||
type PathStat = container.PathStat
|
||||
|
||||
// CopyToContainerOptions holds information
|
||||
// about files to copy into a container
|
||||
type CopyToContainerOptions = container.CopyToContainerOptions
|
||||
|
||||
// StatsResponseReader wraps an io.ReadCloser to read (a stream of) stats
|
||||
// for a container, as produced by the GET "/stats" endpoint.
|
||||
//
|
||||
// The OSType field is set to the server's platform to allow
|
||||
// platform-specific handling of the response.
|
||||
//
|
||||
// TODO(thaJeztah): remove this wrapper, and make OSType part of [StatsResponse].
|
||||
type StatsResponseReader = client.StatsResponseReader
|
||||
|
||||
// MountPoint represents a mount point configuration inside the container.
|
||||
// This is used for reporting the mountpoints in use by a container.
|
||||
type MountPoint = container.MountPoint
|
||||
|
||||
// State stores container's running state
|
||||
// it's part of ContainerJSONBase and returned by "inspect" command
|
||||
type State = container.State
|
||||
|
||||
// Summary contains response of Engine API:
|
||||
// GET "/containers/json"
|
||||
type Summary = container.Summary
|
||||
|
||||
// CreateRequest is the request message sent to the server for container
|
||||
// create calls. It is a config wrapper that holds the container [Config]
|
||||
// (portable) and the corresponding [HostConfig] (non-portable) and
|
||||
// [network.NetworkingConfig].
|
||||
type CreateRequest = container.CreateRequest
|
||||
|
||||
// CreateResponse ContainerCreateResponse
|
||||
//
|
||||
// OK response to ContainerCreate operation
|
||||
// swagger:model CreateResponse
|
||||
type CreateResponse = container.CreateResponse
|
||||
|
||||
// ExecCreateResponse is the response for a successful exec-create request.
|
||||
// It holds the ID of the exec that was created.
|
||||
//
|
||||
// TODO(thaJeztah): make this a distinct type.
|
||||
type ExecCreateResponse = container.ExecCreateResponse
|
||||
|
||||
// ExecOptions is a small subset of the Config struct that holds the configuration
|
||||
// for the exec feature of docker.
|
||||
type ExecOptions = container.ExecOptions
|
||||
|
||||
// ExecStartOptions is a temp struct used by execStart
|
||||
// Config fields is part of ExecConfig in runconfig package
|
||||
type ExecStartOptions = container.ExecStartOptions
|
||||
|
||||
// ExecAttachOptions is a temp struct used by execAttach.
|
||||
//
|
||||
// TODO(thaJeztah): make this a separate type; ContainerExecAttach does not use the Detach option, and cannot run detached.
|
||||
type ExecAttachOptions = container.ExecAttachOptions
|
||||
|
||||
// ExecInspect holds information returned by exec inspect.
|
||||
type ExecInspect = container.ExecInspect
|
||||
|
||||
// FilesystemChange Change in the container's filesystem.
|
||||
type FilesystemChange = container.FilesystemChange
|
||||
|
||||
// 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 = container.HealthStatus
|
||||
|
||||
// Health states
|
||||
const (
|
||||
NoHealthcheck = container.NoHealthcheck // Indicates there is no healthcheck
|
||||
Starting = container.Starting // Starting indicates that the container is not yet ready
|
||||
Healthy = container.Healthy // Healthy indicates that the container is running correctly
|
||||
Unhealthy = container.Unhealthy // Unhealthy indicates that the container has a problem
|
||||
)
|
||||
|
||||
// Health stores information about the container's healthcheck results
|
||||
type Health = container.Health
|
||||
|
||||
// HealthcheckResult stores information about a single run of a healthcheck probe
|
||||
type HealthcheckResult = container.HealthcheckResult
|
||||
|
||||
// ValidateHealthStatus checks if the provided string is a valid
|
||||
// container [container.HealthStatus].
|
||||
func ValidateHealthStatus(s container.HealthStatus) error {
|
||||
return container.ValidateHealthStatus(s)
|
||||
}
|
||||
|
||||
// CgroupnsMode represents the cgroup namespace mode of the container
|
||||
type CgroupnsMode = container.CgroupnsMode
|
||||
|
||||
// cgroup namespace modes for containers
|
||||
const (
|
||||
CgroupnsModeEmpty = container.CgroupnsModeEmpty
|
||||
CgroupnsModePrivate = container.CgroupnsModePrivate
|
||||
CgroupnsModeHost = container.CgroupnsModeHost
|
||||
)
|
||||
|
||||
// Isolation represents the isolation technology of a container. The supported
|
||||
// values are platform specific
|
||||
type Isolation = container.Isolation
|
||||
|
||||
// Isolation modes for containers
|
||||
const (
|
||||
IsolationEmpty = container.IsolationEmpty // IsolationEmpty is unspecified (same behavior as default)
|
||||
IsolationDefault = container.IsolationDefault // IsolationDefault is the default isolation mode on current daemon
|
||||
IsolationProcess = container.IsolationProcess // IsolationProcess is process isolation mode
|
||||
IsolationHyperV = container.IsolationHyperV // IsolationHyperV is HyperV isolation mode
|
||||
)
|
||||
|
||||
// IpcMode represents the container ipc stack.
|
||||
type IpcMode = container.IpcMode
|
||||
|
||||
// IpcMode constants
|
||||
const (
|
||||
IPCModeNone = container.IPCModeNone
|
||||
IPCModeHost = container.IPCModeHost
|
||||
IPCModeContainer = container.IPCModeContainer
|
||||
IPCModePrivate = container.IPCModePrivate
|
||||
IPCModeShareable = container.IPCModeShareable
|
||||
)
|
||||
|
||||
// NetworkMode represents the container network stack.
|
||||
type NetworkMode = container.NetworkMode
|
||||
|
||||
// UsernsMode represents userns mode in the container.
|
||||
type UsernsMode = container.UsernsMode
|
||||
|
||||
// CgroupSpec represents the cgroup to use for the container.
|
||||
type CgroupSpec = container.CgroupSpec
|
||||
|
||||
// UTSMode represents the UTS namespace of the container.
|
||||
type UTSMode = container.UTSMode
|
||||
|
||||
// PidMode represents the pid namespace of the container.
|
||||
type PidMode = container.PidMode
|
||||
|
||||
// DeviceRequest represents a request for devices from a device driver.
|
||||
// Used by GPU device drivers.
|
||||
type DeviceRequest = container.DeviceRequest
|
||||
|
||||
// DeviceMapping represents the device mapping between the host and the container.
|
||||
type DeviceMapping = container.DeviceMapping
|
||||
|
||||
// RestartPolicy represents the restart policies of the container.
|
||||
type RestartPolicy = container.RestartPolicy
|
||||
|
||||
type RestartPolicyMode = container.RestartPolicyMode
|
||||
|
||||
const (
|
||||
RestartPolicyDisabled = container.RestartPolicyDisabled
|
||||
RestartPolicyAlways = container.RestartPolicyAlways
|
||||
RestartPolicyOnFailure = container.RestartPolicyOnFailure
|
||||
RestartPolicyUnlessStopped = container.RestartPolicyUnlessStopped
|
||||
)
|
||||
|
||||
// ValidateRestartPolicy validates the given RestartPolicy.
|
||||
func ValidateRestartPolicy(policy container.RestartPolicy) error {
|
||||
return container.ValidateRestartPolicy(policy)
|
||||
}
|
||||
|
||||
// LogMode is a type to define the available modes for logging
|
||||
// These modes affect how logs are handled when log messages start piling up.
|
||||
type LogMode = container.LogMode
|
||||
|
||||
// Available logging modes
|
||||
const (
|
||||
LogModeUnset = container.LogModeUnset
|
||||
LogModeBlocking = container.LogModeBlocking
|
||||
LogModeNonBlock = container.LogModeNonBlock
|
||||
)
|
||||
|
||||
// LogConfig represents the logging configuration of the container.
|
||||
type LogConfig = container.LogConfig
|
||||
|
||||
// Ulimit is an alias for [units.Ulimit], which may be moving to a different
|
||||
// location or become a local type. This alias is to help transitioning.
|
||||
//
|
||||
// Users are recommended to use this alias instead of using [units.Ulimit] directly.
|
||||
type Ulimit = container.Ulimit
|
||||
|
||||
// Resources contains container's resources (cgroups config, ulimits...)
|
||||
type Resources = container.Resources
|
||||
|
||||
// UpdateConfig holds the mutable attributes of a Container.
|
||||
// Those attributes can be updated at runtime.
|
||||
type UpdateConfig = container.UpdateConfig
|
||||
|
||||
// HostConfig the non-portable Config structure of a container.
|
||||
// Here, "non-portable" means "dependent of the host we are running on".
|
||||
// Portable information *should* appear in Config.
|
||||
type HostConfig = container.HostConfig
|
||||
|
||||
// NetworkSettings exposes the network settings in the api
|
||||
type NetworkSettings = container.NetworkSettings
|
||||
|
||||
// NetworkSettingsBase holds networking state for a container when inspecting it.
|
||||
type NetworkSettingsBase = container.NetworkSettingsBase
|
||||
|
||||
// DefaultNetworkSettings holds network information
|
||||
// during the 2 release deprecation period.
|
||||
// It will be removed in Docker 1.11.
|
||||
type DefaultNetworkSettings = container.DefaultNetworkSettings
|
||||
|
||||
// NetworkSettingsSummary provides a summary of container's networks
|
||||
// in /containers/json
|
||||
type NetworkSettingsSummary = container.NetworkSettingsSummary
|
||||
|
||||
// ResizeOptions holds parameters to resize a TTY.
|
||||
// It can be used to resize container TTYs and
|
||||
// exec process TTYs too.
|
||||
type ResizeOptions = client.ContainerResizeOptions
|
||||
|
||||
// AttachOptions holds parameters to attach to a container.
|
||||
type AttachOptions = container.AttachOptions
|
||||
|
||||
// CommitOptions holds parameters to commit changes into a container.
|
||||
type CommitOptions = container.CommitOptions
|
||||
|
||||
// RemoveOptions holds parameters to remove containers.
|
||||
type RemoveOptions = container.RemoveOptions
|
||||
|
||||
// StartOptions holds parameters to start containers.
|
||||
type StartOptions = container.StartOptions
|
||||
|
||||
// ListOptions holds parameters to list containers with.
|
||||
type ListOptions = container.ListOptions
|
||||
|
||||
// LogsOptions holds parameters to filter logs with.
|
||||
type LogsOptions = container.LogsOptions
|
||||
|
||||
// Port An open port on a container
|
||||
type Port = container.PortSummary
|
||||
|
||||
// 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 = container.ContainerState
|
||||
|
||||
const (
|
||||
StateCreated = container.StateCreated // StateCreated indicates the container is created, but not (yet) started.
|
||||
StateRunning = container.StateRunning // StateRunning indicates that the container is running.
|
||||
StatePaused = container.StatePaused // StatePaused indicates that the container's current state is paused.
|
||||
StateRestarting = container.StateRestarting // StateRestarting indicates that the container is currently restarting.
|
||||
StateRemoving = container.StateRemoving // StateRemoving indicates that the container is being removed.
|
||||
StateExited = container.StateExited // StateExited indicates that the container exited.
|
||||
StateDead = container.StateDead // StateDead indicates that the container failed to be deleted. Containers in this state are attempted to be cleaned up when the daemon restarts.
|
||||
)
|
||||
|
||||
// ValidateContainerState checks if the provided string is a valid
|
||||
// container [container.ContainerState].
|
||||
func ValidateContainerState(s container.ContainerState) error {
|
||||
return container.ValidateContainerState(s)
|
||||
}
|
||||
|
||||
// ThrottlingData stores CPU throttling stats of one running container.
|
||||
// Not used on Windows.
|
||||
type ThrottlingData = container.ThrottlingData
|
||||
|
||||
// CPUUsage stores All CPU stats aggregated since container inception.
|
||||
type CPUUsage = container.CPUUsage
|
||||
|
||||
// CPUStats aggregates and wraps all CPU related info of container
|
||||
type CPUStats = container.CPUStats
|
||||
|
||||
// MemoryStats aggregates all memory stats since container inception on Linux.
|
||||
// Windows returns stats for commit and private working set only.
|
||||
type MemoryStats = container.MemoryStats
|
||||
|
||||
// BlkioStatEntry is one small entity to store a piece of Blkio stats
|
||||
// Not used on Windows.
|
||||
type BlkioStatEntry = container.BlkioStatEntry
|
||||
|
||||
// BlkioStats stores All IO service stats for data read and write.
|
||||
// This is a Linux specific structure as the differences between expressing
|
||||
// block I/O on Windows and Linux are sufficiently significant to make
|
||||
// little sense attempting to morph into a combined structure.
|
||||
type BlkioStats = container.BlkioStats
|
||||
|
||||
// StorageStats is the disk I/O stats for read/write on Windows.
|
||||
type StorageStats = container.StorageStats
|
||||
|
||||
// NetworkStats aggregates the network stats of one container
|
||||
type NetworkStats = container.NetworkStats
|
||||
|
||||
// PidsStats contains the stats of a container's pids
|
||||
type PidsStats = container.PidsStats
|
||||
|
||||
// Stats is Ultimate struct aggregating all types of stats of one container
|
||||
//
|
||||
// Deprecated: use [StatsResponse] instead. This type will be removed in the next release.
|
||||
type Stats = StatsResponse
|
||||
|
||||
// StatsResponse aggregates all types of stats of one container.
|
||||
type StatsResponse = container.StatsResponse
|
||||
|
||||
// TopResponse ContainerTopResponse
|
||||
//
|
||||
// Container "top" response.
|
||||
type TopResponse = container.TopResponse
|
||||
|
||||
// UpdateResponse ContainerUpdateResponse
|
||||
//
|
||||
// Response for a successful container-update.
|
||||
type UpdateResponse = container.UpdateResponse
|
||||
|
||||
// WaitExitError container waiting error, if any
|
||||
type WaitExitError = container.WaitExitError
|
||||
|
||||
// WaitResponse ContainerWaitResponse
|
||||
//
|
||||
// OK response to ContainerWait operation
|
||||
// swagger:model WaitResponse
|
||||
type WaitResponse = container.WaitResponse
|
||||
|
||||
// WaitCondition is a type used to specify a container state for which
|
||||
// to wait.
|
||||
type WaitCondition = container.WaitCondition
|
||||
|
||||
// Possible WaitCondition Values.
|
||||
//
|
||||
// WaitConditionNotRunning (default) is used to wait for any of the non-running
|
||||
// states: "created", "exited", "dead", "removing", or "removed".
|
||||
//
|
||||
// WaitConditionNextExit is used to wait for the next time the state changes
|
||||
// to a non-running state. If the state is currently "created" or "exited",
|
||||
// this would cause Wait() to block until either the container runs and exits
|
||||
// or is removed.
|
||||
//
|
||||
// WaitConditionRemoved is used to wait for the container to be removed.
|
||||
const (
|
||||
WaitConditionNotRunning = container.WaitConditionNotRunning
|
||||
WaitConditionNextExit = container.WaitConditionNextExit
|
||||
WaitConditionRemoved = container.WaitConditionRemoved
|
||||
)
|
||||
51
vendor/github.com/docker/docker/api/types/container/container_deprecated.go
generated
vendored
Normal file
51
vendor/github.com/docker/docker/api/types/container/container_deprecated.go
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
|
||||
// for API version 1.18 and older.
|
||||
//
|
||||
// TODO(thaJeztah): combine ContainerJSONBase and InspectResponse into a single struct.
|
||||
// The split between ContainerJSONBase (ContainerJSONBase) and InspectResponse (InspectResponse)
|
||||
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
|
||||
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
|
||||
// held fields that were added in API 1.19 and up. Given that the minimum
|
||||
// supported API version is now 1.24, we no longer use the separate type.
|
||||
type ContainerJSONBase struct {
|
||||
ID string `json:"Id"`
|
||||
Created string
|
||||
Path string
|
||||
Args []string
|
||||
State *State
|
||||
Image string
|
||||
ResolvConfPath string
|
||||
HostnamePath string
|
||||
HostsPath string
|
||||
LogPath string
|
||||
Name string
|
||||
RestartCount int
|
||||
Driver string
|
||||
Platform string
|
||||
MountLabel string
|
||||
ProcessLabel string
|
||||
AppArmorProfile string
|
||||
ExecIDs []string
|
||||
HostConfig *HostConfig
|
||||
GraphDriver storage.DriverData
|
||||
SizeRw *int64 `json:",omitempty"`
|
||||
SizeRootFs *int64 `json:",omitempty"`
|
||||
}
|
||||
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
*ContainerJSONBase
|
||||
Mounts []MountPoint
|
||||
Config *Config
|
||||
NetworkSettings *NetworkSettings
|
||||
// ImageManifestDescriptor is the descriptor of a platform-specific manifest of the image used to create the container.
|
||||
ImageManifestDescriptor *ocispec.Descriptor `json:"ImageManifestDescriptor,omitempty"`
|
||||
}
|
||||
|
|
@ -1,40 +1,5 @@
|
|||
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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
package events
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/events"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// Type is used for event-types.
|
||||
type Type = events.Type
|
||||
|
||||
// List of known event types.
|
||||
const (
|
||||
BuilderEventType = events.BuilderEventType // BuilderEventType is the event type that the builder generates.
|
||||
ConfigEventType = events.ConfigEventType // ConfigEventType is the event type that configs generate.
|
||||
ContainerEventType = events.ContainerEventType // ContainerEventType is the event type that containers generate.
|
||||
DaemonEventType = events.DaemonEventType // DaemonEventType is the event type that daemon generate.
|
||||
ImageEventType = events.ImageEventType // ImageEventType is the event type that images generate.
|
||||
NetworkEventType = events.NetworkEventType // NetworkEventType is the event type that networks generate.
|
||||
NodeEventType = events.NodeEventType // NodeEventType is the event type that nodes generate.
|
||||
PluginEventType = events.PluginEventType // PluginEventType is the event type that plugins generate.
|
||||
SecretEventType = events.SecretEventType // SecretEventType is the event type that secrets generate.
|
||||
ServiceEventType = events.ServiceEventType // ServiceEventType is the event type that services generate.
|
||||
VolumeEventType = events.VolumeEventType // VolumeEventType is the event type that volumes generate.
|
||||
)
|
||||
|
||||
// Action is used for event-actions.
|
||||
type Action = events.Action
|
||||
|
||||
const (
|
||||
ActionCreate = events.ActionCreate
|
||||
ActionStart = events.ActionStart
|
||||
ActionRestart = events.ActionRestart
|
||||
ActionStop = events.ActionStop
|
||||
ActionCheckpoint = events.ActionCheckpoint
|
||||
ActionPause = events.ActionPause
|
||||
ActionUnPause = events.ActionUnPause
|
||||
ActionAttach = events.ActionAttach
|
||||
ActionDetach = events.ActionDetach
|
||||
ActionResize = events.ActionResize
|
||||
ActionUpdate = events.ActionUpdate
|
||||
ActionRename = events.ActionRename
|
||||
ActionKill = events.ActionKill
|
||||
ActionDie = events.ActionDie
|
||||
ActionOOM = events.ActionOOM
|
||||
ActionDestroy = events.ActionDestroy
|
||||
ActionRemove = events.ActionRemove
|
||||
ActionCommit = events.ActionCommit
|
||||
ActionTop = events.ActionTop
|
||||
ActionCopy = events.ActionCopy
|
||||
ActionArchivePath = events.ActionArchivePath
|
||||
ActionExtractToDir = events.ActionExtractToDir
|
||||
ActionExport = events.ActionExport
|
||||
ActionImport = events.ActionImport
|
||||
ActionSave = events.ActionSave
|
||||
ActionLoad = events.ActionLoad
|
||||
ActionTag = events.ActionTag
|
||||
ActionUnTag = events.ActionUnTag
|
||||
ActionPush = events.ActionPush
|
||||
ActionPull = events.ActionPull
|
||||
ActionPrune = events.ActionPrune
|
||||
ActionDelete = events.ActionDelete
|
||||
ActionEnable = events.ActionEnable
|
||||
ActionDisable = events.ActionDisable
|
||||
ActionConnect = events.ActionConnect
|
||||
ActionDisconnect = events.ActionDisconnect
|
||||
ActionReload = events.ActionReload
|
||||
ActionMount = events.ActionMount
|
||||
ActionUnmount = events.ActionUnmount
|
||||
|
||||
// ActionExecCreate is the prefix used for exec_create events. These
|
||||
// event-actions are commonly followed by a colon and space (": "),
|
||||
// and the command that's defined for the exec, for example:
|
||||
//
|
||||
// exec_create: /bin/sh -c 'echo hello'
|
||||
//
|
||||
// This is far from ideal; it's a compromise to allow filtering and
|
||||
// to preserve backward-compatibility.
|
||||
ActionExecCreate = events.ActionExecCreate
|
||||
// ActionExecStart is the prefix used for exec_create events. These
|
||||
// event-actions are commonly followed by a colon and space (": "),
|
||||
// and the command that's defined for the exec, for example:
|
||||
//
|
||||
// exec_start: /bin/sh -c 'echo hello'
|
||||
//
|
||||
// This is far from ideal; it's a compromise to allow filtering and
|
||||
// to preserve backward-compatibility.
|
||||
ActionExecStart = events.ActionExecStart
|
||||
ActionExecDie = events.ActionExecDie
|
||||
ActionExecDetach = events.ActionExecDetach
|
||||
|
||||
// ActionHealthStatus is the prefix to use for health_status events.
|
||||
//
|
||||
// Health-status events can either have a pre-defined status, in which
|
||||
// case the "health_status" action is followed by a colon, or can be
|
||||
// "free-form", in which case they're followed by the output of the
|
||||
// health-check output.
|
||||
//
|
||||
// This is far form ideal, and a compromise to allow filtering, and
|
||||
// to preserve backward-compatibility.
|
||||
ActionHealthStatus = events.ActionHealthStatus
|
||||
ActionHealthStatusRunning = events.ActionHealthStatusRunning
|
||||
ActionHealthStatusHealthy = events.ActionHealthStatusHealthy
|
||||
ActionHealthStatusUnhealthy = events.ActionHealthStatusUnhealthy
|
||||
)
|
||||
|
||||
// Actor describes something that generates events,
|
||||
// like a container, or a network, or a volume.
|
||||
// It has a defined name and a set of attributes.
|
||||
// The container attributes are its labels, other actors
|
||||
// can generate these attributes from other properties.
|
||||
type Actor = events.Actor
|
||||
|
||||
// Message represents the information an event contains
|
||||
type Message = events.Message
|
||||
|
||||
// ListOptions holds parameters to filter events with.
|
||||
type ListOptions = client.EventsListOptions
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Package filters provides tools for encoding a mapping of keys to a set of
|
||||
multiple values.
|
||||
*/
|
||||
package filters
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
)
|
||||
|
||||
// Args stores a mapping of keys to a set of multiple values.
|
||||
type Args = filters.Args
|
||||
|
||||
// KeyValuePair are used to initialize a new Args
|
||||
type KeyValuePair = filters.KeyValuePair
|
||||
|
||||
// Arg creates a new KeyValuePair for initializing Args
|
||||
func Arg(key, value string) filters.KeyValuePair {
|
||||
return filters.Arg(key, value)
|
||||
}
|
||||
|
||||
// NewArgs returns a new Args populated with the initial args
|
||||
func NewArgs(initialArgs ...filters.KeyValuePair) filters.Args {
|
||||
return filters.NewArgs(initialArgs...)
|
||||
}
|
||||
|
||||
// ToJSON returns the Args as a JSON encoded string
|
||||
func ToJSON(a Args) (string, error) {
|
||||
return filters.ToJSON(a)
|
||||
}
|
||||
|
||||
// FromJSON decodes a JSON encoded string into Args
|
||||
func FromJSON(p string) (filters.Args, error) {
|
||||
return filters.FromJSON(p)
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
)
|
||||
|
||||
// ToParamWithVersion encodes Args as a JSON string. If version is less than 1.22
|
||||
|
|
@ -11,51 +12,21 @@ import (
|
|||
// list of strings, instead of a set.
|
||||
//
|
||||
// Deprecated: do not use in any new code; use ToJSON instead
|
||||
func ToParamWithVersion(version string, a Args) (string, error) {
|
||||
out, err := ToJSON(a)
|
||||
if out == "" || err != nil {
|
||||
func ToParamWithVersion(version string, a filters.Args) (string, error) {
|
||||
if a.Len() == 0 {
|
||||
return "", nil
|
||||
}
|
||||
if version != "" && versions.LessThan(version, "1.22") {
|
||||
return encodeLegacyFilters(out)
|
||||
buf, err := json.Marshal(convertArgsToSlice(a))
|
||||
return string(buf), err
|
||||
}
|
||||
return out, nil
|
||||
return ToJSON(a)
|
||||
}
|
||||
|
||||
// encodeLegacyFilters encodes Args in the legacy format as used in API v1.21 and older.
|
||||
// where values are a list of strings, instead of a set.
|
||||
//
|
||||
// Don't use in any new code; use [filters.ToJSON]] instead.
|
||||
func encodeLegacyFilters(currentFormat string) (string, error) {
|
||||
// The Args.fields field is not exported, but used to marshal JSON,
|
||||
// so we'll marshal to the new format, then unmarshal to get the
|
||||
// fields, and marshal again.
|
||||
//
|
||||
// This is far from optimal, but this code is only used for deprecated
|
||||
// API versions, so should not be hit commonly.
|
||||
var argsFields map[string]map[string]bool
|
||||
err := json.Unmarshal([]byte(currentFormat), &argsFields)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
buf, err := json.Marshal(convertArgsToSlice(argsFields))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(buf), nil
|
||||
}
|
||||
|
||||
func convertArgsToSlice(f map[string]map[string]bool) map[string][]string {
|
||||
func convertArgsToSlice(f filters.Args) map[string][]string {
|
||||
m := map[string][]string{}
|
||||
for k, v := range f {
|
||||
values := []string{}
|
||||
for kk := range v {
|
||||
if v[kk] {
|
||||
values = append(values, kk)
|
||||
}
|
||||
}
|
||||
m[k] = values
|
||||
for _, key := range f.Keys() {
|
||||
m[key] = f.Get(key)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,119 @@
|
|||
package image
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/client"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// DeleteResponse delete response
|
||||
type DeleteResponse = image.DeleteResponse
|
||||
|
||||
// Metadata contains engine-local data about the image.
|
||||
type Metadata = image.Metadata
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/images/prune"
|
||||
type PruneReport = image.PruneReport
|
||||
|
||||
// LoadResponse returns information to the client about a load process.
|
||||
//
|
||||
// TODO(thaJeztah): remove this type, and just use an io.ReadCloser
|
||||
//
|
||||
// This type was added in https://github.com/moby/moby/pull/18878, related
|
||||
// to https://github.com/moby/moby/issues/19177;
|
||||
//
|
||||
// Make docker load to output json when the response content type is json
|
||||
// Swarm hijacks the response from docker load and returns JSON rather
|
||||
// than plain text like the Engine does. This makes the API library to return
|
||||
// information to figure that out.
|
||||
//
|
||||
// However the "load" endpoint unconditionally returns JSON;
|
||||
// https://github.com/moby/moby/blob/7b9d2ef6e5518a3d3f3cc418459f8df786cfbbd1/api/server/router/image/image_routes.go#L248-L255
|
||||
//
|
||||
// PR https://github.com/moby/moby/pull/21959 made the response-type depend
|
||||
// on whether "quiet" was set, but this logic got changed in a follow-up
|
||||
// https://github.com/moby/moby/pull/25557, which made the JSON response-type
|
||||
// unconditionally, but the output produced depend on whether"quiet" was set.
|
||||
//
|
||||
// We should deprecated the "quiet" option, as it's really a client
|
||||
// responsibility.
|
||||
type LoadResponse = image.LoadResponse
|
||||
|
||||
// HistoryResponseItem individual image layer information in response to ImageHistory operation
|
||||
type HistoryResponseItem = image.HistoryResponseItem
|
||||
|
||||
// RootFS returns Image's RootFS description including the layer IDs.
|
||||
type RootFS = image.RootFS
|
||||
|
||||
// InspectResponse contains response of Engine API:
|
||||
// GET "/images/{name:.*}/json"
|
||||
type InspectResponse = image.InspectResponse
|
||||
|
||||
type ManifestKind = image.ManifestKind
|
||||
|
||||
const (
|
||||
ManifestKindImage = image.ManifestKindImage
|
||||
ManifestKindAttestation = image.ManifestKindAttestation
|
||||
ManifestKindUnknown = image.ManifestKindUnknown
|
||||
)
|
||||
|
||||
type ManifestSummary = image.ManifestSummary
|
||||
|
||||
type ImageProperties = image.ImageProperties
|
||||
|
||||
type AttestationProperties = image.AttestationProperties
|
||||
|
||||
// ImportSource holds source information for ImageImport
|
||||
type ImportSource = client.ImageImportSource
|
||||
|
||||
// ImportOptions holds information to import images from the client host.
|
||||
type ImportOptions = client.ImageImportOptions
|
||||
|
||||
// CreateOptions holds information to create images.
|
||||
type CreateOptions = client.ImageCreateOptions
|
||||
|
||||
// PullOptions holds information to pull images.
|
||||
type PullOptions = client.ImagePullOptions
|
||||
|
||||
// PushOptions holds information to push images.
|
||||
type PushOptions = client.ImagePushOptions
|
||||
|
||||
// ListOptions holds parameters to list images with.
|
||||
type ListOptions = client.ImageListOptions
|
||||
|
||||
// RemoveOptions holds parameters to remove images.
|
||||
type RemoveOptions = client.ImageRemoveOptions
|
||||
|
||||
// HistoryOptions holds parameters to get image history.
|
||||
//
|
||||
// FIXME(thaJeztah): no longer exported in client: either deprecate or export in client
|
||||
type HistoryOptions struct {
|
||||
// Platform from the manifest list to use for history.
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
// LoadOptions holds parameters to load images.
|
||||
//
|
||||
// FIXME(thaJeztah): no longer exported in client: either deprecate or export in client
|
||||
type LoadOptions struct {
|
||||
// Quiet suppresses progress output
|
||||
Quiet bool
|
||||
|
||||
// Platforms selects the platforms to load if the image is a
|
||||
// multi-platform image and has multiple variants.
|
||||
Platforms []ocispec.Platform
|
||||
}
|
||||
|
||||
type InspectOptions = client.ImageInspectOptions
|
||||
|
||||
// SaveOptions holds parameters to save images.
|
||||
//
|
||||
// FIXME(thaJeztah): no longer exported in client: either deprecate or export in client
|
||||
type SaveOptions struct {
|
||||
// Platforms selects the platforms to save if the image is a
|
||||
// multi-platform image and has multiple variants.
|
||||
Platforms []ocispec.Platform
|
||||
}
|
||||
|
||||
type Summary = image.Summary
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ImportSource holds source information for ImageImport
|
||||
type ImportSource struct {
|
||||
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
|
||||
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
|
||||
}
|
||||
|
||||
// ImportOptions holds information to import images from the client host.
|
||||
type ImportOptions struct {
|
||||
Tag string // Tag is the name to tag this image with. This attribute is deprecated.
|
||||
Message string // Message is the message to tag the image with
|
||||
Changes []string // Changes are the raw changes to apply to this image
|
||||
Platform string // Platform is the target platform of the image
|
||||
}
|
||||
|
||||
// CreateOptions holds information to create images.
|
||||
type CreateOptions struct {
|
||||
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
|
||||
Platform string // Platform is the target platform of the image if it needs to be pulled from the registry.
|
||||
}
|
||||
|
||||
// PullOptions holds information to pull images.
|
||||
type PullOptions struct {
|
||||
All bool
|
||||
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
||||
|
||||
// PrivilegeFunc is a function that clients can supply to retry operations
|
||||
// after getting an authorization error. This function returns the registry
|
||||
// authentication header value in base64 encoded format, or an error if the
|
||||
// privilege request fails.
|
||||
//
|
||||
// For details, refer to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
|
||||
PrivilegeFunc func(context.Context) (string, error)
|
||||
Platform string
|
||||
}
|
||||
|
||||
// PushOptions holds information to push images.
|
||||
type PushOptions struct {
|
||||
All bool
|
||||
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
||||
|
||||
// PrivilegeFunc is a function that clients can supply to retry operations
|
||||
// after getting an authorization error. This function returns the registry
|
||||
// authentication header value in base64 encoded format, or an error if the
|
||||
// privilege request fails.
|
||||
//
|
||||
// For details, refer to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
|
||||
PrivilegeFunc func(context.Context) (string, error)
|
||||
|
||||
// Platform is an optional field that selects a specific platform to push
|
||||
// when the image is a multi-platform image.
|
||||
// Using this will only push a single platform-specific manifest.
|
||||
Platform *ocispec.Platform `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ListOptions holds parameters to list images with.
|
||||
type ListOptions struct {
|
||||
// All controls whether all images in the graph are filtered, or just
|
||||
// the heads.
|
||||
All bool
|
||||
|
||||
// Filters is a JSON-encoded set of filter arguments.
|
||||
Filters filters.Args
|
||||
|
||||
// SharedSize indicates whether the shared size of images should be computed.
|
||||
SharedSize bool
|
||||
|
||||
// ContainerCount indicates whether container count should be computed.
|
||||
//
|
||||
// Deprecated: This field has been unused and is no longer required and will be removed in a future version.
|
||||
ContainerCount bool
|
||||
|
||||
// Manifests indicates whether the image manifests should be returned.
|
||||
Manifests bool
|
||||
}
|
||||
|
||||
// RemoveOptions holds parameters to remove images.
|
||||
type RemoveOptions struct {
|
||||
Platforms []ocispec.Platform
|
||||
Force bool
|
||||
PruneChildren bool
|
||||
}
|
||||
|
||||
// HistoryOptions holds parameters to get image history.
|
||||
type HistoryOptions struct {
|
||||
// Platform from the manifest list to use for history.
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
// LoadOptions holds parameters to load images.
|
||||
type LoadOptions struct {
|
||||
// Quiet suppresses progress output
|
||||
Quiet bool
|
||||
|
||||
// Platforms selects the platforms to load if the image is a
|
||||
// multi-platform image and has multiple variants.
|
||||
Platforms []ocispec.Platform
|
||||
}
|
||||
|
||||
type InspectOptions struct {
|
||||
// Manifests returns the image manifests.
|
||||
Manifests bool
|
||||
|
||||
// Platform selects the specific platform of a multi-platform image to inspect.
|
||||
//
|
||||
// This option is only available for API version 1.49 and up.
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
// SaveOptions holds parameters to save images.
|
||||
type SaveOptions struct {
|
||||
// Platforms selects the platforms to save if the image is a
|
||||
// multi-platform image and has multiple variants.
|
||||
Platforms []ocispec.Platform
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package mount
|
||||
|
||||
import "github.com/moby/moby/api/types/mount"
|
||||
|
||||
// Type represents the type of a mount.
|
||||
type Type = mount.Type
|
||||
|
||||
// Type constants
|
||||
const (
|
||||
// TypeBind is the type for mounting host dir
|
||||
TypeBind = mount.TypeBind
|
||||
// TypeVolume is the type for remote storage volumes
|
||||
TypeVolume = mount.TypeVolume
|
||||
// TypeTmpfs is the type for mounting tmpfs
|
||||
TypeTmpfs = mount.TypeTmpfs
|
||||
// TypeNamedPipe is the type for mounting Windows named pipes
|
||||
TypeNamedPipe = mount.TypeNamedPipe
|
||||
// TypeCluster is the type for Swarm Cluster Volumes.
|
||||
TypeCluster = mount.TypeCluster
|
||||
// TypeImage is the type for mounting another image's filesystem
|
||||
TypeImage = mount.TypeImage
|
||||
)
|
||||
|
||||
// Mount represents a mount (volume).
|
||||
type Mount = mount.Mount
|
||||
|
||||
// Propagation represents the propagation of a mount.
|
||||
type Propagation = mount.Propagation
|
||||
|
||||
const (
|
||||
// PropagationRPrivate RPRIVATE
|
||||
PropagationRPrivate = mount.PropagationRPrivate
|
||||
// PropagationPrivate PRIVATE
|
||||
PropagationPrivate = mount.PropagationPrivate
|
||||
// PropagationRShared RSHARED
|
||||
PropagationRShared = mount.PropagationRShared
|
||||
// PropagationShared SHARED
|
||||
PropagationShared = mount.PropagationShared
|
||||
// PropagationRSlave RSLAVE
|
||||
PropagationRSlave = mount.PropagationRSlave
|
||||
// PropagationSlave SLAVE
|
||||
PropagationSlave = mount.PropagationSlave
|
||||
)
|
||||
|
||||
// Propagations is the list of all valid mount propagations
|
||||
var Propagations = mount.Propagations
|
||||
|
||||
// Consistency represents the consistency requirements of a mount.
|
||||
type Consistency = mount.Consistency
|
||||
|
||||
const (
|
||||
// ConsistencyFull guarantees bind mount-like consistency
|
||||
ConsistencyFull = mount.ConsistencyFull
|
||||
// ConsistencyCached mounts can cache read data and FS structure
|
||||
ConsistencyCached = mount.ConsistencyCached
|
||||
// ConsistencyDelegated mounts can cache read and written data and structure
|
||||
ConsistencyDelegated = mount.ConsistencyDelegated
|
||||
// ConsistencyDefault provides "consistent" behavior unless overridden
|
||||
ConsistencyDefault = mount.ConsistencyDefault
|
||||
)
|
||||
|
||||
// BindOptions defines options specific to mounts of type "bind".
|
||||
type BindOptions = mount.BindOptions
|
||||
|
||||
// VolumeOptions represents the options for a mount of type volume.
|
||||
type VolumeOptions = mount.VolumeOptions
|
||||
|
||||
type ImageOptions = mount.ImageOptions
|
||||
|
||||
// Driver represents a volume driver.
|
||||
type Driver = mount.Driver
|
||||
|
||||
// TmpfsOptions defines options specific to mounts of type "tmpfs".
|
||||
type TmpfsOptions = mount.TmpfsOptions
|
||||
|
||||
// ClusterOptions specifies options for a Cluster volume.
|
||||
type ClusterOptions = mount.ClusterOptions
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// CreateResponse NetworkCreateResponse
|
||||
//
|
||||
// OK response to NetworkCreate operation
|
||||
type CreateResponse = network.CreateResponse
|
||||
|
||||
// EndpointSettings stores the network endpoint details
|
||||
type EndpointSettings = network.EndpointSettings
|
||||
|
||||
// EndpointIPAMConfig represents IPAM configurations for the endpoint
|
||||
type EndpointIPAMConfig = network.EndpointIPAMConfig
|
||||
|
||||
// NetworkSubnet describes a user-defined subnet for a specific network. It's only used to validate if an
|
||||
// EndpointIPAMConfig is valid for a specific network.
|
||||
type NetworkSubnet = network.NetworkSubnet
|
||||
|
||||
// IPAM represents IP Address Management
|
||||
type IPAM = network.IPAM
|
||||
|
||||
// IPAMConfig represents IPAM configurations
|
||||
type IPAMConfig = network.IPAMConfig
|
||||
|
||||
// ValidateIPAM checks whether the network's IPAM passed as argument is valid. It returns a joinError of the list of
|
||||
// errors found.
|
||||
func ValidateIPAM(ipam *network.IPAM, enableIPv6 bool) error {
|
||||
return network.ValidateIPAM(ipam, enableIPv6)
|
||||
}
|
||||
|
||||
const (
|
||||
// NetworkDefault is a platform-independent alias to choose the platform-specific default network stack.
|
||||
NetworkDefault = network.NetworkDefault
|
||||
// NetworkHost is the name of the predefined network used when the NetworkMode host is selected (only available on Linux)
|
||||
NetworkHost = network.NetworkHost
|
||||
// NetworkNone is the name of the predefined network used when the NetworkMode none is selected (available on both Linux and Windows)
|
||||
NetworkNone = network.NetworkNone
|
||||
// NetworkBridge is the name of the default network on Linux
|
||||
NetworkBridge = network.NetworkBridge
|
||||
// NetworkNat is the name of the default network on Windows
|
||||
NetworkNat = network.NetworkNat
|
||||
)
|
||||
|
||||
// CreateRequest is the request message sent to the server for network create call.
|
||||
type CreateRequest = network.CreateRequest
|
||||
|
||||
// CreateOptions holds options to create a network.
|
||||
type CreateOptions = client.NetworkCreateOptions
|
||||
|
||||
// ListOptions holds parameters to filter the list of networks with.
|
||||
type ListOptions = client.NetworkListOptions
|
||||
|
||||
// InspectOptions holds parameters to inspect network.
|
||||
type InspectOptions = client.NetworkInspectOptions
|
||||
|
||||
// ConnectOptions represents the data to be used to connect a container to the
|
||||
// network.
|
||||
type ConnectOptions = client.NetworkConnectOptions
|
||||
|
||||
// DisconnectOptions represents the data to be used to disconnect a container
|
||||
// from the network.
|
||||
type DisconnectOptions = client.NetworkDisconnectOptions
|
||||
|
||||
// Inspect is the body of the "get network" http response message.
|
||||
type Inspect = network.Inspect
|
||||
|
||||
// Summary is used as response when listing networks. It currently is an alias
|
||||
// for [Inspect], but may diverge in the future, as not all information may
|
||||
// be included when listing networks.
|
||||
type Summary = network.Summary
|
||||
|
||||
// Address represents an IP address
|
||||
type Address = network.Address
|
||||
|
||||
// PeerInfo represents one peer of an overlay network
|
||||
type PeerInfo = network.PeerInfo
|
||||
|
||||
// Task carries the information about one backend task
|
||||
type Task = network.Task
|
||||
|
||||
// ServiceInfo represents service parameters with the list of service's tasks
|
||||
type ServiceInfo = network.ServiceInfo
|
||||
|
||||
// EndpointResource contains network resources allocated and used for a
|
||||
// container in a network.
|
||||
type EndpointResource = network.EndpointResource
|
||||
|
||||
// NetworkingConfig represents the container's networking configuration for each of its interfaces
|
||||
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
|
||||
type NetworkingConfig = network.NetworkingConfig
|
||||
|
||||
// ConfigReference specifies the source which provides a network's configuration
|
||||
type ConfigReference = network.ConfigReference
|
||||
|
||||
// ValidateFilters validates the list of filter args with the available filters.
|
||||
func ValidateFilters(filter filters.Args) error {
|
||||
return network.ValidateFilters(filter)
|
||||
}
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/networks/prune"
|
||||
type PruneReport = network.PruneReport
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package types
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// PluginInterfaceType plugin interface type
|
||||
// swagger:model PluginInterfaceType
|
||||
type PluginInterfaceType struct {
|
||||
|
||||
// capability
|
||||
// Required: true
|
||||
Capability string `json:"Capability"`
|
||||
|
||||
// prefix
|
||||
// Required: true
|
||||
Prefix string `json:"Prefix"`
|
||||
|
||||
// version
|
||||
// Required: true
|
||||
Version string `json:"Version"`
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// PluginsListResponse contains the response for the Engine API
|
||||
type PluginsListResponse []*Plugin
|
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType
|
||||
func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error {
|
||||
versionIndex := len(p)
|
||||
prefixIndex := 0
|
||||
if len(p) < 2 || p[0] != '"' || p[len(p)-1] != '"' {
|
||||
return fmt.Errorf("%q is not a plugin interface type", p)
|
||||
}
|
||||
p = p[1 : len(p)-1]
|
||||
loop:
|
||||
for i, b := range p {
|
||||
switch b {
|
||||
case '.':
|
||||
prefixIndex = i
|
||||
case '/':
|
||||
versionIndex = i
|
||||
break loop
|
||||
}
|
||||
}
|
||||
t.Prefix = string(p[:prefixIndex])
|
||||
t.Capability = string(p[prefixIndex+1 : versionIndex])
|
||||
if versionIndex < len(p) {
|
||||
t.Version = string(p[versionIndex+1:])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler for PluginInterfaceType
|
||||
func (t *PluginInterfaceType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.String())
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer for PluginInterfaceType
|
||||
func (t PluginInterfaceType) String() string {
|
||||
return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version)
|
||||
}
|
||||
|
||||
// PluginPrivilege describes a permission the user has to accept
|
||||
// upon installing a plugin.
|
||||
type PluginPrivilege struct {
|
||||
Name string
|
||||
Description string
|
||||
Value []string
|
||||
}
|
||||
|
||||
// PluginPrivileges is a list of PluginPrivilege
|
||||
type PluginPrivileges []PluginPrivilege
|
||||
|
||||
func (s PluginPrivileges) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s PluginPrivileges) Less(i, j int) bool {
|
||||
return s[i].Name < s[j].Name
|
||||
}
|
||||
|
||||
func (s PluginPrivileges) Swap(i, j int) {
|
||||
sort.Strings(s[i].Value)
|
||||
sort.Strings(s[j].Value)
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.23
|
||||
|
||||
package registry
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/moby/moby/api/pkg/authconfig"
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// AuthHeader is the name of the header used to send encoded registry
|
||||
// authorization credentials for registry operations (push/pull).
|
||||
const AuthHeader = registry.AuthHeader
|
||||
|
||||
// RequestAuthConfig is a function interface that clients can supply
|
||||
// to retry operations after getting an authorization error.
|
||||
//
|
||||
// The function must return the [AuthHeader] value ([AuthConfig]), encoded
|
||||
// in base64url format ([RFC4648, section 5]), which can be decoded by
|
||||
// [DecodeAuthConfig].
|
||||
//
|
||||
// It must return an error if the privilege request fails.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
type RequestAuthConfig = registry.RequestAuthConfig
|
||||
|
||||
// AuthConfig contains authorization information for connecting to a Registry.
|
||||
type AuthConfig = registry.AuthConfig
|
||||
|
||||
// EncodeAuthConfig serializes the auth configuration as a base64url encoded
|
||||
// ([RFC4648, section 5]) JSON string for sending through the X-Registry-Auth header.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
func EncodeAuthConfig(authConfig registry.AuthConfig) (string, error) {
|
||||
return authconfig.Encode(authConfig)
|
||||
}
|
||||
|
||||
// DecodeAuthConfig decodes base64url encoded ([RFC4648, section 5]) JSON
|
||||
// authentication information as sent through the X-Registry-Auth header.
|
||||
//
|
||||
// This function always returns an [AuthConfig], even if an error occurs. It is up
|
||||
// to the caller to decide if authentication is required, and if the error can
|
||||
// be ignored.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
func DecodeAuthConfig(authEncoded string) (*registry.AuthConfig, error) {
|
||||
return authconfig.Decode(authEncoded)
|
||||
}
|
||||
|
||||
// DecodeAuthConfigBody decodes authentication information as sent as JSON in the
|
||||
// body of a request. This function is to provide backward compatibility with old
|
||||
// clients and API versions. Current clients and API versions expect authentication
|
||||
// to be provided through the X-Registry-Auth header.
|
||||
//
|
||||
// Like [DecodeAuthConfig], this function always returns an [AuthConfig], even if an
|
||||
// error occurs. It is up to the caller to decide if authentication is required,
|
||||
// and if the error can be ignored.
|
||||
func DecodeAuthConfigBody(rdr io.ReadCloser) (*registry.AuthConfig, error) {
|
||||
return authconfig.DecodeRequestBody(rdr)
|
||||
}
|
||||
|
||||
// AuthenticateOKBody authenticate o k body
|
||||
type AuthenticateOKBody = registry.AuthenticateOKBody
|
||||
|
||||
// ServiceConfig stores daemon registry services configuration.
|
||||
type ServiceConfig = registry.ServiceConfig
|
||||
|
||||
// NetIPNet is the net.IPNet type, which can be marshalled and
|
||||
// unmarshalled to JSON
|
||||
type NetIPNet = registry.NetIPNet
|
||||
|
||||
// IndexInfo contains information about a registry
|
||||
type IndexInfo = registry.IndexInfo
|
||||
|
||||
// DistributionInspect describes the result obtained from contacting the
|
||||
// registry to retrieve image metadata
|
||||
type DistributionInspect = registry.DistributionInspect
|
||||
|
||||
// SearchOptions holds parameters to search images with.
|
||||
type SearchOptions = client.ImageSearchOptions
|
||||
|
||||
// SearchResult describes a search result returned from a registry
|
||||
type SearchResult = registry.SearchResult
|
||||
|
||||
// SearchResults lists a collection search results returned from a registry
|
||||
type SearchResults = registry.SearchResults
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
package registry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// AuthHeader is the name of the header used to send encoded registry
|
||||
// authorization credentials for registry operations (push/pull).
|
||||
const AuthHeader = "X-Registry-Auth"
|
||||
|
||||
// RequestAuthConfig is a function interface that clients can supply
|
||||
// to retry operations after getting an authorization error.
|
||||
//
|
||||
// The function must return the [AuthHeader] value ([AuthConfig]), encoded
|
||||
// in base64url format ([RFC4648, section 5]), which can be decoded by
|
||||
// [DecodeAuthConfig].
|
||||
//
|
||||
// It must return an error if the privilege request fails.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
type RequestAuthConfig func(context.Context) (string, error)
|
||||
|
||||
// AuthConfig contains authorization information for connecting to a Registry.
|
||||
type AuthConfig struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Auth string `json:"auth,omitempty"`
|
||||
|
||||
// Email is an optional value associated with the username.
|
||||
//
|
||||
// Deprecated: This field is deprecated since docker 1.11 (API v1.23) and will be removed in the next release.
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
ServerAddress string `json:"serveraddress,omitempty"`
|
||||
|
||||
// IdentityToken is used to authenticate the user and get
|
||||
// an access token for the registry.
|
||||
IdentityToken string `json:"identitytoken,omitempty"`
|
||||
|
||||
// RegistryToken is a bearer token to be sent to a registry
|
||||
RegistryToken string `json:"registrytoken,omitempty"`
|
||||
}
|
||||
|
||||
// EncodeAuthConfig serializes the auth configuration as a base64url encoded
|
||||
// ([RFC4648, section 5]) JSON string for sending through the X-Registry-Auth header.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
func EncodeAuthConfig(authConfig AuthConfig) (string, error) {
|
||||
buf, err := json.Marshal(authConfig)
|
||||
if err != nil {
|
||||
return "", errInvalidParameter{err}
|
||||
}
|
||||
return base64.URLEncoding.EncodeToString(buf), nil
|
||||
}
|
||||
|
||||
// DecodeAuthConfig decodes base64url encoded ([RFC4648, section 5]) JSON
|
||||
// authentication information as sent through the X-Registry-Auth header.
|
||||
//
|
||||
// This function always returns an [AuthConfig], even if an error occurs. It is up
|
||||
// to the caller to decide if authentication is required, and if the error can
|
||||
// be ignored.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
func DecodeAuthConfig(authEncoded string) (*AuthConfig, error) {
|
||||
if authEncoded == "" {
|
||||
return &AuthConfig{}, nil
|
||||
}
|
||||
|
||||
authJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authEncoded))
|
||||
return decodeAuthConfigFromReader(authJSON)
|
||||
}
|
||||
|
||||
// DecodeAuthConfigBody decodes authentication information as sent as JSON in the
|
||||
// body of a request. This function is to provide backward compatibility with old
|
||||
// clients and API versions. Current clients and API versions expect authentication
|
||||
// to be provided through the X-Registry-Auth header.
|
||||
//
|
||||
// Like [DecodeAuthConfig], this function always returns an [AuthConfig], even if an
|
||||
// error occurs. It is up to the caller to decide if authentication is required,
|
||||
// and if the error can be ignored.
|
||||
//
|
||||
// Deprecated: this function is no longer used and will be removed in the next release.
|
||||
func DecodeAuthConfigBody(rdr io.ReadCloser) (*AuthConfig, error) {
|
||||
return decodeAuthConfigFromReader(rdr)
|
||||
}
|
||||
|
||||
func decodeAuthConfigFromReader(rdr io.Reader) (*AuthConfig, error) {
|
||||
authConfig := &AuthConfig{}
|
||||
if err := json.NewDecoder(rdr).Decode(authConfig); err != nil {
|
||||
// always return an (empty) AuthConfig to increase compatibility with
|
||||
// the existing API.
|
||||
return &AuthConfig{}, invalid(err)
|
||||
}
|
||||
return authConfig, nil
|
||||
}
|
||||
|
||||
func invalid(err error) error {
|
||||
return errInvalidParameter{fmt.Errorf("invalid X-Registry-Auth header: %w", err)}
|
||||
}
|
||||
|
||||
type errInvalidParameter struct{ error }
|
||||
|
||||
func (errInvalidParameter) InvalidParameter() {}
|
||||
|
||||
func (e errInvalidParameter) Cause() error { return e.error }
|
||||
|
||||
func (e errInvalidParameter) Unwrap() error { return e.error }
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package strslice
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// StrSlice represents a string or an array of strings.
|
||||
// We need to override the json decoder to accept both options.
|
||||
type StrSlice []string
|
||||
|
||||
// UnmarshalJSON decodes the byte slice whether it's a string or an array of
|
||||
// strings. This method is needed to implement json.Unmarshaler.
|
||||
func (e *StrSlice) UnmarshalJSON(b []byte) error {
|
||||
if len(b) == 0 {
|
||||
// With no input, we preserve the existing value by returning nil and
|
||||
// leaving the target alone. This allows defining default values for
|
||||
// the type.
|
||||
return nil
|
||||
}
|
||||
|
||||
p := make([]string, 0, 1)
|
||||
if err := json.Unmarshal(b, &p); err != nil {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
p = append(p, s)
|
||||
}
|
||||
|
||||
*e = p
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,579 @@
|
|||
package swarm
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// Version represents the internal object version.
|
||||
type Version = swarm.Version
|
||||
|
||||
// Meta is a base object inherited by most of the other once.
|
||||
type Meta = swarm.Meta
|
||||
|
||||
// Annotations represents how to describe an object.
|
||||
type Annotations = swarm.Annotations
|
||||
|
||||
// Driver represents a driver (network, logging, secrets backend).
|
||||
type Driver = swarm.Driver
|
||||
|
||||
// TLSInfo represents the TLS information about what CA certificate is trusted,
|
||||
// and who the issuer for a TLS certificate is
|
||||
type TLSInfo = swarm.TLSInfo
|
||||
|
||||
// Config represents a config.
|
||||
type Config = swarm.Config
|
||||
|
||||
// ConfigSpec represents a config specification from a config in swarm
|
||||
type ConfigSpec = swarm.ConfigSpec
|
||||
|
||||
// ConfigReferenceFileTarget is a file target in a config reference
|
||||
type ConfigReferenceFileTarget = swarm.ConfigReferenceFileTarget
|
||||
|
||||
// ConfigReferenceRuntimeTarget is a target for a config specifying that it
|
||||
// isn't mounted into the container but instead has some other purpose.
|
||||
type ConfigReferenceRuntimeTarget = swarm.ConfigReferenceRuntimeTarget
|
||||
|
||||
// ConfigReference is a reference to a config in swarm
|
||||
type ConfigReference = swarm.ConfigReference
|
||||
|
||||
// ConfigCreateResponse contains the information returned to a client
|
||||
// on the creation of a new config.
|
||||
type ConfigCreateResponse = swarm.ConfigCreateResponse
|
||||
|
||||
// ConfigListOptions holds parameters to list configs
|
||||
type ConfigListOptions = client.ConfigListOptions
|
||||
|
||||
// DNSConfig specifies DNS related configurations in resolver configuration file (resolv.conf)
|
||||
type DNSConfig = swarm.DNSConfig
|
||||
|
||||
// SELinuxContext contains the SELinux labels of the container.
|
||||
type SELinuxContext = swarm.SELinuxContext
|
||||
|
||||
// SeccompMode is the type used for the enumeration of possible seccomp modes
|
||||
// in SeccompOpts
|
||||
type SeccompMode = swarm.SeccompMode
|
||||
|
||||
const (
|
||||
SeccompModeDefault = swarm.SeccompModeDefault
|
||||
SeccompModeUnconfined = swarm.SeccompModeUnconfined
|
||||
SeccompModeCustom = swarm.SeccompModeCustom
|
||||
)
|
||||
|
||||
// SeccompOpts defines the options for configuring seccomp on a swarm-managed
|
||||
// container.
|
||||
type SeccompOpts = swarm.SeccompOpts
|
||||
|
||||
// AppArmorMode is type used for the enumeration of possible AppArmor modes in
|
||||
// AppArmorOpts
|
||||
type AppArmorMode = swarm.AppArmorMode
|
||||
|
||||
const (
|
||||
AppArmorModeDefault = swarm.AppArmorModeDefault
|
||||
AppArmorModeDisabled = swarm.AppArmorModeDisabled
|
||||
)
|
||||
|
||||
// AppArmorOpts defines the options for configuring AppArmor on a swarm-managed
|
||||
// container. Currently, custom AppArmor profiles are not supported.
|
||||
type AppArmorOpts = swarm.AppArmorOpts
|
||||
|
||||
// CredentialSpec for managed service account (Windows only)
|
||||
type CredentialSpec = swarm.CredentialSpec
|
||||
|
||||
// Privileges defines the security options for the container.
|
||||
type Privileges = swarm.Privileges
|
||||
|
||||
// ContainerSpec represents the spec of a container.
|
||||
type ContainerSpec = swarm.ContainerSpec
|
||||
|
||||
// Endpoint represents an endpoint.
|
||||
type Endpoint = swarm.Endpoint
|
||||
|
||||
// EndpointSpec represents the spec of an endpoint.
|
||||
type EndpointSpec = swarm.EndpointSpec
|
||||
|
||||
// ResolutionMode represents a resolution mode.
|
||||
type ResolutionMode = swarm.ResolutionMode
|
||||
|
||||
const (
|
||||
// ResolutionModeVIP VIP
|
||||
ResolutionModeVIP = swarm.ResolutionModeVIP
|
||||
// ResolutionModeDNSRR DNSRR
|
||||
ResolutionModeDNSRR = swarm.ResolutionModeDNSRR
|
||||
)
|
||||
|
||||
// PortConfig represents the config of a port.
|
||||
type PortConfig = swarm.PortConfig
|
||||
|
||||
// PortConfigPublishMode represents the mode in which the port is to
|
||||
// be published.
|
||||
type PortConfigPublishMode = swarm.PortConfigPublishMode
|
||||
|
||||
const (
|
||||
// PortConfigPublishModeIngress is used for ports published
|
||||
// for ingress load balancing using routing mesh.
|
||||
PortConfigPublishModeIngress = swarm.PortConfigPublishModeIngress
|
||||
// PortConfigPublishModeHost is used for ports published
|
||||
// for direct host level access on the host where the task is running.
|
||||
PortConfigPublishModeHost = swarm.PortConfigPublishModeHost
|
||||
)
|
||||
|
||||
// PortConfigProtocol represents the protocol of a port.
|
||||
type PortConfigProtocol = swarm.PortConfigProtocol
|
||||
|
||||
const (
|
||||
// PortConfigProtocolTCP TCP
|
||||
PortConfigProtocolTCP = swarm.PortConfigProtocolTCP
|
||||
// PortConfigProtocolUDP UDP
|
||||
PortConfigProtocolUDP = swarm.PortConfigProtocolUDP
|
||||
// PortConfigProtocolSCTP SCTP
|
||||
PortConfigProtocolSCTP = swarm.PortConfigProtocolSCTP
|
||||
)
|
||||
|
||||
// EndpointVirtualIP represents the virtual ip of a port.
|
||||
type EndpointVirtualIP = swarm.EndpointVirtualIP
|
||||
|
||||
// Network represents a network.
|
||||
type Network = swarm.Network
|
||||
|
||||
// NetworkSpec represents the spec of a network.
|
||||
type NetworkSpec = swarm.NetworkSpec
|
||||
|
||||
// NetworkAttachmentConfig represents the configuration of a network attachment.
|
||||
type NetworkAttachmentConfig = swarm.NetworkAttachmentConfig
|
||||
|
||||
// NetworkAttachment represents a network attachment.
|
||||
type NetworkAttachment = swarm.NetworkAttachment
|
||||
|
||||
// IPAMOptions represents ipam options.
|
||||
type IPAMOptions = swarm.IPAMOptions
|
||||
|
||||
// IPAMConfig represents ipam configuration.
|
||||
type IPAMConfig = swarm.IPAMConfig
|
||||
|
||||
// Node represents a node.
|
||||
type Node = swarm.Node
|
||||
|
||||
// NodeSpec represents the spec of a node.
|
||||
type NodeSpec = swarm.NodeSpec
|
||||
|
||||
// NodeRole represents the role of a node.
|
||||
type NodeRole = swarm.NodeRole
|
||||
|
||||
const (
|
||||
// NodeRoleWorker WORKER
|
||||
NodeRoleWorker = swarm.NodeRoleWorker
|
||||
// NodeRoleManager MANAGER
|
||||
NodeRoleManager = swarm.NodeRoleManager
|
||||
)
|
||||
|
||||
// NodeAvailability represents the availability of a node.
|
||||
type NodeAvailability = swarm.NodeAvailability
|
||||
|
||||
const (
|
||||
// NodeAvailabilityActive ACTIVE
|
||||
NodeAvailabilityActive = swarm.NodeAvailabilityActive
|
||||
// NodeAvailabilityPause PAUSE
|
||||
NodeAvailabilityPause = swarm.NodeAvailabilityPause
|
||||
// NodeAvailabilityDrain DRAIN
|
||||
NodeAvailabilityDrain = swarm.NodeAvailabilityDrain
|
||||
)
|
||||
|
||||
// NodeDescription represents the description of a node.
|
||||
type NodeDescription = swarm.NodeDescription
|
||||
|
||||
// Platform represents the platform (Arch/OS).
|
||||
type Platform = swarm.Platform
|
||||
|
||||
// EngineDescription represents the description of an engine.
|
||||
type EngineDescription = swarm.EngineDescription
|
||||
|
||||
// NodeCSIInfo represents information about a CSI plugin available on the node
|
||||
type NodeCSIInfo = swarm.NodeCSIInfo
|
||||
|
||||
// PluginDescription represents the description of an engine plugin.
|
||||
type PluginDescription = swarm.PluginDescription
|
||||
|
||||
// NodeStatus represents the status of a node.
|
||||
type NodeStatus = swarm.NodeStatus
|
||||
|
||||
// Reachability represents the reachability of a node.
|
||||
type Reachability = swarm.Reachability
|
||||
|
||||
const (
|
||||
// ReachabilityUnknown UNKNOWN
|
||||
ReachabilityUnknown = swarm.ReachabilityUnknown
|
||||
// ReachabilityUnreachable UNREACHABLE
|
||||
ReachabilityUnreachable = swarm.ReachabilityUnreachable
|
||||
// ReachabilityReachable REACHABLE
|
||||
ReachabilityReachable = swarm.ReachabilityReachable
|
||||
)
|
||||
|
||||
// ManagerStatus represents the status of a manager.
|
||||
type ManagerStatus = swarm.ManagerStatus
|
||||
|
||||
// NodeState represents the state of a node.
|
||||
type NodeState = swarm.NodeState
|
||||
|
||||
const (
|
||||
// NodeStateUnknown UNKNOWN
|
||||
NodeStateUnknown = swarm.NodeStateUnknown
|
||||
// NodeStateDown DOWN
|
||||
NodeStateDown = swarm.NodeStateDown
|
||||
// NodeStateReady READY
|
||||
NodeStateReady = swarm.NodeStateReady
|
||||
// NodeStateDisconnected DISCONNECTED
|
||||
NodeStateDisconnected = swarm.NodeStateDisconnected
|
||||
)
|
||||
|
||||
// Topology defines the CSI topology of this node. This type is a duplicate of
|
||||
// github.com/docker/docker/api/types.Topology. Because the type definition
|
||||
// is so simple and to avoid complicated structure or circular imports, we just
|
||||
// duplicate it here. See that type for full documentation
|
||||
type Topology = swarm.Topology
|
||||
|
||||
// NodeListOptions holds parameters to list nodes with.
|
||||
type NodeListOptions = client.NodeListOptions
|
||||
|
||||
// NodeRemoveOptions holds parameters to remove nodes with.
|
||||
type NodeRemoveOptions = client.NodeRemoveOptions
|
||||
|
||||
// RuntimeType is the type of runtime used for the TaskSpec
|
||||
type RuntimeType = swarm.RuntimeType
|
||||
|
||||
// RuntimeURL is the proto type url
|
||||
type RuntimeURL = swarm.RuntimeURL
|
||||
|
||||
const (
|
||||
// RuntimeContainer is the container based runtime
|
||||
RuntimeContainer = swarm.RuntimeContainer
|
||||
// RuntimePlugin is the plugin based runtime
|
||||
RuntimePlugin = swarm.RuntimePlugin
|
||||
// RuntimeNetworkAttachment is the network attachment runtime
|
||||
RuntimeNetworkAttachment = swarm.RuntimeNetworkAttachment
|
||||
|
||||
// RuntimeURLContainer is the proto url for the container type
|
||||
RuntimeURLContainer = swarm.RuntimeURLContainer
|
||||
// RuntimeURLPlugin is the proto url for the plugin type
|
||||
RuntimeURLPlugin = swarm.RuntimeURLPlugin
|
||||
)
|
||||
|
||||
// NetworkAttachmentSpec represents the runtime spec type for network
|
||||
// attachment tasks
|
||||
type NetworkAttachmentSpec = swarm.NetworkAttachmentSpec
|
||||
|
||||
// Secret represents a secret.
|
||||
type Secret = swarm.Secret
|
||||
|
||||
// SecretSpec represents a secret specification from a secret in swarm
|
||||
type SecretSpec = swarm.SecretSpec
|
||||
|
||||
// SecretReferenceFileTarget is a file target in a secret reference
|
||||
type SecretReferenceFileTarget = swarm.SecretReferenceFileTarget
|
||||
|
||||
// SecretReference is a reference to a secret in swarm
|
||||
type SecretReference = swarm.SecretReference
|
||||
|
||||
// SecretCreateResponse contains the information returned to a client
|
||||
// on the creation of a new secret.
|
||||
type SecretCreateResponse = swarm.SecretCreateResponse
|
||||
|
||||
// SecretListOptions holds parameters to list secrets
|
||||
type SecretListOptions = client.SecretListOptions
|
||||
|
||||
// Service represents a service.
|
||||
type Service = swarm.Service
|
||||
|
||||
// ServiceSpec represents the spec of a service.
|
||||
type ServiceSpec = swarm.ServiceSpec
|
||||
|
||||
// ServiceMode represents the mode of a service.
|
||||
type ServiceMode = swarm.ServiceMode
|
||||
|
||||
// UpdateState is the state of a service update.
|
||||
type UpdateState = swarm.UpdateState
|
||||
|
||||
const (
|
||||
// UpdateStateUpdating is the updating state.
|
||||
UpdateStateUpdating = swarm.UpdateStateUpdating
|
||||
// UpdateStatePaused is the paused state.
|
||||
UpdateStatePaused = swarm.UpdateStatePaused
|
||||
// UpdateStateCompleted is the completed state.
|
||||
UpdateStateCompleted = swarm.UpdateStateCompleted
|
||||
// UpdateStateRollbackStarted is the state with a rollback in progress.
|
||||
UpdateStateRollbackStarted = swarm.UpdateStateRollbackStarted
|
||||
// UpdateStateRollbackPaused is the state with a rollback in progress.
|
||||
UpdateStateRollbackPaused = swarm.UpdateStateRollbackPaused
|
||||
// UpdateStateRollbackCompleted is the state with a rollback in progress.
|
||||
UpdateStateRollbackCompleted = swarm.UpdateStateRollbackCompleted
|
||||
)
|
||||
|
||||
// UpdateStatus reports the status of a service update.
|
||||
type UpdateStatus = swarm.UpdateStatus
|
||||
|
||||
// ReplicatedService is a kind of ServiceMode.
|
||||
type ReplicatedService = swarm.ReplicatedService
|
||||
|
||||
// GlobalService is a kind of ServiceMode.
|
||||
type GlobalService = swarm.GlobalService
|
||||
|
||||
// ReplicatedJob is the a type of Service which executes a defined Tasks
|
||||
// in parallel until the specified number of Tasks have succeeded.
|
||||
type ReplicatedJob = swarm.ReplicatedJob
|
||||
|
||||
// GlobalJob is the type of a Service which executes a Task on every Node
|
||||
// matching the Service's placement constraints. These tasks run to completion
|
||||
// and then exit.
|
||||
//
|
||||
// This type is deliberately empty.
|
||||
type GlobalJob = swarm.GlobalJob
|
||||
|
||||
const (
|
||||
// UpdateFailureActionPause PAUSE
|
||||
UpdateFailureActionPause = swarm.UpdateFailureActionPause
|
||||
// UpdateFailureActionContinue CONTINUE
|
||||
UpdateFailureActionContinue = swarm.UpdateFailureActionContinue
|
||||
// UpdateFailureActionRollback ROLLBACK
|
||||
UpdateFailureActionRollback = swarm.UpdateFailureActionRollback
|
||||
|
||||
// UpdateOrderStopFirst STOP_FIRST
|
||||
UpdateOrderStopFirst = swarm.UpdateOrderStopFirst
|
||||
// UpdateOrderStartFirst START_FIRST
|
||||
UpdateOrderStartFirst = swarm.UpdateOrderStartFirst
|
||||
)
|
||||
|
||||
// UpdateConfig represents the update configuration.
|
||||
type UpdateConfig = swarm.UpdateConfig
|
||||
|
||||
// ServiceStatus represents the number of running tasks in a service and the
|
||||
// number of tasks desired to be running.
|
||||
type ServiceStatus = swarm.ServiceStatus
|
||||
|
||||
// JobStatus is the status of a job-type service.
|
||||
type JobStatus = swarm.JobStatus
|
||||
|
||||
// ServiceCreateOptions contains the options to use when creating a service.
|
||||
type ServiceCreateOptions = client.ServiceCreateOptions
|
||||
|
||||
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
||||
const (
|
||||
RegistryAuthFromSpec = swarm.RegistryAuthFromSpec
|
||||
RegistryAuthFromPreviousSpec = swarm.RegistryAuthFromPreviousSpec
|
||||
)
|
||||
|
||||
// ServiceUpdateOptions contains the options to be used for updating services.
|
||||
type ServiceUpdateOptions = client.ServiceUpdateOptions
|
||||
|
||||
// ServiceListOptions holds parameters to list services with.
|
||||
type ServiceListOptions = client.ServiceListOptions
|
||||
|
||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||
// operation.
|
||||
type ServiceInspectOptions = client.ServiceInspectOptions
|
||||
|
||||
// ServiceCreateResponse contains the information returned to a client on the
|
||||
// creation of a new service.
|
||||
type ServiceCreateResponse = swarm.ServiceCreateResponse
|
||||
|
||||
// ServiceUpdateResponse service update response
|
||||
type ServiceUpdateResponse = swarm.ServiceUpdateResponse
|
||||
|
||||
// ClusterInfo represents info about the cluster for outputting in "info"
|
||||
// it contains the same information as "Swarm", but without the JoinTokens
|
||||
type ClusterInfo = swarm.ClusterInfo
|
||||
|
||||
// Swarm represents a swarm.
|
||||
type Swarm = swarm.Swarm
|
||||
|
||||
// JoinTokens contains the tokens workers and managers need to join the swarm.
|
||||
type JoinTokens = swarm.JoinTokens
|
||||
|
||||
// Spec represents the spec of a swarm.
|
||||
type Spec = swarm.Spec
|
||||
|
||||
// OrchestrationConfig represents orchestration configuration.
|
||||
type OrchestrationConfig = swarm.OrchestrationConfig
|
||||
|
||||
// TaskDefaults parameterizes cluster-level task creation with default values.
|
||||
type TaskDefaults = swarm.TaskDefaults
|
||||
|
||||
// EncryptionConfig controls at-rest encryption of data and keys.
|
||||
type EncryptionConfig = swarm.EncryptionConfig
|
||||
|
||||
// RaftConfig represents raft configuration.
|
||||
type RaftConfig = swarm.RaftConfig
|
||||
|
||||
// DispatcherConfig represents dispatcher configuration.
|
||||
type DispatcherConfig = swarm.DispatcherConfig
|
||||
|
||||
// CAConfig represents CA configuration.
|
||||
type CAConfig = swarm.CAConfig
|
||||
|
||||
// ExternalCAProtocol represents type of external CA.
|
||||
type ExternalCAProtocol = swarm.ExternalCAProtocol
|
||||
|
||||
// ExternalCAProtocolCFSSL CFSSL
|
||||
const ExternalCAProtocolCFSSL = swarm.ExternalCAProtocolCFSSL
|
||||
|
||||
// ExternalCA defines external CA to be used by the cluster.
|
||||
type ExternalCA = swarm.ExternalCA
|
||||
|
||||
// InitRequest is the request used to init a swarm.
|
||||
type InitRequest = swarm.InitRequest
|
||||
|
||||
// JoinRequest is the request used to join a swarm.
|
||||
type JoinRequest = swarm.JoinRequest
|
||||
|
||||
// UnlockRequest is the request used to unlock a swarm.
|
||||
type UnlockRequest = swarm.UnlockRequest
|
||||
|
||||
// LocalNodeState represents the state of the local node.
|
||||
type LocalNodeState = swarm.LocalNodeState
|
||||
|
||||
const (
|
||||
// LocalNodeStateInactive INACTIVE
|
||||
LocalNodeStateInactive = swarm.LocalNodeStateInactive
|
||||
// LocalNodeStatePending PENDING
|
||||
LocalNodeStatePending = swarm.LocalNodeStatePending
|
||||
// LocalNodeStateActive ACTIVE
|
||||
LocalNodeStateActive = swarm.LocalNodeStateActive
|
||||
// LocalNodeStateError ERROR
|
||||
LocalNodeStateError = swarm.LocalNodeStateError
|
||||
// LocalNodeStateLocked LOCKED
|
||||
LocalNodeStateLocked = swarm.LocalNodeStateLocked
|
||||
)
|
||||
|
||||
// Info represents generic information about swarm.
|
||||
type Info = swarm.Info
|
||||
|
||||
// Status provides information about the current swarm status and role,
|
||||
// obtained from the "Swarm" header in the API response.
|
||||
type Status = swarm.Status
|
||||
|
||||
// Peer represents a peer.
|
||||
type Peer = swarm.Peer
|
||||
|
||||
// UpdateFlags contains flags for SwarmUpdate.
|
||||
type UpdateFlags = client.SwarmUpdateFlags
|
||||
|
||||
// UnlockKeyResponse contains the response for Engine API:
|
||||
// GET /swarm/unlockkey
|
||||
type UnlockKeyResponse = swarm.UnlockKeyResponse
|
||||
|
||||
// TaskState represents the state of a task.
|
||||
type TaskState = swarm.TaskState
|
||||
|
||||
const (
|
||||
// TaskStateNew NEW
|
||||
TaskStateNew = swarm.TaskStateNew
|
||||
// TaskStateAllocated ALLOCATED
|
||||
TaskStateAllocated = swarm.TaskStateAllocated
|
||||
// TaskStatePending PENDING
|
||||
TaskStatePending = swarm.TaskStatePending
|
||||
// TaskStateAssigned ASSIGNED
|
||||
TaskStateAssigned = swarm.TaskStateAssigned
|
||||
// TaskStateAccepted ACCEPTED
|
||||
TaskStateAccepted = swarm.TaskStateAccepted
|
||||
// TaskStatePreparing PREPARING
|
||||
TaskStatePreparing = swarm.TaskStatePreparing
|
||||
// TaskStateReady READY
|
||||
TaskStateReady = swarm.TaskStateReady
|
||||
// TaskStateStarting STARTING
|
||||
TaskStateStarting = swarm.TaskStateStarting
|
||||
// TaskStateRunning RUNNING
|
||||
TaskStateRunning = swarm.TaskStateRunning
|
||||
// TaskStateComplete COMPLETE
|
||||
TaskStateComplete = swarm.TaskStateComplete
|
||||
// TaskStateShutdown SHUTDOWN
|
||||
TaskStateShutdown = swarm.TaskStateShutdown
|
||||
// TaskStateFailed FAILED
|
||||
TaskStateFailed = swarm.TaskStateFailed
|
||||
// TaskStateRejected REJECTED
|
||||
TaskStateRejected = swarm.TaskStateRejected
|
||||
// TaskStateRemove REMOVE
|
||||
TaskStateRemove = swarm.TaskStateRemove
|
||||
// TaskStateOrphaned ORPHANED
|
||||
TaskStateOrphaned = swarm.TaskStateOrphaned
|
||||
)
|
||||
|
||||
// Task represents a task.
|
||||
type Task = swarm.Task
|
||||
|
||||
// TaskSpec represents the spec of a task.
|
||||
type TaskSpec = swarm.TaskSpec
|
||||
|
||||
// Resources represents resources (CPU/Memory) which can be advertised by a
|
||||
// node and requested to be reserved for a task.
|
||||
type Resources = swarm.Resources
|
||||
|
||||
// Limit describes limits on resources which can be requested by a task.
|
||||
type Limit = swarm.Limit
|
||||
|
||||
// GenericResource represents a "user defined" resource which can
|
||||
// be either an integer (e.g: SSD=3) or a string (e.g: SSD=sda1)
|
||||
type GenericResource = swarm.GenericResource
|
||||
|
||||
// NamedGenericResource represents a "user defined" resource which is defined
|
||||
// as a string.
|
||||
// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...)
|
||||
// Value is used to identify the resource (GPU="UUID-1", FPGA="/dev/sdb5", ...)
|
||||
type NamedGenericResource = swarm.NamedGenericResource
|
||||
|
||||
// DiscreteGenericResource represents a "user defined" resource which is defined
|
||||
// as an integer
|
||||
// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...)
|
||||
// Value is used to count the resource (SSD=5, HDD=3, ...)
|
||||
type DiscreteGenericResource = swarm.DiscreteGenericResource
|
||||
|
||||
// ResourceRequirements represents resources requirements.
|
||||
type ResourceRequirements = swarm.ResourceRequirements
|
||||
|
||||
// Placement represents orchestration parameters.
|
||||
type Placement = swarm.Placement
|
||||
|
||||
// PlacementPreference provides a way to make the scheduler aware of factors
|
||||
// such as topology.
|
||||
type PlacementPreference = swarm.PlacementPreference
|
||||
|
||||
// SpreadOver is a scheduling preference that instructs the scheduler to spread
|
||||
// tasks evenly over groups of nodes identified by labels.
|
||||
type SpreadOver = swarm.SpreadOver
|
||||
|
||||
// RestartPolicy represents the restart policy.
|
||||
type RestartPolicy = swarm.RestartPolicy
|
||||
|
||||
// RestartPolicyCondition represents when to restart.
|
||||
type RestartPolicyCondition = swarm.RestartPolicyCondition
|
||||
|
||||
const (
|
||||
// RestartPolicyConditionNone NONE
|
||||
RestartPolicyConditionNone = swarm.RestartPolicyConditionNone
|
||||
// RestartPolicyConditionOnFailure ON_FAILURE
|
||||
RestartPolicyConditionOnFailure = swarm.RestartPolicyConditionOnFailure
|
||||
// RestartPolicyConditionAny ANY
|
||||
RestartPolicyConditionAny = swarm.RestartPolicyConditionAny
|
||||
)
|
||||
|
||||
// TaskStatus represents the status of a task.
|
||||
type TaskStatus = swarm.TaskStatus
|
||||
|
||||
// ContainerStatus represents the status of a container.
|
||||
type ContainerStatus = swarm.ContainerStatus
|
||||
|
||||
// PortStatus represents the port status of a task's host ports whose
|
||||
// service has published host ports
|
||||
type PortStatus = swarm.PortStatus
|
||||
|
||||
// VolumeAttachment contains the associating a Volume to a Task.
|
||||
type VolumeAttachment = swarm.VolumeAttachment
|
||||
|
||||
// TaskListOptions holds parameters to list tasks with.
|
||||
type TaskListOptions = client.TaskListOptions
|
||||
|
||||
// RuntimeSpec defines the base payload which clients can specify for creating
|
||||
// a service with the plugin runtime.
|
||||
type RuntimeSpec = swarm.RuntimeSpec
|
||||
|
||||
// RuntimePrivilege describes a permission the user has to accept
|
||||
// upon installing a plugin.
|
||||
type RuntimePrivilege = swarm.RuntimePrivilege
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package runtime
|
||||
|
||||
import "fmt"
|
||||
|
||||
// PluginSpec defines the base payload which clients can specify for creating
|
||||
// a service with the plugin runtime.
|
||||
type PluginSpec struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Remote string `json:"remote,omitempty"`
|
||||
Privileges []*PluginPrivilege `json:"privileges,omitempty"`
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
Env []string `json:"env,omitempty"`
|
||||
}
|
||||
|
||||
// PluginPrivilege describes a permission the user has to accept
|
||||
// upon installing a plugin.
|
||||
type PluginPrivilege struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Value []string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthPlugin = fmt.Errorf("proto: negative length found during unmarshaling") // Deprecated: this error was only used internally and is no longer used.
|
||||
ErrIntOverflowPlugin = fmt.Errorf("proto: integer overflow") // Deprecated: this error was only used internally and is no longer used.
|
||||
ErrUnexpectedEndOfGroupPlugin = fmt.Errorf("proto: unexpected end of group") // Deprecated: this error was only used internally and is no longer used.
|
||||
)
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package system
|
||||
|
||||
import "github.com/moby/moby/api/types/system"
|
||||
|
||||
// DiskUsage contains response of Engine API for API 1.49 and greater:
|
||||
// GET "/system/df"
|
||||
type DiskUsage = system.DiskUsage
|
||||
|
||||
// Info contains response of Engine API:
|
||||
// GET "/info"
|
||||
type Info = system.Info
|
||||
|
||||
// ContainerdInfo holds information about the containerd instance used by the daemon.
|
||||
type ContainerdInfo = system.ContainerdInfo
|
||||
|
||||
// ContainerdNamespaces reflects the containerd namespaces used by the daemon.
|
||||
type ContainerdNamespaces = system.ContainerdNamespaces
|
||||
|
||||
// PluginsInfo is a temp struct holding Plugins name
|
||||
// registered with docker daemon. It is used by [Info] struct
|
||||
type PluginsInfo = system.PluginsInfo
|
||||
|
||||
// Commit holds the Git-commit (SHA1) that a binary was built from, as reported
|
||||
// in the version-string of external tools, such as containerd, or runC.
|
||||
type Commit = system.Commit
|
||||
|
||||
// NetworkAddressPool is a temp struct used by [Info] struct.
|
||||
type NetworkAddressPool = system.NetworkAddressPool
|
||||
|
||||
// FirewallInfo describes the firewall backend.
|
||||
type FirewallInfo = system.FirewallInfo
|
||||
|
||||
// DeviceInfo represents a discoverable device from a device driver.
|
||||
type DeviceInfo = system.DeviceInfo
|
||||
|
||||
// Runtime describes an OCI runtime
|
||||
type Runtime = system.Runtime
|
||||
|
||||
// RuntimeWithStatus extends [Runtime] to hold [RuntimeStatus].
|
||||
type RuntimeWithStatus = system.RuntimeWithStatus
|
||||
|
||||
// SecurityOpt contains the name and options of a security option
|
||||
type SecurityOpt = system.SecurityOpt
|
||||
|
||||
// DecodeSecurityOptions decodes a security options string slice to a
|
||||
// type-safe [SecurityOpt].
|
||||
func DecodeSecurityOptions(opts []string) ([]system.SecurityOpt, error) {
|
||||
return system.DecodeSecurityOptions(opts)
|
||||
}
|
||||
|
||||
// KeyValue holds a key/value pair.
|
||||
type KeyValue = system.KeyValue
|
||||
|
|
@ -3,12 +3,13 @@ package types
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/docker/api/types/build"
|
||||
"github.com/docker/docker/api/types/common"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/api/types/storage"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/common"
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// IDResponse Response to an API call that returns just an Id.
|
||||
|
|
@ -125,7 +126,7 @@ type SecretCreateResponse = swarm.SecretCreateResponse
|
|||
// SecretListOptions holds parameters to list secrets
|
||||
//
|
||||
// Deprecated: use [swarm.SecretListOptions].
|
||||
type SecretListOptions = swarm.SecretListOptions
|
||||
type SecretListOptions = client.SecretListOptions
|
||||
|
||||
// ConfigCreateResponse contains the information returned to a client
|
||||
// on the creation of a new config.
|
||||
|
|
@ -136,32 +137,32 @@ type ConfigCreateResponse = swarm.ConfigCreateResponse
|
|||
// ConfigListOptions holds parameters to list configs
|
||||
//
|
||||
// Deprecated: use [swarm.ConfigListOptions].
|
||||
type ConfigListOptions = swarm.ConfigListOptions
|
||||
type ConfigListOptions = client.ConfigListOptions
|
||||
|
||||
// NodeListOptions holds parameters to list nodes with.
|
||||
//
|
||||
// Deprecated: use [swarm.NodeListOptions].
|
||||
type NodeListOptions = swarm.NodeListOptions
|
||||
type NodeListOptions = client.NodeListOptions
|
||||
|
||||
// NodeRemoveOptions holds parameters to remove nodes with.
|
||||
//
|
||||
// Deprecated: use [swarm.NodeRemoveOptions].
|
||||
type NodeRemoveOptions = swarm.NodeRemoveOptions
|
||||
type NodeRemoveOptions = client.NodeRemoveOptions
|
||||
|
||||
// TaskListOptions holds parameters to list tasks with.
|
||||
//
|
||||
// Deprecated: use [swarm.TaskListOptions].
|
||||
type TaskListOptions = swarm.TaskListOptions
|
||||
type TaskListOptions = client.TaskListOptions
|
||||
|
||||
// ServiceCreateOptions contains the options to use when creating a service.
|
||||
//
|
||||
// Deprecated: use [swarm.ServiceCreateOptions].
|
||||
type ServiceCreateOptions = swarm.ServiceCreateOptions
|
||||
type ServiceCreateOptions = client.ServiceCreateOptions
|
||||
|
||||
// ServiceUpdateOptions contains the options to be used for updating services.
|
||||
//
|
||||
// Deprecated: use [swarm.ServiceCreateOptions].
|
||||
type ServiceUpdateOptions = swarm.ServiceUpdateOptions
|
||||
type ServiceUpdateOptions = client.ServiceUpdateOptions
|
||||
|
||||
const (
|
||||
RegistryAuthFromSpec = swarm.RegistryAuthFromSpec // Deprecated: use [swarm.RegistryAuthFromSpec].
|
||||
|
|
@ -171,13 +172,13 @@ const (
|
|||
// ServiceListOptions holds parameters to list services with.
|
||||
//
|
||||
// Deprecated: use [swarm.ServiceListOptions].
|
||||
type ServiceListOptions = swarm.ServiceListOptions
|
||||
type ServiceListOptions = client.ServiceListOptions
|
||||
|
||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||
// operation.
|
||||
//
|
||||
// Deprecated: use [swarm.ServiceInspectOptions].
|
||||
type ServiceInspectOptions = swarm.ServiceInspectOptions
|
||||
type ServiceInspectOptions = client.ServiceInspectOptions
|
||||
|
||||
// SwarmUnlockKeyResponse contains the response for Engine API:
|
||||
// GET /swarm/unlockkey
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package versions
|
||||
|
||||
import "github.com/moby/moby/api/types/versions"
|
||||
|
||||
// LessThan checks if a version is less than another
|
||||
func LessThan(v, other string) bool {
|
||||
return versions.LessThan(v, other)
|
||||
}
|
||||
|
||||
// LessThanOrEqualTo checks if a version is less than or equal to another
|
||||
func LessThanOrEqualTo(v, other string) bool {
|
||||
return versions.LessThanOrEqualTo(v, other)
|
||||
}
|
||||
|
||||
// GreaterThan checks if a version is greater than another
|
||||
func GreaterThan(v, other string) bool {
|
||||
return versions.GreaterThan(v, other)
|
||||
}
|
||||
|
||||
// GreaterThanOrEqualTo checks if a version is greater than or equal to another
|
||||
func GreaterThanOrEqualTo(v, other string) bool {
|
||||
return versions.GreaterThanOrEqualTo(v, other)
|
||||
}
|
||||
|
||||
// Equal checks if a version is equal to another
|
||||
func Equal(v, other string) bool {
|
||||
return versions.Equal(v, other)
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
package volume
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// ClusterVolume contains options and information specific to, and only present
|
||||
// on, Swarm CSI cluster volumes.
|
||||
type ClusterVolume = volume.ClusterVolume
|
||||
|
||||
// ClusterVolumeSpec contains the spec used to create this volume.
|
||||
type ClusterVolumeSpec = volume.ClusterVolumeSpec
|
||||
|
||||
// Availability specifies the availability of the volume.
|
||||
type Availability = volume.Availability
|
||||
|
||||
const (
|
||||
// AvailabilityActive indicates that the volume is active and fully
|
||||
// schedulable on the cluster.
|
||||
AvailabilityActive = volume.AvailabilityActive
|
||||
|
||||
// AvailabilityPause indicates that no new workloads should use the
|
||||
// volume, but existing workloads can continue to use it.
|
||||
AvailabilityPause = volume.AvailabilityPause
|
||||
|
||||
// AvailabilityDrain indicates that all workloads using this volume
|
||||
// should be rescheduled, and the volume unpublished from all nodes.
|
||||
AvailabilityDrain = volume.AvailabilityDrain
|
||||
)
|
||||
|
||||
// AccessMode defines the access mode of a volume.
|
||||
type AccessMode = volume.AccessMode
|
||||
|
||||
// Scope defines the Scope of a Cluster Volume. This is how many nodes a
|
||||
// Volume can be accessed simultaneously on.
|
||||
type Scope = volume.Scope
|
||||
|
||||
const (
|
||||
// ScopeSingleNode indicates the volume can be used on one node at a
|
||||
// time.
|
||||
ScopeSingleNode = volume.ScopeSingleNode
|
||||
|
||||
// ScopeMultiNode indicates the volume can be used on many nodes at
|
||||
// the same time.
|
||||
ScopeMultiNode = volume.ScopeMultiNode
|
||||
)
|
||||
|
||||
// SharingMode defines the Sharing of a Cluster Volume. This is how Tasks using a
|
||||
// Volume at the same time can use it.
|
||||
type SharingMode = volume.SharingMode
|
||||
|
||||
const (
|
||||
// SharingNone indicates that only one Task may use the Volume at a
|
||||
// time.
|
||||
SharingNone = volume.SharingNone
|
||||
|
||||
// SharingReadOnly indicates that the Volume may be shared by any
|
||||
// number of Tasks, but they must be read-only.
|
||||
SharingReadOnly = volume.SharingReadOnly
|
||||
|
||||
// SharingOneWriter indicates that the Volume may be shared by any
|
||||
// number of Tasks, but all after the first must be read-only.
|
||||
SharingOneWriter = volume.SharingOneWriter
|
||||
|
||||
// SharingAll means that the Volume may be shared by any number of
|
||||
// Tasks, as readers or writers.
|
||||
SharingAll = volume.SharingAll
|
||||
)
|
||||
|
||||
// TypeBlock defines options for using a volume as a block-type volume.
|
||||
//
|
||||
// Intentionally empty.
|
||||
type TypeBlock = volume.TypeBlock
|
||||
|
||||
// TypeMount contains options for using a volume as a Mount-type
|
||||
// volume.
|
||||
type TypeMount = volume.TypeMount
|
||||
|
||||
// TopologyRequirement expresses the user's requirements for a volume's
|
||||
// accessible topology.
|
||||
type TopologyRequirement = volume.TopologyRequirement
|
||||
|
||||
// Topology is a map of topological domains to topological segments.
|
||||
type Topology = volume.Topology
|
||||
|
||||
// CapacityRange describes the minimum and maximum capacity a volume should be
|
||||
// created with
|
||||
type CapacityRange = volume.CapacityRange
|
||||
|
||||
// Secret represents a Swarm Secret value that must be passed to the CSI
|
||||
// storage plugin when operating on this Volume. It represents one key-value
|
||||
// pair of possibly many.
|
||||
type Secret = volume.Secret
|
||||
|
||||
// PublishState represents the state of a Volume as it pertains to its
|
||||
// use on a particular Node.
|
||||
type PublishState = volume.PublishState
|
||||
|
||||
const (
|
||||
// StatePending indicates that the volume should be published on
|
||||
// this node, but the call to ControllerPublishVolume has not been
|
||||
// successfully completed yet and the result recorded by swarmkit.
|
||||
StatePending = volume.StatePending
|
||||
|
||||
// StatePublished means the volume is published successfully to the node.
|
||||
StatePublished = volume.StatePublished
|
||||
// StatePendingNodeUnpublish indicates that the Volume should be
|
||||
// unpublished on the Node, and we're waiting for confirmation that it has
|
||||
// done so. After the Node has confirmed that the Volume has been
|
||||
// unpublished, the state will move to StatePendingUnpublish.
|
||||
StatePendingNodeUnpublish = volume.StatePendingNodeUnpublish
|
||||
|
||||
// StatePendingUnpublish means the volume is still published to the node
|
||||
// by the controller, awaiting the operation to unpublish it.
|
||||
StatePendingUnpublish = volume.StatePendingUnpublish
|
||||
)
|
||||
|
||||
// PublishStatus represents the status of the volume as published to an
|
||||
// individual node
|
||||
type PublishStatus = volume.PublishStatus
|
||||
|
||||
// Info contains information about the Volume as a whole as provided by
|
||||
// the CSI storage plugin.
|
||||
type Info = volume.Info
|
||||
|
||||
// CreateOptions VolumeConfig
|
||||
//
|
||||
// Volume configuration
|
||||
type CreateOptions = volume.CreateOptions
|
||||
|
||||
// ListResponse VolumeListResponse
|
||||
//
|
||||
// Volume list response
|
||||
type ListResponse = volume.ListResponse
|
||||
|
||||
// ListOptions holds parameters to list volumes.
|
||||
type ListOptions = client.VolumeListOptions
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/volumes/prune"
|
||||
type PruneReport = volume.PruneReport
|
||||
|
||||
// Volume volume
|
||||
type Volume = volume.Volume
|
||||
|
||||
// UsageData Usage details about the volume. This information is used by the
|
||||
// `GET /system/df` endpoint, and omitted in other endpoints.
|
||||
type UsageData = volume.UsageData
|
||||
|
||||
// UpdateOptions is configuration to update a Volume with.
|
||||
type UpdateOptions = volume.UpdateOptions
|
||||
|
|
@ -20,8 +20,19 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options netwo
|
|||
}
|
||||
|
||||
networkCreateRequest := network.CreateRequest{
|
||||
CreateOptions: options,
|
||||
Name: name,
|
||||
Name: name,
|
||||
Driver: options.Driver,
|
||||
Scope: options.Scope,
|
||||
EnableIPv4: options.EnableIPv4,
|
||||
EnableIPv6: options.EnableIPv6,
|
||||
IPAM: options.IPAM,
|
||||
Internal: options.Internal,
|
||||
Attachable: options.Attachable,
|
||||
Ingress: options.Ingress,
|
||||
ConfigOnly: options.ConfigOnly,
|
||||
ConfigFrom: options.ConfigFrom,
|
||||
Options: options.Options,
|
||||
Labels: options.Labels,
|
||||
}
|
||||
if versions.LessThan(cli.version, "1.44") {
|
||||
enabled := true
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
"github.com/moby/moby/api/types/jsonstream"
|
||||
"github.com/moby/term"
|
||||
"github.com/morikuni/aec"
|
||||
)
|
||||
|
|
@ -18,14 +19,7 @@ const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
|
|||
|
||||
// JSONError wraps a concrete Code and Message, Code is
|
||||
// an integer error code, Message is the error message.
|
||||
type JSONError struct {
|
||||
Code int `json:"code,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (e *JSONError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
type JSONError = jsonstream.Error
|
||||
|
||||
// JSONProgress describes a progress message in a JSON stream.
|
||||
type JSONProgress struct {
|
||||
|
|
@ -149,12 +143,12 @@ type JSONMessage struct {
|
|||
// ProgressMessage is a pre-formatted presentation of [Progress].
|
||||
//
|
||||
// Deprecated: this field is deprecated since docker v0.7.1 / API v1.8. Use the information in [Progress] instead. This field will be omitted in a future release.
|
||||
ProgressMessage string `json:"progress,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
From string `json:"from,omitempty"` // Deprecated: this field is no longer set in stream responses and should not be used.
|
||||
Time int64 `json:"time,omitempty"` // Deprecated: this field is no longer set in stream responses and should not be used.
|
||||
TimeNano int64 `json:"timeNano,omitempty"` // Deprecated: this field is no longer set in stream responses and should not be used.
|
||||
Error *JSONError `json:"errorDetail,omitempty"`
|
||||
ProgressMessage string `json:"progress,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
From string `json:"from,omitempty"` // Deprecated: this field is no longer set in stream responses and should not be used.
|
||||
Time int64 `json:"time,omitempty"` // Deprecated: this field is no longer set in stream responses and should not be used.
|
||||
TimeNano int64 `json:"timeNano,omitempty"` // Deprecated: this field is no longer set in stream responses and should not be used.
|
||||
Error *jsonstream.Error `json:"errorDetail,omitempty"`
|
||||
|
||||
// ErrorMessage contains errors encountered during the operation.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -2,92 +2,54 @@ package progress
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/moby/moby/api/pkg/progress"
|
||||
)
|
||||
|
||||
// Progress represents the progress of a transfer.
|
||||
type Progress struct {
|
||||
ID string
|
||||
|
||||
// Progress contains a Message or...
|
||||
Message string
|
||||
|
||||
// ...progress of an action
|
||||
Action string
|
||||
Current int64
|
||||
Total int64
|
||||
|
||||
// If true, don't show xB/yB
|
||||
HideCounts bool
|
||||
// If not empty, use units instead of bytes for counts
|
||||
Units string
|
||||
|
||||
// Aux contains extra information not presented to the user, such as
|
||||
// digests for push signing.
|
||||
Aux interface{}
|
||||
|
||||
LastUpdate bool
|
||||
}
|
||||
type Progress = progress.Progress
|
||||
|
||||
// Output is an interface for writing progress information. It's
|
||||
// like a writer for progress, but we don't call it Writer because
|
||||
// that would be confusing next to ProgressReader (also, because it
|
||||
// doesn't implement the io.Writer interface).
|
||||
type Output interface {
|
||||
WriteProgress(Progress) error
|
||||
}
|
||||
|
||||
type chanOutput chan<- Progress
|
||||
|
||||
func (out chanOutput) WriteProgress(p Progress) error {
|
||||
// FIXME: workaround for panic in #37735
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
out <- p
|
||||
return nil
|
||||
}
|
||||
type Output = progress.Output
|
||||
|
||||
// ChanOutput returns an Output that writes progress updates to the
|
||||
// supplied channel.
|
||||
func ChanOutput(progressChan chan<- Progress) Output {
|
||||
return chanOutput(progressChan)
|
||||
}
|
||||
|
||||
type discardOutput struct{}
|
||||
|
||||
func (discardOutput) WriteProgress(Progress) error {
|
||||
return nil
|
||||
func ChanOutput(progressChan chan<- progress.Progress) progress.Output {
|
||||
return progress.ChanOutput(progressChan)
|
||||
}
|
||||
|
||||
// DiscardOutput returns an Output that discards progress
|
||||
func DiscardOutput() Output {
|
||||
return discardOutput{}
|
||||
func DiscardOutput() progress.Output {
|
||||
return progress.DiscardOutput()
|
||||
}
|
||||
|
||||
// Update is a convenience function to write a progress update to the channel.
|
||||
func Update(out Output, id, action string) {
|
||||
out.WriteProgress(Progress{ID: id, Action: action})
|
||||
func Update(out progress.Output, id, action string) {
|
||||
out.WriteProgress(progress.Progress{ID: id, Action: action})
|
||||
}
|
||||
|
||||
// Updatef is a convenience function to write a printf-formatted progress update
|
||||
// to the channel.
|
||||
func Updatef(out Output, id, format string, a ...interface{}) {
|
||||
func Updatef(out progress.Output, id, format string, a ...interface{}) {
|
||||
Update(out, id, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// Message is a convenience function to write a progress message to the channel.
|
||||
func Message(out Output, id, message string) {
|
||||
out.WriteProgress(Progress{ID: id, Message: message})
|
||||
func Message(out progress.Output, id, message string) {
|
||||
out.WriteProgress(progress.Progress{ID: id, Message: message})
|
||||
}
|
||||
|
||||
// Messagef is a convenience function to write a printf-formatted progress
|
||||
// message to the channel.
|
||||
func Messagef(out Output, id, format string, a ...interface{}) {
|
||||
func Messagef(out progress.Output, id, format string, a ...interface{}) {
|
||||
Message(out, id, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// Aux sends auxiliary information over a progress interface, which will not be
|
||||
// formatted for the UI. This is used for things such as push signing.
|
||||
func Aux(out Output, a interface{}) {
|
||||
out.WriteProgress(Progress{Aux: a})
|
||||
func Aux(out progress.Output, a interface{}) {
|
||||
out.WriteProgress(progress.Progress{Aux: a})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,65 +2,14 @@ package progress
|
|||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
"github.com/moby/moby/api/pkg/progress"
|
||||
)
|
||||
|
||||
// Reader is a Reader with progress bar.
|
||||
type Reader struct {
|
||||
in io.ReadCloser // Stream to read from
|
||||
out Output // Where to send progress bar to
|
||||
size int64
|
||||
current int64
|
||||
lastUpdate int64
|
||||
id string
|
||||
action string
|
||||
rateLimiter *rate.Limiter
|
||||
}
|
||||
type Reader = progress.Reader
|
||||
|
||||
// NewProgressReader creates a new ProgressReader.
|
||||
func NewProgressReader(in io.ReadCloser, out Output, size int64, id, action string) *Reader {
|
||||
return &Reader{
|
||||
in: in,
|
||||
out: out,
|
||||
size: size,
|
||||
id: id,
|
||||
action: action,
|
||||
rateLimiter: rate.NewLimiter(rate.Every(100*time.Millisecond), 1),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Reader) Read(buf []byte) (int, error) {
|
||||
read, err := p.in.Read(buf)
|
||||
p.current += int64(read)
|
||||
updateEvery := int64(1024 * 512) // 512kB
|
||||
if p.size > 0 {
|
||||
// Update progress for every 1% read if 1% < 512kB
|
||||
if increment := int64(0.01 * float64(p.size)); increment < updateEvery {
|
||||
updateEvery = increment
|
||||
}
|
||||
}
|
||||
if p.current-p.lastUpdate > updateEvery || err != nil {
|
||||
p.updateProgress(err != nil && read == 0)
|
||||
p.lastUpdate = p.current
|
||||
}
|
||||
|
||||
return read, err
|
||||
}
|
||||
|
||||
// Close closes the progress reader and its underlying reader.
|
||||
func (p *Reader) Close() error {
|
||||
if p.current < p.size {
|
||||
// print a full progress bar when closing prematurely
|
||||
p.current = p.size
|
||||
p.updateProgress(false)
|
||||
}
|
||||
return p.in.Close()
|
||||
}
|
||||
|
||||
func (p *Reader) updateProgress(last bool) {
|
||||
if last || p.current == p.size || p.rateLimiter.Allow() {
|
||||
p.out.WriteProgress(Progress{ID: p.id, Action: p.action, Current: p.current, Total: p.size, LastUpdate: last})
|
||||
}
|
||||
func NewProgressReader(in io.ReadCloser, out progress.Output, size int64, id, action string) *progress.Reader {
|
||||
return progress.NewProgressReader(in, out, size, id, action)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package stdcopy
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/moby/moby/api/pkg/stdcopy"
|
||||
)
|
||||
|
||||
// StdType is the type of standard stream
|
||||
// a writer can multiplex to.
|
||||
//
|
||||
// Deprecated: use [stdcopy.StdType]. This alias will be removed in the next release.
|
||||
type StdType = stdcopy.StdType
|
||||
|
||||
const (
|
||||
Stdin = stdcopy.Stdin
|
||||
Stdout = stdcopy.Stdout
|
||||
Stderr = stdcopy.Stderr
|
||||
Systemerr = stdcopy.Systemerr
|
||||
)
|
||||
|
||||
// NewStdWriter instantiates a new Writer.
|
||||
func NewStdWriter(w io.Writer, t stdcopy.StdType) io.Writer {
|
||||
return stdcopy.NewStdWriter(w, t)
|
||||
}
|
||||
|
||||
// StdCopy is a modified version of io.Copy.
|
||||
func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {
|
||||
return stdcopy.StdCopy(dstout, dsterr, src)
|
||||
}
|
||||
|
|
@ -5,12 +5,34 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/docker/docker/pkg/progress"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/moby/moby/api/pkg/progress"
|
||||
"github.com/moby/moby/api/types/jsonstream"
|
||||
)
|
||||
|
||||
// jsonMessage defines a message struct. It describes
|
||||
// the created time, where it from, status, ID of the
|
||||
// message. It's used for docker events.
|
||||
//
|
||||
// It is a reduced set of [jsonmessage.JSONMessage].
|
||||
type jsonMessage struct {
|
||||
Stream string `json:"stream,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Progress *jsonstream.Progress `json:"progressDetail,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Error *jsonstream.Error `json:"errorDetail,omitempty"`
|
||||
Aux *json.RawMessage `json:"aux,omitempty"` // Aux contains out-of-band data, such as digests for push signing and image id after building.
|
||||
|
||||
// ErrorMessage contains errors encountered during the operation.
|
||||
//
|
||||
// Deprecated: this field is deprecated since docker v0.6.0 / API v1.4. Use [Error.Message] instead. This field will be omitted in a future release.
|
||||
ErrorMessage string `json:"error,omitempty"` // deprecated
|
||||
}
|
||||
|
||||
const streamNewline = "\r\n"
|
||||
|
||||
type jsonProgressFormatter struct{}
|
||||
|
|
@ -22,7 +44,7 @@ func appendNewline(source []byte) []byte {
|
|||
// FormatStatus formats the specified objects according to the specified format (and id).
|
||||
func FormatStatus(id, format string, a ...interface{}) []byte {
|
||||
str := fmt.Sprintf(format, a...)
|
||||
b, err := json.Marshal(&jsonmessage.JSONMessage{ID: id, Status: str})
|
||||
b, err := json.Marshal(&jsonMessage{ID: id, Status: str})
|
||||
if err != nil {
|
||||
return FormatError(err)
|
||||
}
|
||||
|
|
@ -31,11 +53,11 @@ func FormatStatus(id, format string, a ...interface{}) []byte {
|
|||
|
||||
// FormatError formats the error as a JSON object
|
||||
func FormatError(err error) []byte {
|
||||
jsonError, ok := err.(*jsonmessage.JSONError)
|
||||
jsonError, ok := err.(*jsonstream.Error)
|
||||
if !ok {
|
||||
jsonError = &jsonmessage.JSONError{Message: err.Error()}
|
||||
jsonError = &jsonstream.Error{Message: err.Error()}
|
||||
}
|
||||
if b, err := json.Marshal(&jsonmessage.JSONMessage{Error: jsonError, ErrorMessage: err.Error()}); err == nil {
|
||||
if b, err := json.Marshal(&jsonMessage{Error: jsonError, ErrorMessage: err.Error()}); err == nil {
|
||||
return appendNewline(b)
|
||||
}
|
||||
return []byte(`{"error":"format error"}` + streamNewline)
|
||||
|
|
@ -46,9 +68,9 @@ func (sf *jsonProgressFormatter) formatStatus(id, format string, a ...interface{
|
|||
}
|
||||
|
||||
// formatProgress formats the progress information for a specified action.
|
||||
func (sf *jsonProgressFormatter) formatProgress(id, action string, progress *jsonmessage.JSONProgress, aux interface{}) []byte {
|
||||
func (sf *jsonProgressFormatter) formatProgress(id, action string, progress *jsonstream.Progress, aux interface{}) []byte {
|
||||
if progress == nil {
|
||||
progress = &jsonmessage.JSONProgress{}
|
||||
progress = &jsonstream.Progress{}
|
||||
}
|
||||
var auxJSON *json.RawMessage
|
||||
if aux != nil {
|
||||
|
|
@ -59,12 +81,11 @@ func (sf *jsonProgressFormatter) formatProgress(id, action string, progress *jso
|
|||
auxJSON = new(json.RawMessage)
|
||||
*auxJSON = auxJSONBytes
|
||||
}
|
||||
b, err := json.Marshal(&jsonmessage.JSONMessage{
|
||||
Status: action,
|
||||
ProgressMessage: progress.String(),
|
||||
Progress: progress,
|
||||
ID: id,
|
||||
Aux: auxJSON,
|
||||
b, err := json.Marshal(&jsonMessage{
|
||||
Status: action,
|
||||
Progress: progress,
|
||||
ID: id,
|
||||
Aux: auxJSON,
|
||||
})
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
@ -78,15 +99,72 @@ func (sf *rawProgressFormatter) formatStatus(id, format string, a ...interface{}
|
|||
return []byte(fmt.Sprintf(format, a...) + streamNewline)
|
||||
}
|
||||
|
||||
func (sf *rawProgressFormatter) formatProgress(id, action string, progress *jsonmessage.JSONProgress, aux interface{}) []byte {
|
||||
func rawProgressString(p *jsonstream.Progress) string {
|
||||
if p == nil || (p.Current <= 0 && p.Total <= 0) {
|
||||
return ""
|
||||
}
|
||||
if p.Total <= 0 {
|
||||
switch p.Units {
|
||||
case "":
|
||||
return fmt.Sprintf("%8v", units.HumanSize(float64(p.Current)))
|
||||
default:
|
||||
return fmt.Sprintf("%d %s", p.Current, p.Units)
|
||||
}
|
||||
}
|
||||
|
||||
percentage := int(float64(p.Current)/float64(p.Total)*100) / 2
|
||||
if percentage > 50 {
|
||||
percentage = 50
|
||||
}
|
||||
|
||||
numSpaces := 0
|
||||
if 50-percentage > 0 {
|
||||
numSpaces = 50 - percentage
|
||||
}
|
||||
pbBox := fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", numSpaces))
|
||||
|
||||
var numbersBox string
|
||||
switch {
|
||||
case p.HideCounts:
|
||||
case p.Units == "": // no units, use bytes
|
||||
current := units.HumanSize(float64(p.Current))
|
||||
total := units.HumanSize(float64(p.Total))
|
||||
|
||||
numbersBox = fmt.Sprintf("%8v/%v", current, total)
|
||||
|
||||
if p.Current > p.Total {
|
||||
// remove total display if the reported current is wonky.
|
||||
numbersBox = fmt.Sprintf("%8v", current)
|
||||
}
|
||||
default:
|
||||
numbersBox = fmt.Sprintf("%d/%d %s", p.Current, p.Total, p.Units)
|
||||
|
||||
if p.Current > p.Total {
|
||||
// remove total display if the reported current is wonky.
|
||||
numbersBox = fmt.Sprintf("%d %s", p.Current, p.Units)
|
||||
}
|
||||
}
|
||||
|
||||
var timeLeftBox string
|
||||
if p.Current > 0 && p.Start > 0 && percentage < 50 {
|
||||
fromStart := time.Since(time.Unix(p.Start, 0))
|
||||
perEntry := fromStart / time.Duration(p.Current)
|
||||
left := time.Duration(p.Total-p.Current) * perEntry
|
||||
timeLeftBox = " " + left.Round(time.Second).String()
|
||||
}
|
||||
return pbBox + numbersBox + timeLeftBox
|
||||
}
|
||||
|
||||
func (sf *rawProgressFormatter) formatProgress(id, action string, progress *jsonstream.Progress, aux interface{}) []byte {
|
||||
if progress == nil {
|
||||
progress = &jsonmessage.JSONProgress{}
|
||||
progress = &jsonstream.Progress{}
|
||||
}
|
||||
endl := "\r"
|
||||
if progress.String() == "" {
|
||||
out := rawProgressString(progress)
|
||||
if out == "" {
|
||||
endl += "\n"
|
||||
}
|
||||
return []byte(action + " " + progress.String() + endl)
|
||||
return []byte(action + " " + out + endl)
|
||||
}
|
||||
|
||||
// NewProgressOutput returns a progress.Output object that can be passed to
|
||||
|
|
@ -103,7 +181,7 @@ func NewJSONProgressOutput(out io.Writer, newLines bool) progress.Output {
|
|||
|
||||
type formatProgress interface {
|
||||
formatStatus(id, format string, a ...interface{}) []byte
|
||||
formatProgress(id, action string, progress *jsonmessage.JSONProgress, aux interface{}) []byte
|
||||
formatProgress(id, action string, progress *jsonstream.Progress, aux interface{}) []byte
|
||||
}
|
||||
|
||||
type progressOutput struct {
|
||||
|
|
@ -119,7 +197,12 @@ func (out *progressOutput) WriteProgress(prog progress.Progress) error {
|
|||
if prog.Message != "" {
|
||||
formatted = out.sf.formatStatus(prog.ID, prog.Message)
|
||||
} else {
|
||||
jsonProgress := jsonmessage.JSONProgress{Current: prog.Current, Total: prog.Total, HideCounts: prog.HideCounts, Units: prog.Units}
|
||||
jsonProgress := jsonstream.Progress{
|
||||
Current: prog.Current,
|
||||
Total: prog.Total,
|
||||
HideCounts: prog.HideCounts,
|
||||
Units: prog.Units,
|
||||
}
|
||||
formatted = out.sf.formatProgress(prog.ID, prog.Action, &jsonProgress, prog.Aux)
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +234,7 @@ func (sf *AuxFormatter) Emit(id string, aux interface{}) error {
|
|||
}
|
||||
auxJSON := new(json.RawMessage)
|
||||
*auxJSON = auxJSONBytes
|
||||
msgJSON, err := json.Marshal(&jsonmessage.JSONMessage{ID: id, Aux: auxJSON})
|
||||
msgJSON, err := json.Marshal(&jsonMessage{ID: id, Aux: auxJSON})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package streamformatter
|
|||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
)
|
||||
|
||||
type streamWriter struct {
|
||||
|
|
@ -22,7 +20,7 @@ func (sw *streamWriter) Write(buf []byte) (int, error) {
|
|||
}
|
||||
|
||||
func (sw *streamWriter) format(buf []byte) []byte {
|
||||
msg := &jsonmessage.JSONMessage{Stream: sw.lineFormat(buf)}
|
||||
msg := &jsonMessage{Stream: sw.lineFormat(buf)}
|
||||
b, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
return FormatError(err)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,191 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
https://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2013-2018 Docker, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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.
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package authconfig
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
)
|
||||
|
||||
// Encode serializes the auth configuration as a base64url encoded
|
||||
// ([RFC4648, section 5]) JSON string for sending through the X-Registry-Auth header.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
func Encode(authConfig registry.AuthConfig) (string, error) {
|
||||
// Older daemons (or registries) may not handle an empty string,
|
||||
// which resulted in an "io.EOF" when unmarshaling or decoding.
|
||||
//
|
||||
// FIXME(thaJeztah): find exactly what code-paths are impacted by this.
|
||||
// if authConfig == (AuthConfig{}) { return "", nil }
|
||||
buf, err := json.Marshal(authConfig)
|
||||
if err != nil {
|
||||
return "", errInvalidParameter{err}
|
||||
}
|
||||
return base64.URLEncoding.EncodeToString(buf), nil
|
||||
}
|
||||
|
||||
// Decode decodes base64url encoded ([RFC4648, section 5]) JSON
|
||||
// authentication information as sent through the X-Registry-Auth header.
|
||||
//
|
||||
// This function always returns an [AuthConfig], even if an error occurs. It is up
|
||||
// to the caller to decide if authentication is required, and if the error can
|
||||
// be ignored.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
func Decode(authEncoded string) (*registry.AuthConfig, error) {
|
||||
if authEncoded == "" {
|
||||
return ®istry.AuthConfig{}, nil
|
||||
}
|
||||
|
||||
decoded, err := base64.URLEncoding.DecodeString(authEncoded)
|
||||
if err != nil {
|
||||
var e base64.CorruptInputError
|
||||
if errors.As(err, &e) {
|
||||
return ®istry.AuthConfig{}, invalid(errors.New("must be a valid base64url-encoded string"))
|
||||
}
|
||||
return ®istry.AuthConfig{}, invalid(err)
|
||||
}
|
||||
|
||||
if bytes.Equal(decoded, []byte("{}")) {
|
||||
return ®istry.AuthConfig{}, nil
|
||||
}
|
||||
|
||||
return decode(bytes.NewReader(decoded))
|
||||
}
|
||||
|
||||
// DecodeRequestBody decodes authentication information as sent as JSON in the
|
||||
// body of a request. This function is to provide backward compatibility with old
|
||||
// clients and API versions. Current clients and API versions expect authentication
|
||||
// to be provided through the X-Registry-Auth header.
|
||||
//
|
||||
// Like [Decode], this function always returns an [AuthConfig], even if an
|
||||
// error occurs. It is up to the caller to decide if authentication is required,
|
||||
// and if the error can be ignored.
|
||||
func DecodeRequestBody(r io.ReadCloser) (*registry.AuthConfig, error) {
|
||||
return decode(r)
|
||||
}
|
||||
|
||||
func decode(r io.Reader) (*registry.AuthConfig, error) {
|
||||
authConfig := ®istry.AuthConfig{}
|
||||
if err := json.NewDecoder(r).Decode(authConfig); err != nil {
|
||||
// always return an (empty) AuthConfig to increase compatibility with
|
||||
// the existing API.
|
||||
return ®istry.AuthConfig{}, invalid(fmt.Errorf("invalid JSON: %w", err))
|
||||
}
|
||||
return authConfig, nil
|
||||
}
|
||||
|
||||
func invalid(err error) error {
|
||||
return errInvalidParameter{fmt.Errorf("invalid X-Registry-Auth header: %w", err)}
|
||||
}
|
||||
|
||||
type errInvalidParameter struct{ error }
|
||||
|
||||
func (errInvalidParameter) InvalidParameter() {}
|
||||
|
||||
func (e errInvalidParameter) Cause() error { return e.error }
|
||||
|
||||
func (e errInvalidParameter) Unwrap() error { return e.error }
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package progress
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Progress represents the progress of a transfer.
|
||||
type Progress struct {
|
||||
ID string
|
||||
|
||||
// Progress contains a Message or...
|
||||
Message string
|
||||
|
||||
// ...progress of an action
|
||||
Action string
|
||||
Current int64
|
||||
Total int64
|
||||
|
||||
// If true, don't show xB/yB
|
||||
HideCounts bool
|
||||
// If not empty, use units instead of bytes for counts
|
||||
Units string
|
||||
|
||||
// Aux contains extra information not presented to the user, such as
|
||||
// digests for push signing.
|
||||
Aux any
|
||||
|
||||
LastUpdate bool
|
||||
}
|
||||
|
||||
// Output is an interface for writing progress information. It's
|
||||
// like a writer for progress, but we don't call it Writer because
|
||||
// that would be confusing next to ProgressReader (also, because it
|
||||
// doesn't implement the io.Writer interface).
|
||||
type Output interface {
|
||||
WriteProgress(Progress) error
|
||||
}
|
||||
|
||||
type chanOutput chan<- Progress
|
||||
|
||||
func (out chanOutput) WriteProgress(p Progress) error {
|
||||
// FIXME: workaround for panic in #37735
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
out <- p
|
||||
return nil
|
||||
}
|
||||
|
||||
// ChanOutput returns an Output that writes progress updates to the
|
||||
// supplied channel.
|
||||
func ChanOutput(progressChan chan<- Progress) Output {
|
||||
return chanOutput(progressChan)
|
||||
}
|
||||
|
||||
type discardOutput struct{}
|
||||
|
||||
func (discardOutput) WriteProgress(Progress) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DiscardOutput returns an Output that discards progress
|
||||
func DiscardOutput() Output {
|
||||
return discardOutput{}
|
||||
}
|
||||
|
||||
// Update is a convenience function to write a progress update to the channel.
|
||||
func Update(out Output, id, action string) {
|
||||
out.WriteProgress(Progress{ID: id, Action: action})
|
||||
}
|
||||
|
||||
// Updatef is a convenience function to write a printf-formatted progress update
|
||||
// to the channel.
|
||||
func Updatef(out Output, id, format string, a ...any) {
|
||||
Update(out, id, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// Message is a convenience function to write a progress message to the channel.
|
||||
func Message(out Output, id, message string) {
|
||||
out.WriteProgress(Progress{ID: id, Message: message})
|
||||
}
|
||||
|
||||
// Messagef is a convenience function to write a printf-formatted progress
|
||||
// message to the channel.
|
||||
func Messagef(out Output, id, format string, a ...any) {
|
||||
Message(out, id, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// Aux sends auxiliary information over a progress interface, which will not be
|
||||
// formatted for the UI. This is used for things such as push signing.
|
||||
func Aux(out Output, a any) {
|
||||
out.WriteProgress(Progress{Aux: a})
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package progress
|
||||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
// Reader is a Reader with progress bar.
|
||||
type Reader struct {
|
||||
in io.ReadCloser // Stream to read from
|
||||
out Output // Where to send progress bar to
|
||||
size int64
|
||||
current int64
|
||||
lastUpdate int64
|
||||
id string
|
||||
action string
|
||||
rateLimiter *rate.Limiter
|
||||
}
|
||||
|
||||
// NewProgressReader creates a new ProgressReader.
|
||||
func NewProgressReader(in io.ReadCloser, out Output, size int64, id, action string) *Reader {
|
||||
return &Reader{
|
||||
in: in,
|
||||
out: out,
|
||||
size: size,
|
||||
id: id,
|
||||
action: action,
|
||||
rateLimiter: rate.NewLimiter(rate.Every(100*time.Millisecond), 1),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Reader) Read(buf []byte) (int, error) {
|
||||
read, err := p.in.Read(buf)
|
||||
p.current += int64(read)
|
||||
updateEvery := int64(1024 * 512) // 512kB
|
||||
if p.size > 0 {
|
||||
// Update progress for every 1% read if 1% < 512kB
|
||||
if increment := int64(0.01 * float64(p.size)); increment < updateEvery {
|
||||
updateEvery = increment
|
||||
}
|
||||
}
|
||||
if p.current-p.lastUpdate > updateEvery || err != nil {
|
||||
p.updateProgress(err != nil && read == 0)
|
||||
p.lastUpdate = p.current
|
||||
}
|
||||
|
||||
return read, err
|
||||
}
|
||||
|
||||
// Close closes the progress reader and its underlying reader.
|
||||
func (p *Reader) Close() error {
|
||||
if p.current < p.size {
|
||||
// print a full progress bar when closing prematurely
|
||||
p.current = p.size
|
||||
p.updateProgress(false)
|
||||
}
|
||||
return p.in.Close()
|
||||
}
|
||||
|
||||
func (p *Reader) updateProgress(last bool) {
|
||||
if last || p.current == p.size || p.rateLimiter.Allow() {
|
||||
p.out.WriteProgress(Progress{ID: p.id, Action: p.action, Current: p.current, Total: p.size, LastUpdate: last})
|
||||
}
|
||||
}
|
||||
|
|
@ -14,16 +14,13 @@ import (
|
|||
type StdType byte
|
||||
|
||||
const (
|
||||
// Stdin represents standard input stream type.
|
||||
Stdin StdType = iota
|
||||
// Stdout represents standard output stream type.
|
||||
Stdout
|
||||
// Stderr represents standard error steam type.
|
||||
Stderr
|
||||
// Systemerr represents errors originating from the system that make it
|
||||
// into the multiplexed stream.
|
||||
Systemerr
|
||||
Stdin StdType = 0 // Stdin represents standard input stream. It is present for completeness and should NOT be used. When reading the stream with [StdCopy] it is output on [Stdout].
|
||||
Stdout StdType = 1 // Stdout represents standard output stream.
|
||||
Stderr StdType = 2 // Stderr represents standard error steam.
|
||||
Systemerr StdType = 3 // Systemerr represents errors originating from the system. When reading the stream with [StdCopy] it is returned as an error.
|
||||
)
|
||||
|
||||
const (
|
||||
stdWriterPrefixLen = 8
|
||||
stdWriterFdIndex = 0
|
||||
stdWriterSizeIndex = 4
|
||||
|
|
@ -31,7 +28,7 @@ const (
|
|||
startingBufLen = 32*1024 + stdWriterPrefixLen + 1
|
||||
)
|
||||
|
||||
var bufPool = &sync.Pool{New: func() interface{} { return bytes.NewBuffer(nil) }}
|
||||
var bufPool = &sync.Pool{New: func() any { return bytes.NewBuffer(nil) }}
|
||||
|
||||
// stdWriter is wrapper of io.Writer with extra customized info.
|
||||
type stdWriter struct {
|
||||
|
|
@ -39,10 +36,11 @@ type stdWriter struct {
|
|||
prefix byte
|
||||
}
|
||||
|
||||
// Write sends the buffer to the underneath writer.
|
||||
// Write sends the buffer to the underlying writer.
|
||||
// It inserts the prefix header before the buffer,
|
||||
// so stdcopy.StdCopy knows where to multiplex the output.
|
||||
// It makes stdWriter to implement io.Writer.
|
||||
// so [StdCopy] knows where to multiplex the output.
|
||||
//
|
||||
// It implements [io.Writer].
|
||||
func (w *stdWriter) Write(p []byte) (int, error) {
|
||||
if w == nil || w.Writer == nil {
|
||||
return 0, errors.New("writer not instantiated")
|
||||
|
|
@ -68,30 +66,55 @@ func (w *stdWriter) Write(p []byte) (int, error) {
|
|||
return n, err
|
||||
}
|
||||
|
||||
// NewStdWriter instantiates a new Writer.
|
||||
// Everything written to it will be encapsulated using a custom format,
|
||||
// and written to the underlying `w` stream.
|
||||
// This allows multiple write streams (e.g. stdout and stderr) to be muxed into a single connection.
|
||||
// `t` indicates the id of the stream to encapsulate.
|
||||
// It can be stdcopy.Stdin, stdcopy.Stdout, stdcopy.Stderr.
|
||||
func NewStdWriter(w io.Writer, t StdType) io.Writer {
|
||||
// NewStdWriter instantiates a new writer using a custom format to multiplex
|
||||
// multiple streams to a single writer. All messages written using this writer
|
||||
// are encapsulated using a custom format, and written to the underlying
|
||||
// stream "w".
|
||||
//
|
||||
// Writers created through NewStdWriter allow for multiple write streams
|
||||
// (e.g., stdout ([Stdout]) and stderr ([Stderr]) to be multiplexed into a
|
||||
// single connection. "streamType" indicates the type of stream to encapsulate,
|
||||
// commonly, [Stdout] or [Stderr]. The [Systemerr] stream can be used to
|
||||
// include server-side errors in the stream. Information on this stream
|
||||
// is returned as an error by [StdCopy] and terminates processing the
|
||||
// stream.
|
||||
//
|
||||
// The [Stdin] stream is present for completeness and should generally
|
||||
// NOT be used. It is output on [Stdout] when reading the stream with
|
||||
// [StdCopy].
|
||||
//
|
||||
// All streams must share the same underlying [io.Writer] to ensure proper
|
||||
// multiplexing. Each call to NewStdWriter wraps that shared writer with
|
||||
// a header indicating the target stream.
|
||||
func NewStdWriter(w io.Writer, streamType StdType) io.Writer {
|
||||
return &stdWriter{
|
||||
Writer: w,
|
||||
prefix: byte(t),
|
||||
prefix: byte(streamType),
|
||||
}
|
||||
}
|
||||
|
||||
// StdCopy is a modified version of io.Copy.
|
||||
// StdCopy is a modified version of [io.Copy] to de-multiplex messages
|
||||
// from "multiplexedSource" and copy them to destination streams
|
||||
// "destOut" and "destErr".
|
||||
//
|
||||
// StdCopy will demultiplex `src`, assuming that it contains two streams,
|
||||
// previously multiplexed together using a StdWriter instance.
|
||||
// As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.
|
||||
// StdCopy demultiplexes "multiplexedSource", assuming that it contains
|
||||
// two streams, previously multiplexed using a writer created with
|
||||
// [NewStdWriter].
|
||||
//
|
||||
// StdCopy will read until it hits EOF on `src`. It will then return a nil error.
|
||||
// In other words: if `err` is non nil, it indicates a real underlying error.
|
||||
// As it reads from "multiplexedSource", StdCopy writes [Stdout] messages
|
||||
// to "destOut", and [Stderr] message to "destErr]. For backward-compatibility,
|
||||
// [Stdin] messages are output to "destOut". The [Systemerr] stream provides
|
||||
// errors produced by the daemon. It is returned as an error, and terminates
|
||||
// processing the stream.
|
||||
//
|
||||
// `written` will hold the total number of bytes written to `dstout` and `dsterr`.
|
||||
func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {
|
||||
// StdCopy it reads until it hits [io.EOF] on "multiplexedSource", after
|
||||
// which it returns a nil error. In other words: any error returned indicates
|
||||
// a real underlying error, which may be when an unknown [StdType] stream
|
||||
// is received.
|
||||
//
|
||||
// The "written" return holds the total number of bytes written to "destOut"
|
||||
// and "destErr" combined.
|
||||
func StdCopy(destOut, destErr io.Writer, multiplexedSource io.Reader) (written int64, _ error) {
|
||||
var (
|
||||
buf = make([]byte, startingBufLen)
|
||||
bufLen = len(buf)
|
||||
|
|
@ -105,7 +128,7 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {
|
|||
// Make sure we have at least a full header
|
||||
for nr < stdWriterPrefixLen {
|
||||
var nr2 int
|
||||
nr2, err = src.Read(buf[nr:])
|
||||
nr2, err = multiplexedSource.Read(buf[nr:])
|
||||
nr += nr2
|
||||
if errors.Is(err, io.EOF) {
|
||||
if nr < stdWriterPrefixLen {
|
||||
|
|
@ -118,24 +141,24 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {
|
|||
}
|
||||
}
|
||||
|
||||
stream := StdType(buf[stdWriterFdIndex])
|
||||
// Check the first byte to know where to write
|
||||
stream := StdType(buf[stdWriterFdIndex])
|
||||
switch stream {
|
||||
case Stdin:
|
||||
fallthrough
|
||||
case Stdout:
|
||||
// Write on stdout
|
||||
out = dstout
|
||||
out = destOut
|
||||
case Stderr:
|
||||
// Write on stderr
|
||||
out = dsterr
|
||||
out = destErr
|
||||
case Systemerr:
|
||||
// If we're on Systemerr, we won't write anywhere.
|
||||
// NB: if this code changes later, make sure you don't try to write
|
||||
// to outstream if Systemerr is the stream
|
||||
out = nil
|
||||
default:
|
||||
return 0, fmt.Errorf("Unrecognized input header: %d", buf[stdWriterFdIndex])
|
||||
return 0, fmt.Errorf("unrecognized stream: %d", stream)
|
||||
}
|
||||
|
||||
// Retrieve the size of the frame
|
||||
|
|
@ -151,7 +174,7 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {
|
|||
// While the amount of bytes read is less than the size of the frame + header, we keep reading
|
||||
for nr < frameSize+stdWriterPrefixLen {
|
||||
var nr2 int
|
||||
nr2, err = src.Read(buf[nr:])
|
||||
nr2, err = multiplexedSource.Read(buf[nr:])
|
||||
nr += nr2
|
||||
if errors.Is(err, io.EOF) {
|
||||
if nr < frameSize+stdWriterPrefixLen {
|
||||
|
|
@ -3,8 +3,8 @@ package build
|
|||
import (
|
||||
"io"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/registry"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
)
|
||||
|
||||
// BuilderVersion sets the version of underlying builder to use
|
||||
|
|
@ -3,7 +3,7 @@ package build
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
)
|
||||
|
||||
// CacheRecord contains information about a build cache record.
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
package types
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package common
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// ErrorResponse Represents an error.
|
||||
// Example: {"message":"Something went wrong."}
|
||||
//
|
||||
// swagger:model ErrorResponse
|
||||
type ErrorResponse struct {
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package types
|
||||
package common
|
||||
|
||||
// Error returns the error message
|
||||
func (e ErrorResponse) Error() string {
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package common
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// IDResponse Response to an API call that returns just an Id
|
||||
//
|
||||
// swagger:model IDResponse
|
||||
type IDResponse struct {
|
||||
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package container
|
||||
|
||||
import "github.com/docker/docker/api/types/common"
|
||||
import "github.com/moby/moby/api/types/common"
|
||||
|
||||
// CommitResponse response for the commit API call, containing the ID of the
|
||||
// image that was produced.
|
||||
|
|
@ -3,8 +3,6 @@ package container
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/strslice"
|
||||
"github.com/docker/go-connections/nat"
|
||||
dockerspec "github.com/moby/docker-image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
|
|
@ -48,18 +46,18 @@ type Config struct {
|
|||
AttachStdin bool // Attach the standard input, makes possible user interaction
|
||||
AttachStdout bool // Attach the standard output
|
||||
AttachStderr bool // Attach the standard error
|
||||
ExposedPorts nat.PortSet `json:",omitempty"` // List of exposed ports
|
||||
ExposedPorts PortSet `json:",omitempty"` // List of exposed ports
|
||||
Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
|
||||
OpenStdin bool // Open stdin
|
||||
StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
|
||||
Env []string // List of environment variable to set in the container
|
||||
Cmd strslice.StrSlice // Command to run when starting the container
|
||||
Cmd []string // Command to run when starting the container
|
||||
Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
|
||||
ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (meaning treat as a command line) (Windows specific).
|
||||
Image string // Name of the image as it was passed by the operator (e.g. could be symbolic)
|
||||
Volumes map[string]struct{} // List of volumes (mounts) used for the container
|
||||
WorkingDir string // Current directory (PWD) in the command will be launched
|
||||
Entrypoint strslice.StrSlice // Entrypoint to run when starting the container
|
||||
Entrypoint []string // Entrypoint to run when starting the container
|
||||
NetworkDisabled bool `json:",omitempty"` // Is network disabled
|
||||
// Mac Address of the container.
|
||||
//
|
||||
|
|
@ -69,5 +67,5 @@ type Config struct {
|
|||
Labels map[string]string // List of labels set to this container
|
||||
StopSignal string `json:",omitempty"` // Signal to stop a container
|
||||
StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
|
||||
Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
|
||||
Shell []string `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
|
||||
}
|
||||
|
|
@ -1,25 +1,14 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/storage"
|
||||
"github.com/moby/moby/api/types/mount"
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ContainerUpdateOKBody OK response to ContainerUpdate operation
|
||||
//
|
||||
// Deprecated: use [UpdateResponse]. This alias will be removed in the next release.
|
||||
type ContainerUpdateOKBody = UpdateResponse
|
||||
|
||||
// ContainerTopOKBody OK response to ContainerTop operation
|
||||
//
|
||||
// Deprecated: use [TopResponse]. This alias will be removed in the next release.
|
||||
type ContainerTopOKBody = TopResponse
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/containers/prune"
|
||||
type PruneReport struct {
|
||||
|
|
@ -45,23 +34,10 @@ type CopyToContainerOptions struct {
|
|||
CopyUIDGID bool
|
||||
}
|
||||
|
||||
// StatsResponseReader wraps an io.ReadCloser to read (a stream of) stats
|
||||
// for a container, as produced by the GET "/stats" endpoint.
|
||||
//
|
||||
// The OSType field is set to the server's platform to allow
|
||||
// platform-specific handling of the response.
|
||||
//
|
||||
// TODO(thaJeztah): remove this wrapper, and make OSType part of [StatsResponse].
|
||||
type StatsResponseReader struct {
|
||||
Body io.ReadCloser `json:"body"`
|
||||
OSType string `json:"ostype"`
|
||||
}
|
||||
|
||||
// MountPoint represents a mount point configuration inside the container.
|
||||
// This is used for reporting the mountpoints in use by a container.
|
||||
type MountPoint struct {
|
||||
// Type is the type of mount, see `Type<foo>` definitions in
|
||||
// github.com/docker/docker/api/types/mount.Type
|
||||
// Type is the type of mount, see [mount.Type] definitions for details.
|
||||
Type mount.Type `json:",omitempty"`
|
||||
|
||||
// Name is the name reference to the underlying data defined by `Source`
|
||||
|
|
@ -128,7 +104,7 @@ type Summary struct {
|
|||
ImageManifestDescriptor *ocispec.Descriptor `json:"ImageManifestDescriptor,omitempty"`
|
||||
Command string
|
||||
Created int64
|
||||
Ports []Port
|
||||
Ports []PortSummary
|
||||
SizeRw int64 `json:",omitempty"`
|
||||
SizeRootFs int64 `json:",omitempty"`
|
||||
Labels map[string]string
|
||||
|
|
@ -138,20 +114,14 @@ type Summary struct {
|
|||
NetworkMode string `json:",omitempty"`
|
||||
Annotations map[string]string `json:",omitempty"`
|
||||
}
|
||||
Health *HealthSummary `json:",omitempty"`
|
||||
NetworkSettings *NetworkSettingsSummary
|
||||
Mounts []MountPoint
|
||||
}
|
||||
|
||||
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
|
||||
// for API version 1.18 and older.
|
||||
//
|
||||
// TODO(thaJeztah): combine ContainerJSONBase and InspectResponse into a single struct.
|
||||
// The split between ContainerJSONBase (ContainerJSONBase) and InspectResponse (InspectResponse)
|
||||
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
|
||||
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
|
||||
// held fields that were added in API 1.19 and up. Given that the minimum
|
||||
// supported API version is now 1.24, we no longer use the separate type.
|
||||
type ContainerJSONBase struct {
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
ID string `json:"Id"`
|
||||
Created string
|
||||
Path string
|
||||
|
|
@ -174,12 +144,6 @@ type ContainerJSONBase struct {
|
|||
GraphDriver storage.DriverData
|
||||
SizeRw *int64 `json:",omitempty"`
|
||||
SizeRootFs *int64 `json:",omitempty"`
|
||||
}
|
||||
|
||||
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
|
||||
// endpoint.
|
||||
type InspectResponse struct {
|
||||
*ContainerJSONBase
|
||||
Mounts []MountPoint
|
||||
Config *Config
|
||||
NetworkSettings *NetworkSettings
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package container
|
||||
|
||||
import "github.com/docker/docker/api/types/network"
|
||||
import "github.com/moby/moby/api/types/network"
|
||||
|
||||
// CreateRequest is the request message sent to the server for container
|
||||
// create calls. It is a config wrapper that holds the container [Config]
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -5,15 +7,18 @@ package container
|
|||
|
||||
// CreateResponse ContainerCreateResponse
|
||||
//
|
||||
// OK response to ContainerCreate operation
|
||||
// # OK response to ContainerCreate operation
|
||||
//
|
||||
// swagger:model CreateResponse
|
||||
type CreateResponse struct {
|
||||
|
||||
// The ID of the created container
|
||||
// Example: ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743
|
||||
// Required: true
|
||||
ID string `json:"Id"`
|
||||
|
||||
// Warnings encountered when creating the container
|
||||
// Example: []
|
||||
// Required: true
|
||||
Warnings []string `json:"Warnings"`
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package container
|
||||
|
||||
import "github.com/docker/docker/api/types/common"
|
||||
import "github.com/moby/moby/api/types/common"
|
||||
|
||||
// ExecCreateResponse is the response for a successful exec-create request.
|
||||
// It holds the ID of the exec that was created.
|
||||
|
|
@ -44,10 +44,42 @@ type ExecStartOptions struct {
|
|||
type ExecAttachOptions = ExecStartOptions
|
||||
|
||||
// ExecInspect holds information returned by exec inspect.
|
||||
//
|
||||
// It is used by the client to unmarshal a [ExecInspectResponse],
|
||||
// but currently only provides a subset of the information included
|
||||
// in that type.
|
||||
//
|
||||
// TODO(thaJeztah): merge [ExecInspect] and [ExecInspectResponse],
|
||||
type ExecInspect struct {
|
||||
ExecID string `json:"ID"`
|
||||
ContainerID string
|
||||
Running bool
|
||||
ExitCode int
|
||||
Pid int
|
||||
ContainerID string `json:"ContainerID"`
|
||||
Running bool `json:"Running"`
|
||||
ExitCode int `json:"ExitCode"`
|
||||
Pid int `json:"Pid"`
|
||||
}
|
||||
|
||||
// ExecInspectResponse is the API response for the "GET /exec/{id}/json"
|
||||
// endpoint and holds information about and exec.
|
||||
type ExecInspectResponse struct {
|
||||
ID string `json:"ID"`
|
||||
Running bool `json:"Running"`
|
||||
ExitCode *int `json:"ExitCode"`
|
||||
ProcessConfig *ExecProcessConfig
|
||||
OpenStdin bool `json:"OpenStdin"`
|
||||
OpenStderr bool `json:"OpenStderr"`
|
||||
OpenStdout bool `json:"OpenStdout"`
|
||||
CanRemove bool `json:"CanRemove"`
|
||||
ContainerID string `json:"ContainerID"`
|
||||
DetachKeys []byte `json:"DetachKeys"`
|
||||
Pid int `json:"Pid"`
|
||||
}
|
||||
|
||||
// ExecProcessConfig holds information about the exec process
|
||||
// running on the host.
|
||||
type ExecProcessConfig struct {
|
||||
Tty bool `json:"tty"`
|
||||
Entrypoint string `json:"entrypoint"`
|
||||
Arguments []string `json:"arguments"`
|
||||
Privileged *bool `json:"privileged,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -26,6 +26,12 @@ type Health struct {
|
|||
Log []*HealthcheckResult // Log contains the last few results (oldest first)
|
||||
}
|
||||
|
||||
// HealthSummary stores a summary of the container's healthcheck results.
|
||||
type HealthSummary struct {
|
||||
Status HealthStatus // Status is one of [NoHealthcheck], [Starting], [Healthy] or [Unhealthy].
|
||||
FailingStreak int // FailingStreak is the number of consecutive failures
|
||||
}
|
||||
|
||||
// HealthcheckResult stores information about a single run of a healthcheck probe
|
||||
type HealthcheckResult struct {
|
||||
Start time.Time // Start is the time this check started
|
||||
|
|
@ -5,12 +5,10 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types/blkiodev"
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/strslice"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/moby/moby/api/types/blkiodev"
|
||||
"github.com/moby/moby/api/types/mount"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
)
|
||||
|
||||
// CgroupnsMode represents the cgroup namespace mode of the container
|
||||
|
|
@ -427,7 +425,7 @@ type HostConfig struct {
|
|||
ContainerIDFile string // File (path) where the containerId is written
|
||||
LogConfig LogConfig // Configuration of the logs for this container
|
||||
NetworkMode NetworkMode // Network mode to use for the container
|
||||
PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
|
||||
PortBindings PortMap // Port mapping between the exposed port (container) and the host
|
||||
RestartPolicy RestartPolicy // Restart policy to be used for the container
|
||||
AutoRemove bool // Automatically remove container when it exits
|
||||
VolumeDriver string // Name of the volume driver used to mount volumes
|
||||
|
|
@ -436,8 +434,8 @@ type HostConfig struct {
|
|||
Annotations map[string]string `json:",omitempty"` // Arbitrary non-identifying metadata attached to container and provided to the runtime
|
||||
|
||||
// Applicable to UNIX platforms
|
||||
CapAdd strslice.StrSlice // List of kernel capabilities to add to the container
|
||||
CapDrop strslice.StrSlice // List of kernel capabilities to remove from the container
|
||||
CapAdd []string // List of kernel capabilities to add to the container
|
||||
CapDrop []string // List of kernel capabilities to remove from the container
|
||||
CgroupnsMode CgroupnsMode // Cgroup namespace mode to use for the container
|
||||
DNS []string `json:"Dns"` // List of DNS server to lookup
|
||||
DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
package container
|
||||
|
||||
import "github.com/docker/docker/api/types/network"
|
||||
import "github.com/moby/moby/api/types/network"
|
||||
|
||||
// IsValid indicates if an isolation technology is valid
|
||||
func (i Isolation) IsValid() bool {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package container
|
||||
|
||||
import "github.com/docker/docker/api/types/network"
|
||||
import "github.com/moby/moby/api/types/network"
|
||||
|
||||
// IsValid indicates if an isolation technology is valid
|
||||
func (i Isolation) IsValid() bool {
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package container
|
||||
|
||||
import "github.com/docker/go-connections/nat"
|
||||
|
||||
// PortRangeProto is a string containing port number and protocol in the format "80/tcp",
|
||||
// or a port range and protocol in the format "80-83/tcp".
|
||||
//
|
||||
// It is currently an alias for [nat.Port] but may become a concrete type in a future release.
|
||||
type PortRangeProto = nat.Port
|
||||
|
||||
// PortSet is a collection of structs indexed by [HostPort].
|
||||
//
|
||||
// It is currently an alias for [nat.PortSet] but may become a concrete type in a future release.
|
||||
type PortSet = nat.PortSet
|
||||
|
||||
// PortBinding represents a binding between a Host IP address and a [HostPort].
|
||||
//
|
||||
// It is currently an alias for [nat.PortBinding] but may become a concrete type in a future release.
|
||||
type PortBinding = nat.PortBinding
|
||||
|
||||
// PortMap is a collection of [PortBinding] indexed by [HostPort].
|
||||
//
|
||||
// It is currently an alias for [nat.PortMap] but may become a concrete type in a future release.
|
||||
type PortMap = nat.PortMap
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
)
|
||||
|
||||
// NetworkSettings exposes the network settings in the api
|
||||
|
|
@ -14,10 +13,10 @@ type NetworkSettings struct {
|
|||
|
||||
// NetworkSettingsBase holds networking state for a container when inspecting it.
|
||||
type NetworkSettingsBase struct {
|
||||
Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag.
|
||||
SandboxID string // SandboxID uniquely represents a container's network stack
|
||||
SandboxKey string // SandboxKey identifies the sandbox
|
||||
Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port
|
||||
Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag.
|
||||
SandboxID string // SandboxID uniquely represents a container's network stack
|
||||
SandboxKey string // SandboxKey identifies the sandbox
|
||||
Ports PortMap // Ports is a collection of PortBinding indexed by Port
|
||||
|
||||
// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
|
||||
//
|
||||
|
|
@ -1,14 +1,6 @@
|
|||
package container
|
||||
|
||||
import "github.com/docker/docker/api/types/filters"
|
||||
|
||||
// ResizeOptions holds parameters to resize a TTY.
|
||||
// It can be used to resize container TTYs and
|
||||
// exec process TTYs too.
|
||||
type ResizeOptions struct {
|
||||
Height uint
|
||||
Width uint
|
||||
}
|
||||
import "github.com/moby/moby/api/types/filters"
|
||||
|
||||
// AttachOptions holds parameters to attach to a container.
|
||||
type AttachOptions struct {
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// Port An open port on a container
|
||||
// swagger:model Port
|
||||
type Port struct {
|
||||
// PortSummary Describes a port-mapping between the container and the host.
|
||||
//
|
||||
// Example: {"PrivatePort":8080,"PublicPort":80,"Type":"tcp"}
|
||||
//
|
||||
// swagger:model PortSummary
|
||||
type PortSummary struct {
|
||||
|
||||
// Host IP address that the container's port is mapped to
|
||||
IP string `json:"IP,omitempty"`
|
||||
|
|
@ -19,5 +24,6 @@ type Port struct {
|
|||
|
||||
// type
|
||||
// Required: true
|
||||
// Enum: ["tcp","udp","sctp"]
|
||||
Type string `json:"Type"`
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
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, ", "))}
|
||||
}
|
||||
}
|
||||
|
|
@ -147,11 +147,6 @@ type PidsStats struct {
|
|||
Limit uint64 `json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
// Stats is Ultimate struct aggregating all types of stats of one container
|
||||
//
|
||||
// Deprecated: use [StatsResponse] instead. This type will be removed in the next release.
|
||||
type Stats = StatsResponse
|
||||
|
||||
// StatsResponse aggregates all types of stats of one container.
|
||||
type StatsResponse struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -6,13 +8,16 @@ package container
|
|||
// TopResponse ContainerTopResponse
|
||||
//
|
||||
// Container "top" response.
|
||||
//
|
||||
// swagger:model TopResponse
|
||||
type TopResponse struct {
|
||||
|
||||
// Each process running in the container, where each process
|
||||
// is an array of values corresponding to the titles.
|
||||
// Example: {"Processes":[["root","13642","882","0","17:03","pts/0","00:00:00","/bin/bash"],["root","13735","13642","0","17:06","pts/0","00:00:00","sleep 10"]]}
|
||||
Processes [][]string `json:"Processes"`
|
||||
|
||||
// The ps column titles
|
||||
// Example: {"Titles":["UID","PID","PPID","C","STIME","TTY","TIME","CMD"]}
|
||||
Titles []string `json:"Titles"`
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -6,9 +8,11 @@ package container
|
|||
// UpdateResponse ContainerUpdateResponse
|
||||
//
|
||||
// Response for a successful container-update.
|
||||
//
|
||||
// swagger:model UpdateResponse
|
||||
type UpdateResponse struct {
|
||||
|
||||
// Warnings encountered when updating the container.
|
||||
// Example: ["Published ports are discarded when using host network mode"]
|
||||
Warnings []string `json:"Warnings"`
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// WaitExitError container waiting error, if any
|
||||
//
|
||||
// swagger:model WaitExitError
|
||||
type WaitExitError struct {
|
||||
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package container
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -5,7 +7,8 @@ package container
|
|||
|
||||
// WaitResponse ContainerWaitResponse
|
||||
//
|
||||
// OK response to ContainerWait operation
|
||||
// # OK response to ContainerWait operation
|
||||
//
|
||||
// swagger:model WaitResponse
|
||||
type WaitResponse struct {
|
||||
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package events
|
||||
|
||||
import "github.com/docker/docker/api/types/filters"
|
||||
|
||||
// Type is used for event-types.
|
||||
type Type string
|
||||
|
||||
|
|
@ -130,10 +128,3 @@ type Message struct {
|
|||
Time int64 `json:"time,omitempty"`
|
||||
TimeNano int64 `json:"timeNano,omitempty"`
|
||||
}
|
||||
|
||||
// ListOptions holds parameters to filter events with.
|
||||
type ListOptions struct {
|
||||
Since string
|
||||
Until string
|
||||
Filters filters.Args
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package image
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// DeleteResponse delete response
|
||||
//
|
||||
// swagger:model DeleteResponse
|
||||
type DeleteResponse struct {
|
||||
|
||||
|
|
@ -7,6 +7,7 @@ package image
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
// HistoryResponseItem individual image layer information in response to ImageHistory operation
|
||||
//
|
||||
// swagger:model HistoryResponseItem
|
||||
type HistoryResponseItem struct {
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package image
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/storage"
|
||||
dockerspec "github.com/moby/docker-image-spec/specs-go/v1"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package jsonstream
|
||||
|
||||
// Error wraps a concrete Code and Message, Code is
|
||||
// an integer error code, Message is the error message.
|
||||
type Error struct {
|
||||
Code int `json:"code,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (e *Error) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package jsonstream
|
||||
|
||||
// Progress describes a progress message in a JSON stream.
|
||||
type Progress struct {
|
||||
Current int64 `json:"current,omitempty"` // Current is the current status and value of the progress made towards Total.
|
||||
Total int64 `json:"total,omitempty"` // Total is the end value describing when we made 100% progress for an operation.
|
||||
Start int64 `json:"start,omitempty"` // Start is the initial value for the operation.
|
||||
HideCounts bool `json:"hidecounts,omitempty"` // HideCounts. if true, hides the progress count indicator (xB/yB).
|
||||
Units string `json:"units,omitempty"` // Units is the unit to print for progress. It defaults to "bytes" if empty.
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
|
|
@ -5,11 +7,13 @@ package network
|
|||
|
||||
// CreateResponse NetworkCreateResponse
|
||||
//
|
||||
// OK response to NetworkCreate operation
|
||||
// # OK response to NetworkCreate operation
|
||||
//
|
||||
// swagger:model CreateResponse
|
||||
type CreateResponse struct {
|
||||
|
||||
// The ID of the created network.
|
||||
// Example: b5c4fc71e8022147cd25de22b22173de4e3b170134117172eb595cb91b4e7e5d
|
||||
// Required: true
|
||||
ID string `json:"Id"`
|
||||
|
||||
|
|
@ -3,7 +3,9 @@ package network
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// EndpointSettings stores the network endpoint details
|
||||
|
|
@ -39,25 +41,16 @@ type EndpointSettings struct {
|
|||
|
||||
// Copy makes a deep copy of `EndpointSettings`
|
||||
func (es *EndpointSettings) Copy() *EndpointSettings {
|
||||
if es == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
epCopy := *es
|
||||
if es.IPAMConfig != nil {
|
||||
epCopy.IPAMConfig = es.IPAMConfig.Copy()
|
||||
}
|
||||
|
||||
if es.Links != nil {
|
||||
links := make([]string, 0, len(es.Links))
|
||||
epCopy.Links = append(links, es.Links...)
|
||||
}
|
||||
|
||||
if es.Aliases != nil {
|
||||
aliases := make([]string, 0, len(es.Aliases))
|
||||
epCopy.Aliases = append(aliases, es.Aliases...)
|
||||
}
|
||||
|
||||
if len(es.DNSNames) > 0 {
|
||||
epCopy.DNSNames = make([]string, len(es.DNSNames))
|
||||
copy(epCopy.DNSNames, es.DNSNames)
|
||||
}
|
||||
epCopy.IPAMConfig = es.IPAMConfig.Copy()
|
||||
epCopy.Links = slices.Clone(es.Links)
|
||||
epCopy.Aliases = slices.Clone(es.Aliases)
|
||||
epCopy.DNSNames = slices.Clone(es.DNSNames)
|
||||
epCopy.DriverOpts = maps.Clone(es.DriverOpts)
|
||||
|
||||
return &epCopy
|
||||
}
|
||||
|
|
@ -71,9 +64,11 @@ type EndpointIPAMConfig struct {
|
|||
|
||||
// Copy makes a copy of the endpoint ipam config
|
||||
func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig {
|
||||
if cfg == nil {
|
||||
return nil
|
||||
}
|
||||
cfgCopy := *cfg
|
||||
cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs))
|
||||
cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...)
|
||||
cfgCopy.LinkLocalIPs = slices.Clone(cfg.LinkLocalIPs)
|
||||
return &cfgCopy
|
||||
}
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package network
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -21,16 +21,7 @@ const (
|
|||
|
||||
// CreateRequest is the request message sent to the server for network create call.
|
||||
type CreateRequest struct {
|
||||
CreateOptions
|
||||
Name string // Name is the requested name of the network.
|
||||
|
||||
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
|
||||
// package to older daemons.
|
||||
CheckDuplicate *bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
// CreateOptions holds options to create a network.
|
||||
type CreateOptions struct {
|
||||
Name string // Name is the requested name of the network.
|
||||
Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
|
||||
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
|
||||
EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4.
|
||||
|
|
@ -43,31 +34,10 @@ type CreateOptions struct {
|
|||
ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
|
||||
Options map[string]string // Options specifies the network-specific options to use for when creating the network.
|
||||
Labels map[string]string // Labels holds metadata specific to the network being created.
|
||||
}
|
||||
|
||||
// ListOptions holds parameters to filter the list of networks with.
|
||||
type ListOptions struct {
|
||||
Filters filters.Args
|
||||
}
|
||||
|
||||
// InspectOptions holds parameters to inspect network.
|
||||
type InspectOptions struct {
|
||||
Scope string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// ConnectOptions represents the data to be used to connect a container to the
|
||||
// network.
|
||||
type ConnectOptions struct {
|
||||
Container string
|
||||
EndpointConfig *EndpointSettings `json:",omitempty"`
|
||||
}
|
||||
|
||||
// DisconnectOptions represents the data to be used to disconnect a container
|
||||
// from the network.
|
||||
type DisconnectOptions struct {
|
||||
Container string
|
||||
Force bool
|
||||
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
|
||||
// package to older daemons.
|
||||
CheckDuplicate *bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Inspect is the body of the "get network" http response message.
|
||||
|
|
@ -0,0 +1 @@
|
|||
testdata/rapid/**
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type CapabilityID struct {
|
||||
Capability string
|
||||
Prefix string
|
||||
Version string
|
||||
}
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CapabilityID{}
|
||||
_ encoding.TextUnmarshaler = (*CapabilityID)(nil)
|
||||
_ encoding.TextMarshaler = CapabilityID{}
|
||||
)
|
||||
|
||||
// String implements [fmt.Stringer] for CapabilityID
|
||||
func (t CapabilityID) String() string {
|
||||
return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version)
|
||||
}
|
||||
|
||||
// UnmarshalText implements [encoding.TextUnmarshaler] for CapabilityID
|
||||
func (t *CapabilityID) UnmarshalText(p []byte) error {
|
||||
fqcap, version, _ := bytes.Cut(p, []byte{'/'})
|
||||
idx := bytes.LastIndexByte(fqcap, '.')
|
||||
if idx < 0 {
|
||||
t.Prefix = ""
|
||||
t.Capability = string(fqcap)
|
||||
} else {
|
||||
t.Prefix = string(fqcap[:idx])
|
||||
t.Capability = string(fqcap[idx+1:])
|
||||
}
|
||||
t.Version = string(version)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText implements [encoding.TextMarshaler] for CapabilityID
|
||||
func (t CapabilityID) MarshalText() ([]byte, error) {
|
||||
// Assert that the value can be round-tripped successfully.
|
||||
if strings.Contains(t.Capability, ".") {
|
||||
return nil, fmt.Errorf("capability %q cannot contain a dot", t.Capability)
|
||||
}
|
||||
if strings.Contains(t.Prefix, "/") {
|
||||
return nil, fmt.Errorf("prefix %q cannot contain a slash", t.Prefix)
|
||||
}
|
||||
if strings.Contains(t.Capability, "/") {
|
||||
return nil, fmt.Errorf("capability %q cannot contain a slash", t.Capability)
|
||||
}
|
||||
return []byte(t.String()), nil
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
package types
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package plugin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// PluginDevice plugin device
|
||||
// swagger:model PluginDevice
|
||||
type PluginDevice struct {
|
||||
// Device device
|
||||
//
|
||||
// swagger:model Device
|
||||
type Device struct {
|
||||
|
||||
// description
|
||||
// Required: true
|
||||
|
|
@ -16,6 +19,7 @@ type PluginDevice struct {
|
|||
Name string `json:"Name"`
|
||||
|
||||
// path
|
||||
// Example: /dev/fuse
|
||||
// Required: true
|
||||
Path *string `json:"Path"`
|
||||
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
package types
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package plugin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// PluginEnv plugin env
|
||||
// swagger:model PluginEnv
|
||||
type PluginEnv struct {
|
||||
// Env env
|
||||
//
|
||||
// swagger:model Env
|
||||
type Env struct {
|
||||
|
||||
// description
|
||||
// Required: true
|
||||
|
|
@ -1,25 +1,32 @@
|
|||
package types
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package plugin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// PluginMount plugin mount
|
||||
// swagger:model PluginMount
|
||||
type PluginMount struct {
|
||||
// Mount mount
|
||||
//
|
||||
// swagger:model Mount
|
||||
type Mount struct {
|
||||
|
||||
// description
|
||||
// Example: This is a mount that's used by the plugin.
|
||||
// Required: true
|
||||
Description string `json:"Description"`
|
||||
|
||||
// destination
|
||||
// Example: /mnt/state
|
||||
// Required: true
|
||||
Destination string `json:"Destination"`
|
||||
|
||||
// name
|
||||
// Example: some-mount
|
||||
// Required: true
|
||||
Name string `json:"Name"`
|
||||
|
||||
// options
|
||||
// Example: ["rbind","rw"]
|
||||
// Required: true
|
||||
Options []string `json:"Options"`
|
||||
|
||||
|
|
@ -28,10 +35,12 @@ type PluginMount struct {
|
|||
Settable []string `json:"Settable"`
|
||||
|
||||
// source
|
||||
// Example: /var/lib/docker/plugins/
|
||||
// Required: true
|
||||
Source *string `json:"Source"`
|
||||
|
||||
// type
|
||||
// Example: bind
|
||||
// Required: true
|
||||
Type string `json:"Type"`
|
||||
}
|
||||
|
|
@ -1,110 +1,130 @@
|
|||
package types
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package plugin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// Plugin A plugin for the Engine API
|
||||
//
|
||||
// swagger:model Plugin
|
||||
type Plugin struct {
|
||||
|
||||
// config
|
||||
// Required: true
|
||||
Config PluginConfig `json:"Config"`
|
||||
Config Config `json:"Config"`
|
||||
|
||||
// True if the plugin is running. False if the plugin is not running, only installed.
|
||||
// Example: true
|
||||
// Required: true
|
||||
Enabled bool `json:"Enabled"`
|
||||
|
||||
// Id
|
||||
// Example: 5724e2c8652da337ab2eedd19fc6fc0ec908e4bd907c7421bf6a8dfc70c4c078
|
||||
ID string `json:"Id,omitempty"`
|
||||
|
||||
// name
|
||||
// Example: tiborvass/sample-volume-plugin
|
||||
// Required: true
|
||||
Name string `json:"Name"`
|
||||
|
||||
// plugin remote reference used to push/pull the plugin
|
||||
// Example: localhost:5000/tiborvass/sample-volume-plugin:latest
|
||||
PluginReference string `json:"PluginReference,omitempty"`
|
||||
|
||||
// settings
|
||||
// Required: true
|
||||
Settings PluginSettings `json:"Settings"`
|
||||
Settings Settings `json:"Settings"`
|
||||
}
|
||||
|
||||
// PluginConfig The config of a plugin.
|
||||
// swagger:model PluginConfig
|
||||
type PluginConfig struct {
|
||||
// Config The config of a plugin.
|
||||
//
|
||||
// swagger:model Config
|
||||
type Config struct {
|
||||
|
||||
// args
|
||||
// Required: true
|
||||
Args PluginConfigArgs `json:"Args"`
|
||||
Args Args `json:"Args"`
|
||||
|
||||
// description
|
||||
// Example: A sample volume plugin for Docker
|
||||
// Required: true
|
||||
Description string `json:"Description"`
|
||||
|
||||
// Docker Version used to create the plugin
|
||||
// Example: 17.06.0-ce
|
||||
DockerVersion string `json:"DockerVersion,omitempty"`
|
||||
|
||||
// documentation
|
||||
// Example: https://docs.docker.com/engine/extend/plugins/
|
||||
// Required: true
|
||||
Documentation string `json:"Documentation"`
|
||||
|
||||
// entrypoint
|
||||
// Example: ["/usr/bin/sample-volume-plugin","/data"]
|
||||
// Required: true
|
||||
Entrypoint []string `json:"Entrypoint"`
|
||||
|
||||
// env
|
||||
// Example: [{"Description":"If set, prints debug messages","Name":"DEBUG","Settable":null,"Value":"0"}]
|
||||
// Required: true
|
||||
Env []PluginEnv `json:"Env"`
|
||||
Env []Env `json:"Env"`
|
||||
|
||||
// interface
|
||||
// Required: true
|
||||
Interface PluginConfigInterface `json:"Interface"`
|
||||
Interface Interface `json:"Interface"`
|
||||
|
||||
// ipc host
|
||||
// Example: false
|
||||
// Required: true
|
||||
IpcHost bool `json:"IpcHost"`
|
||||
|
||||
// linux
|
||||
// Required: true
|
||||
Linux PluginConfigLinux `json:"Linux"`
|
||||
Linux LinuxConfig `json:"Linux"`
|
||||
|
||||
// mounts
|
||||
// Required: true
|
||||
Mounts []PluginMount `json:"Mounts"`
|
||||
Mounts []Mount `json:"Mounts"`
|
||||
|
||||
// network
|
||||
// Required: true
|
||||
Network PluginConfigNetwork `json:"Network"`
|
||||
Network NetworkConfig `json:"Network"`
|
||||
|
||||
// pid host
|
||||
// Example: false
|
||||
// Required: true
|
||||
PidHost bool `json:"PidHost"`
|
||||
|
||||
// propagated mount
|
||||
// Example: /mnt/volumes
|
||||
// Required: true
|
||||
PropagatedMount string `json:"PropagatedMount"`
|
||||
|
||||
// user
|
||||
User PluginConfigUser `json:"User,omitempty"`
|
||||
User User `json:"User,omitempty"`
|
||||
|
||||
// work dir
|
||||
// Example: /bin/
|
||||
// Required: true
|
||||
WorkDir string `json:"WorkDir"`
|
||||
|
||||
// rootfs
|
||||
Rootfs *PluginConfigRootfs `json:"rootfs,omitempty"`
|
||||
Rootfs *RootFS `json:"rootfs,omitempty"`
|
||||
}
|
||||
|
||||
// PluginConfigArgs plugin config args
|
||||
// swagger:model PluginConfigArgs
|
||||
type PluginConfigArgs struct {
|
||||
// Args args
|
||||
//
|
||||
// swagger:model Args
|
||||
type Args struct {
|
||||
|
||||
// description
|
||||
// Example: command line arguments
|
||||
// Required: true
|
||||
Description string `json:"Description"`
|
||||
|
||||
// name
|
||||
// Example: args
|
||||
// Required: true
|
||||
Name string `json:"Name"`
|
||||
|
||||
|
|
@ -117,73 +137,90 @@ type PluginConfigArgs struct {
|
|||
Value []string `json:"Value"`
|
||||
}
|
||||
|
||||
// PluginConfigInterface The interface between Docker and the plugin
|
||||
// swagger:model PluginConfigInterface
|
||||
type PluginConfigInterface struct {
|
||||
// Interface The interface between Docker and the plugin
|
||||
//
|
||||
// swagger:model Interface
|
||||
type Interface struct {
|
||||
|
||||
// Protocol to use for clients connecting to the plugin.
|
||||
// Example: some.protocol/v1.0
|
||||
// Enum: ["","moby.plugins.http/v1"]
|
||||
ProtocolScheme string `json:"ProtocolScheme,omitempty"`
|
||||
|
||||
// socket
|
||||
// Example: plugins.sock
|
||||
// Required: true
|
||||
Socket string `json:"Socket"`
|
||||
|
||||
// types
|
||||
// Example: ["docker.volumedriver/1.0"]
|
||||
// Required: true
|
||||
Types []PluginInterfaceType `json:"Types"`
|
||||
Types []CapabilityID `json:"Types"`
|
||||
}
|
||||
|
||||
// PluginConfigLinux plugin config linux
|
||||
// swagger:model PluginConfigLinux
|
||||
type PluginConfigLinux struct {
|
||||
// LinuxConfig linux config
|
||||
//
|
||||
// swagger:model LinuxConfig
|
||||
type LinuxConfig struct {
|
||||
|
||||
// allow all devices
|
||||
// Example: false
|
||||
// Required: true
|
||||
AllowAllDevices bool `json:"AllowAllDevices"`
|
||||
|
||||
// capabilities
|
||||
// Example: ["CAP_SYS_ADMIN","CAP_SYSLOG"]
|
||||
// Required: true
|
||||
Capabilities []string `json:"Capabilities"`
|
||||
|
||||
// devices
|
||||
// Required: true
|
||||
Devices []PluginDevice `json:"Devices"`
|
||||
Devices []Device `json:"Devices"`
|
||||
}
|
||||
|
||||
// PluginConfigNetwork plugin config network
|
||||
// swagger:model PluginConfigNetwork
|
||||
type PluginConfigNetwork struct {
|
||||
// NetworkConfig network config
|
||||
//
|
||||
// swagger:model NetworkConfig
|
||||
type NetworkConfig struct {
|
||||
|
||||
// type
|
||||
// Example: host
|
||||
// Required: true
|
||||
Type string `json:"Type"`
|
||||
}
|
||||
|
||||
// PluginConfigRootfs plugin config rootfs
|
||||
// swagger:model PluginConfigRootfs
|
||||
type PluginConfigRootfs struct {
|
||||
// RootFS root f s
|
||||
//
|
||||
// swagger:model RootFS
|
||||
type RootFS struct {
|
||||
|
||||
// diff ids
|
||||
// Example: ["sha256:675532206fbf3030b8458f88d6e26d4eb1577688a25efec97154c94e8b6b4887","sha256:e216a057b1cb1efc11f8a268f37ef62083e70b1b38323ba252e25ac88904a7e8"]
|
||||
DiffIds []string `json:"diff_ids"`
|
||||
|
||||
// type
|
||||
// Example: layers
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// PluginConfigUser plugin config user
|
||||
// swagger:model PluginConfigUser
|
||||
type PluginConfigUser struct {
|
||||
// User user
|
||||
//
|
||||
// swagger:model User
|
||||
type User struct {
|
||||
|
||||
// g ID
|
||||
// Example: 1000
|
||||
GID uint32 `json:"GID,omitempty"`
|
||||
|
||||
// UID
|
||||
// Example: 1000
|
||||
UID uint32 `json:"UID,omitempty"`
|
||||
}
|
||||
|
||||
// PluginSettings Settings that can be modified by users.
|
||||
// swagger:model PluginSettings
|
||||
type PluginSettings struct {
|
||||
// Settings user-configurable settings for the plugin.
|
||||
//
|
||||
// swagger:model Settings
|
||||
type Settings struct {
|
||||
|
||||
// args
|
||||
// Required: true
|
||||
|
|
@ -191,13 +228,14 @@ type PluginSettings struct {
|
|||
|
||||
// devices
|
||||
// Required: true
|
||||
Devices []PluginDevice `json:"Devices"`
|
||||
Devices []Device `json:"Devices"`
|
||||
|
||||
// env
|
||||
// Example: ["DEBUG=0"]
|
||||
// Required: true
|
||||
Env []string `json:"Env"`
|
||||
|
||||
// mounts
|
||||
// Required: true
|
||||
Mounts []PluginMount `json:"Mounts"`
|
||||
Mounts []Mount `json:"Mounts"`
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// ListResponse contains the response for the Engine API
|
||||
type ListResponse []*Plugin
|
||||
|
||||
// Privilege describes a permission the user has to accept
|
||||
// upon installing a plugin.
|
||||
type Privilege struct {
|
||||
Name string
|
||||
Description string
|
||||
Value []string
|
||||
}
|
||||
|
||||
// Privileges is a list of Privilege
|
||||
type Privileges []Privilege
|
||||
|
||||
func (s Privileges) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s Privileges) Less(i, j int) bool {
|
||||
return s[i].Name < s[j].Name
|
||||
}
|
||||
|
||||
func (s Privileges) Swap(i, j int) {
|
||||
sort.Strings(s[i].Value)
|
||||
sort.Strings(s[j].Value)
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package registry
|
||||
|
||||
import "context"
|
||||
|
||||
// AuthHeader is the name of the header used to send encoded registry
|
||||
// authorization credentials for registry operations (push/pull).
|
||||
const AuthHeader = "X-Registry-Auth"
|
||||
|
||||
// RequestAuthConfig is a function interface that clients can supply
|
||||
// to retry operations after getting an authorization error.
|
||||
//
|
||||
// The function must return the [AuthHeader] value ([AuthConfig]), encoded
|
||||
// in base64url format ([RFC4648, section 5]), which can be decoded by
|
||||
// [DecodeAuthConfig].
|
||||
//
|
||||
// It must return an error if the privilege request fails.
|
||||
//
|
||||
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
|
||||
type RequestAuthConfig func(context.Context) (string, error)
|
||||
|
||||
// AuthConfig contains authorization information for connecting to a Registry.
|
||||
type AuthConfig struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Auth string `json:"auth,omitempty"`
|
||||
|
||||
// Email is an optional value associated with the username.
|
||||
//
|
||||
// Deprecated: This field is deprecated since docker 1.11 (API v1.23) and will be removed in the next release.
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
ServerAddress string `json:"serveraddress,omitempty"`
|
||||
|
||||
// IdentityToken is used to authenticate the user and get
|
||||
// an access token for the registry.
|
||||
IdentityToken string `json:"identitytoken,omitempty"`
|
||||
|
||||
// RegistryToken is a bearer token to be sent to a registry
|
||||
RegistryToken string `json:"registrytoken,omitempty"`
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue