Merge pull request #6635 from thaJeztah/bump_modules

vendor: github.com/moby/moby/api v1.52.0-rc.1, moby/client v0.1.0-rc.1
This commit is contained in:
Paweł Gronowski
2025-11-07 01:31:10 +01:00
committed by GitHub
14 changed files with 162 additions and 201 deletions

View File

@ -201,7 +201,7 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execOptions *cl
return getExecExitStatus(ctx, apiClient, execID)
}
func getExecExitStatus(ctx context.Context, apiClient client.ContainerAPIClient, execID string) error {
func getExecExitStatus(ctx context.Context, apiClient client.ExecAPIClient, execID string) error {
resp, err := apiClient.ExecInspect(ctx, execID, client.ExecInspectOptions{})
if err != nil {
// If we can't connect, then the daemon probably died.

View File

@ -14,8 +14,14 @@ import (
"github.com/sirupsen/logrus"
)
// TODO(thaJeztah): split resizeTTYTo
type resizeClient interface {
client.ExecAPIClient
client.ContainerAPIClient
}
// resizeTTYTo resizes TTY to specific height and width.
func resizeTTYTo(ctx context.Context, apiClient client.ContainerAPIClient, id string, height, width uint, isExec bool) error {
func resizeTTYTo(ctx context.Context, apiClient resizeClient, id string, height, width uint, isExec bool) error {
if height == 0 && width == 0 {
return nil
}

View File

@ -16,11 +16,11 @@ import (
)
const (
defaultDiskUsageImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}"
defaultDiskUsageContainerTableFormat = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.Size}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}"
defaultDiskUsageVolumeTableFormat = "table {{.Name}}\t{{.Links}}\t{{.Size}}"
defaultDiskUsageBuildCacheTableFormat = "table {{.ID}}\t{{.CacheType}}\t{{.Size}}\t{{.CreatedSince}}\t{{.LastUsedSince}}\t{{.UsageCount}}\t{{.Shared}}"
defaultDiskUsageTableFormat = "table {{.Type}}\t{{.TotalCount}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}"
defaultDiskUsageImageTableFormat Format = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}"
defaultDiskUsageContainerTableFormat Format = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.Size}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}"
defaultDiskUsageVolumeTableFormat Format = "table {{.Name}}\t{{.Links}}\t{{.Size}}"
defaultDiskUsageBuildCacheTableFormat Format = "table {{.ID}}\t{{.CacheType}}\t{{.Size}}\t{{.CreatedSince}}\t{{.LastUsedSince}}\t{{.UsageCount}}\t{{.Shared}}"
defaultDiskUsageTableFormat Format = "table {{.Type}}\t{{.TotalCount}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}"
typeHeader = "TYPE"
totalHeader = "TOTAL"
@ -42,10 +42,10 @@ type DiskUsageContext struct {
VolumeDiskUsage client.VolumesDiskUsage
}
func (ctx *DiskUsageContext) startSubsection(format string) (*template.Template, error) {
func (ctx *DiskUsageContext) startSubsection(format Format) (*template.Template, error) {
ctx.buffer = &bytes.Buffer{}
ctx.header = ""
ctx.Format = Format(format)
ctx.Format = format
ctx.preFormat()
return ctx.parseFormat()
@ -69,7 +69,7 @@ func NewDiskUsageFormat(source string, verbose bool) Format {
{{end -}}`
return format
case !verbose && source == TableFormatKey:
return Format(defaultDiskUsageTableFormat)
return defaultDiskUsageTableFormat
case !verbose && source == RawFormatKey:
format := `type: {{.Type}}
total: {{.TotalCount}}
@ -96,8 +96,8 @@ func (ctx *DiskUsageContext) Write() (err error) {
}
err = ctx.contextFormat(tmpl, &diskUsageImagesContext{
totalCount: ctx.ImageDiskUsage.TotalImages,
activeCount: ctx.ImageDiskUsage.ActiveImages,
totalCount: ctx.ImageDiskUsage.TotalCount,
activeCount: ctx.ImageDiskUsage.ActiveCount,
totalSize: ctx.ImageDiskUsage.TotalSize,
reclaimable: ctx.ImageDiskUsage.Reclaimable,
images: ctx.ImageDiskUsage.Items,
@ -106,8 +106,8 @@ func (ctx *DiskUsageContext) Write() (err error) {
return err
}
err = ctx.contextFormat(tmpl, &diskUsageContainersContext{
totalCount: ctx.ContainerDiskUsage.TotalContainers,
activeCount: ctx.ContainerDiskUsage.ActiveContainers,
totalCount: ctx.ContainerDiskUsage.TotalCount,
activeCount: ctx.ContainerDiskUsage.ActiveCount,
totalSize: ctx.ContainerDiskUsage.TotalSize,
reclaimable: ctx.ContainerDiskUsage.Reclaimable,
containers: ctx.ContainerDiskUsage.Items,
@ -117,8 +117,8 @@ func (ctx *DiskUsageContext) Write() (err error) {
}
err = ctx.contextFormat(tmpl, &diskUsageVolumesContext{
totalCount: ctx.VolumeDiskUsage.TotalVolumes,
activeCount: ctx.VolumeDiskUsage.ActiveVolumes,
totalCount: ctx.VolumeDiskUsage.TotalCount,
activeCount: ctx.VolumeDiskUsage.ActiveCount,
totalSize: ctx.VolumeDiskUsage.TotalSize,
reclaimable: ctx.VolumeDiskUsage.Reclaimable,
volumes: ctx.VolumeDiskUsage.Items,
@ -128,8 +128,8 @@ func (ctx *DiskUsageContext) Write() (err error) {
}
err = ctx.contextFormat(tmpl, &diskUsageBuilderContext{
totalCount: ctx.BuildCacheDiskUsage.TotalBuildCacheRecords,
activeCount: ctx.BuildCacheDiskUsage.ActiveBuildCacheRecords,
totalCount: ctx.BuildCacheDiskUsage.TotalCount,
activeCount: ctx.BuildCacheDiskUsage.ActiveCount,
builderSize: ctx.BuildCacheDiskUsage.TotalSize,
reclaimable: ctx.BuildCacheDiskUsage.Reclaimable,
buildCache: ctx.BuildCacheDiskUsage.Items,
@ -226,7 +226,7 @@ func (ctx *DiskUsageContext) verboseWriteTable(duc *diskUsageContext) error {
if err != nil {
return err
}
ctx.Output.Write([]byte("Images space usage:\n\n"))
_, _ = ctx.Output.Write([]byte("Images space usage:\n\n"))
for _, img := range duc.Images {
if err := ctx.contextFormat(tmpl, img); err != nil {
return err
@ -238,7 +238,7 @@ func (ctx *DiskUsageContext) verboseWriteTable(duc *diskUsageContext) error {
if err != nil {
return err
}
ctx.Output.Write([]byte("\nContainers space usage:\n\n"))
_, _ = ctx.Output.Write([]byte("\nContainers space usage:\n\n"))
for _, c := range duc.Containers {
if err := ctx.contextFormat(tmpl, c); err != nil {
return err

View File

@ -28,8 +28,8 @@ require (
github.com/google/uuid v1.6.0
github.com/mattn/go-runewidth v0.0.19
github.com/moby/go-archive v0.1.0
github.com/moby/moby/api v1.52.0-beta.4.0.20251106221347-217fd7890581
github.com/moby/moby/client v0.1.0-beta.3.0.20251106221347-217fd7890581
github.com/moby/moby/api v1.52.0-rc.1
github.com/moby/moby/client v0.1.0-rc.1
github.com/moby/patternmatcher v0.6.0
github.com/moby/swarmkit/v2 v2.1.1
github.com/moby/sys/atomicwriter v0.1.0

View File

@ -113,10 +113,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-beta.4.0.20251106221347-217fd7890581 h1:Qa8MTSJUIV0K8sbG3RgJeEp5Q0GzWIVCKtalKpWewPo=
github.com/moby/moby/api v1.52.0-beta.4.0.20251106221347-217fd7890581/go.mod h1:v0K/motq8oWmx+rtApG1rBTIpQ8KUONUjpf+U73gags=
github.com/moby/moby/client v0.1.0-beta.3.0.20251106221347-217fd7890581 h1:pW39Fs9C96BH5ZRzwYLrIXNtFLuD0V72BkJHpwtcC/E=
github.com/moby/moby/client v0.1.0-beta.3.0.20251106221347-217fd7890581/go.mod h1:py3jWFsk61C4EZ1Cv8zgbv7nsJ6NjGzZFVdPoSSJ3NE=
github.com/moby/moby/api v1.52.0-rc.1 h1:yiNz/QzD4Jr1gyKl2iMo7OCZwwY+Xb3BltKv1xipwXo=
github.com/moby/moby/api v1.52.0-rc.1/go.mod h1:v0K/motq8oWmx+rtApG1rBTIpQ8KUONUjpf+U73gags=
github.com/moby/moby/client v0.1.0-rc.1 h1:NfuQec3HvQkPf4EvVkoFGPsBvlAc8CCyQN1m1kGSEX8=
github.com/moby/moby/client v0.1.0-rc.1/go.mod h1:qYzoKHz8qu4Ie1j41CWYhfNRHo8uhs5ay7cfx309Aqc=
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.1.1 h1:yvTJ8MMCc3f0qTA44J6R59EZ5yZawdYopkpuLk4+ICU=

View File

@ -13,7 +13,7 @@ type DiskUsage struct {
// Count of active build cache records.
//
// Example: 1
ActiveBuildCacheRecords int64 `json:"ActiveBuildCacheRecords,omitempty"`
ActiveCount int64 `json:"ActiveCount,omitempty"`
// List of build cache records.
//
@ -27,7 +27,7 @@ type DiskUsage struct {
// Count of all build cache records.
//
// Example: 4
TotalBuildCacheRecords int64 `json:"TotalBuildCacheRecords,omitempty"`
TotalCount int64 `json:"TotalCount,omitempty"`
// Disk space in use by build cache records.
//

View File

@ -13,7 +13,7 @@ type DiskUsage struct {
// Count of active containers.
//
// Example: 1
ActiveContainers int64 `json:"ActiveContainers,omitempty"`
ActiveCount int64 `json:"ActiveCount,omitempty"`
// List of container summaries.
//
@ -27,7 +27,7 @@ type DiskUsage struct {
// Count of all containers.
//
// Example: 4
TotalContainers int64 `json:"TotalContainers,omitempty"`
TotalCount int64 `json:"TotalCount,omitempty"`
// Disk space in use by containers.
//

View File

@ -13,7 +13,7 @@ type DiskUsage struct {
// Count of active images.
//
// Example: 1
ActiveImages int64 `json:"ActiveImages,omitempty"`
ActiveCount int64 `json:"ActiveCount,omitempty"`
// List of image summaries.
//
@ -27,7 +27,7 @@ type DiskUsage struct {
// Count of all images.
//
// Example: 4
TotalImages int64 `json:"TotalImages,omitempty"`
TotalCount int64 `json:"TotalCount,omitempty"`
// Disk space in use by images.
//

View File

@ -13,7 +13,7 @@ type DiskUsage struct {
// Count of active volumes.
//
// Example: 1
ActiveVolumes int64 `json:"ActiveVolumes,omitempty"`
ActiveCount int64 `json:"ActiveCount,omitempty"`
// List of volumes.
//
@ -24,13 +24,13 @@ type DiskUsage struct {
// Example: 12345678
Reclaimable int64 `json:"Reclaimable,omitempty"`
// Count of all volumes.
//
// Example: 4
TotalCount int64 `json:"TotalCount,omitempty"`
// Disk space in use by volumes.
//
// Example: 98765432
TotalSize int64 `json:"TotalSize,omitempty"`
// Count of all volumes.
//
// Example: 4
TotalVolumes int64 `json:"TotalVolumes,omitempty"`
}

View File

@ -16,6 +16,9 @@ type stableAPIClient interface {
ConfigAPIClient
ContainerAPIClient
DistributionAPIClient
RegistrySearchClient
ExecAPIClient
ImageBuildAPIClient
ImageAPIClient
NetworkAPIClient
PluginAPIClient
@ -36,6 +39,7 @@ type SwarmManagementAPIClient interface {
SwarmAPIClient
NodeAPIClient
ServiceAPIClient
TaskAPIClient
SecretAPIClient
ConfigAPIClient
}
@ -47,40 +51,45 @@ type HijackDialer interface {
// ContainerAPIClient defines API client methods for the containers
type ContainerAPIClient interface {
ContainerAttach(ctx context.Context, container string, options ContainerAttachOptions) (ContainerAttachResult, error)
ContainerCommit(ctx context.Context, container string, options ContainerCommitOptions) (ContainerCommitResult, error)
ContainerCreate(ctx context.Context, options ContainerCreateOptions) (ContainerCreateResult, error)
ContainerDiff(ctx context.Context, container string, options ContainerDiffOptions) (ContainerDiffResult, error)
ExecAPIClient
ContainerExport(ctx context.Context, container string, options ContainerExportOptions) (ContainerExportResult, error)
ContainerInspect(ctx context.Context, container string, options ContainerInspectOptions) (ContainerInspectResult, error)
ContainerKill(ctx context.Context, container string, options ContainerKillOptions) (ContainerKillResult, error)
ContainerList(ctx context.Context, options ContainerListOptions) (ContainerListResult, error)
ContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (ContainerLogsResult, error)
ContainerPause(ctx context.Context, container string, options ContainerPauseOptions) (ContainerPauseResult, error)
ContainerUpdate(ctx context.Context, container string, updateConfig ContainerUpdateOptions) (ContainerUpdateResult, error)
ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) (ContainerRemoveResult, error)
ContainerRename(ctx context.Context, container string, options ContainerRenameOptions) (ContainerRenameResult, error)
ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) (ContainerResizeResult, error)
ContainerRestart(ctx context.Context, container string, options ContainerRestartOptions) (ContainerRestartResult, error)
ContainerStatPath(ctx context.Context, container string, options ContainerStatPathOptions) (ContainerStatPathResult, error)
ContainerStats(ctx context.Context, container string, options ContainerStatsOptions) (ContainerStatsResult, error)
ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
ContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (ContainerLogsResult, error)
ContainerStart(ctx context.Context, container string, options ContainerStartOptions) (ContainerStartResult, error)
ContainerStop(ctx context.Context, container string, options ContainerStopOptions) (ContainerStopResult, error)
ContainerTop(ctx context.Context, container string, options ContainerTopOptions) (ContainerTopResult, error)
ContainerRestart(ctx context.Context, container string, options ContainerRestartOptions) (ContainerRestartResult, error)
ContainerPause(ctx context.Context, container string, options ContainerPauseOptions) (ContainerPauseResult, error)
ContainerUnpause(ctx context.Context, container string, options ContainerUnpauseOptions) (ContainerUnpauseResult, error)
ContainerUpdate(ctx context.Context, container string, updateConfig ContainerUpdateOptions) (ContainerUpdateResult, error)
ContainerWait(ctx context.Context, container string, options ContainerWaitOptions) ContainerWaitResult
ContainerKill(ctx context.Context, container string, options ContainerKillOptions) (ContainerKillResult, error)
ContainerRename(ctx context.Context, container string, options ContainerRenameOptions) (ContainerRenameResult, error)
ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) (ContainerResizeResult, error)
ContainerAttach(ctx context.Context, container string, options ContainerAttachOptions) (ContainerAttachResult, error)
ContainerCommit(ctx context.Context, container string, options ContainerCommitOptions) (ContainerCommitResult, error)
ContainerDiff(ctx context.Context, container string, options ContainerDiffOptions) (ContainerDiffResult, error)
ContainerExport(ctx context.Context, container string, options ContainerExportOptions) (ContainerExportResult, error)
ContainerStats(ctx context.Context, container string, options ContainerStatsOptions) (ContainerStatsResult, error)
ContainerTop(ctx context.Context, container string, options ContainerTopOptions) (ContainerTopResult, error)
ContainerStatPath(ctx context.Context, container string, options ContainerStatPathOptions) (ContainerStatPathResult, error)
CopyFromContainer(ctx context.Context, container string, options CopyFromContainerOptions) (CopyFromContainerResult, error)
CopyToContainer(ctx context.Context, container string, options CopyToContainerOptions) (CopyToContainerResult, error)
ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
}
type ExecAPIClient interface {
ExecCreate(ctx context.Context, container string, options ExecCreateOptions) (ExecCreateResult, error)
ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error)
ExecAttach(ctx context.Context, execID string, options ExecAttachOptions) (ExecAttachResult, error)
ExecInspect(ctx context.Context, execID string, options ExecInspectOptions) (ExecInspectResult, error)
ExecResize(ctx context.Context, execID string, options ExecResizeOptions) (ExecResizeResult, error)
ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error)
ExecAttach(ctx context.Context, execID string, options ExecAttachOptions) (ExecAttachResult, error)
}
// DistributionAPIClient defines API client methods for the registry
@ -88,58 +97,69 @@ type DistributionAPIClient interface {
DistributionInspect(ctx context.Context, image string, options DistributionInspectOptions) (DistributionInspectResult, error)
}
// ImageAPIClient defines API client methods for the images
type ImageAPIClient interface {
type RegistrySearchClient interface {
ImageSearch(ctx context.Context, term string, options ImageSearchOptions) (ImageSearchResult, error)
}
// ImageBuildAPIClient defines API client methods for building images
// using the REST API.
type ImageBuildAPIClient interface {
ImageBuild(ctx context.Context, context io.Reader, options ImageBuildOptions) (ImageBuildResult, error)
BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (BuildCachePruneResult, error)
BuildCancel(ctx context.Context, id string, opts BuildCancelOptions) (BuildCancelResult, error)
}
// ImageAPIClient defines API client methods for the images
type ImageAPIClient interface {
ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (ImageImportResult, error)
ImageList(ctx context.Context, options ImageListOptions) (ImageListResult, error)
ImagePull(ctx context.Context, ref string, options ImagePullOptions) (ImagePullResponse, error)
ImagePush(ctx context.Context, ref string, options ImagePushOptions) (ImagePushResponse, error)
ImageRemove(ctx context.Context, image string, options ImageRemoveOptions) (ImageRemoveResult, error)
ImageSearch(ctx context.Context, term string, options ImageSearchOptions) (ImageSearchResult, error)
ImageTag(ctx context.Context, options ImageTagOptions) (ImageTagResult, error)
ImagePrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error)
ImageInspect(ctx context.Context, image string, _ ...ImageInspectOption) (ImageInspectResult, error)
ImageHistory(ctx context.Context, image string, _ ...ImageHistoryOption) (ImageHistoryResult, error)
ImageLoad(ctx context.Context, input io.Reader, _ ...ImageLoadOption) (ImageLoadResult, error)
ImageSave(ctx context.Context, images []string, _ ...ImageSaveOption) (ImageSaveResult, error)
}
// NetworkAPIClient defines API client methods for the networks
type NetworkAPIClient interface {
NetworkConnect(ctx context.Context, network string, options NetworkConnectOptions) (NetworkConnectResult, error)
NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (NetworkCreateResult, error)
NetworkDisconnect(ctx context.Context, network string, options NetworkDisconnectOptions) (NetworkDisconnectResult, error)
NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (NetworkInspectResult, error)
NetworkList(ctx context.Context, options NetworkListOptions) (NetworkListResult, error)
NetworkRemove(ctx context.Context, network string, options NetworkRemoveOptions) (NetworkRemoveResult, error)
NetworkPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error)
NetworkConnect(ctx context.Context, network string, options NetworkConnectOptions) (NetworkConnectResult, error)
NetworkDisconnect(ctx context.Context, network string, options NetworkDisconnectOptions) (NetworkDisconnectResult, error)
}
// NodeAPIClient defines API client methods for the nodes
type NodeAPIClient interface {
NodeInspect(ctx context.Context, nodeID string, options NodeInspectOptions) (NodeInspectResult, error)
NodeList(ctx context.Context, options NodeListOptions) (NodeListResult, error)
NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) (NodeRemoveResult, error)
NodeUpdate(ctx context.Context, nodeID string, options NodeUpdateOptions) (NodeUpdateResult, error)
NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) (NodeRemoveResult, error)
}
// PluginAPIClient defines API client methods for the plugins
type PluginAPIClient interface {
PluginCreate(ctx context.Context, createContext io.Reader, options PluginCreateOptions) (PluginCreateResult, error)
PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (PluginInstallResult, error)
PluginInspect(ctx context.Context, name string, options PluginInspectOptions) (PluginInspectResult, error)
PluginList(ctx context.Context, options PluginListOptions) (PluginListResult, error)
PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) (PluginRemoveResult, error)
PluginEnable(ctx context.Context, name string, options PluginEnableOptions) (PluginEnableResult, error)
PluginDisable(ctx context.Context, name string, options PluginDisableOptions) (PluginDisableResult, error)
PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (PluginInstallResult, error)
PluginUpgrade(ctx context.Context, name string, options PluginUpgradeOptions) (PluginUpgradeResult, error)
PluginPush(ctx context.Context, name string, options PluginPushOptions) (PluginPushResult, error)
PluginSet(ctx context.Context, name string, options PluginSetOptions) (PluginSetResult, error)
PluginInspect(ctx context.Context, name string, options PluginInspectOptions) (PluginInspectResult, error)
PluginCreate(ctx context.Context, createContext io.Reader, options PluginCreateOptions) (PluginCreateResult, error)
}
// ServiceAPIClient defines API client methods for the services
@ -147,23 +167,30 @@ type ServiceAPIClient interface {
ServiceCreate(ctx context.Context, options ServiceCreateOptions) (ServiceCreateResult, error)
ServiceInspect(ctx context.Context, serviceID string, options ServiceInspectOptions) (ServiceInspectResult, error)
ServiceList(ctx context.Context, options ServiceListOptions) (ServiceListResult, error)
ServiceRemove(ctx context.Context, serviceID string, options ServiceRemoveOptions) (ServiceRemoveResult, error)
ServiceUpdate(ctx context.Context, serviceID string, options ServiceUpdateOptions) (ServiceUpdateResult, error)
ServiceRemove(ctx context.Context, serviceID string, options ServiceRemoveOptions) (ServiceRemoveResult, error)
ServiceLogs(ctx context.Context, serviceID string, options ServiceLogsOptions) (ServiceLogsResult, error)
TaskLogs(ctx context.Context, taskID string, options TaskLogsOptions) (TaskLogsResult, error)
}
// TaskAPIClient defines API client methods to manage swarm tasks.
type TaskAPIClient interface {
TaskInspect(ctx context.Context, taskID string, options TaskInspectOptions) (TaskInspectResult, error)
TaskList(ctx context.Context, options TaskListOptions) (TaskListResult, error)
TaskLogs(ctx context.Context, taskID string, options TaskLogsOptions) (TaskLogsResult, error)
}
// SwarmAPIClient defines API client methods for the swarm
type SwarmAPIClient interface {
SwarmInit(ctx context.Context, options SwarmInitOptions) (SwarmInitResult, error)
SwarmJoin(ctx context.Context, options SwarmJoinOptions) (SwarmJoinResult, error)
SwarmGetUnlockKey(ctx context.Context) (SwarmGetUnlockKeyResult, error)
SwarmUnlock(ctx context.Context, options SwarmUnlockOptions) (SwarmUnlockResult, error)
SwarmLeave(ctx context.Context, options SwarmLeaveOptions) (SwarmLeaveResult, error)
SwarmInspect(ctx context.Context, options SwarmInspectOptions) (SwarmInspectResult, error)
SwarmUpdate(ctx context.Context, options SwarmUpdateOptions) (SwarmUpdateResult, error)
SwarmLeave(ctx context.Context, options SwarmLeaveOptions) (SwarmLeaveResult, error)
SwarmGetUnlockKey(ctx context.Context) (SwarmGetUnlockKeyResult, error)
SwarmUnlock(ctx context.Context, options SwarmUnlockOptions) (SwarmUnlockResult, error)
}
// SystemAPIClient defines API client methods for the system
@ -180,25 +207,25 @@ type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error)
VolumeInspect(ctx context.Context, volumeID string, options VolumeInspectOptions) (VolumeInspectResult, error)
VolumeList(ctx context.Context, options VolumeListOptions) (VolumeListResult, error)
VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error)
VolumeRemove(ctx context.Context, volumeID string, options VolumeRemoveOptions) (VolumeRemoveResult, error)
VolumePrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error)
VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error)
}
// SecretAPIClient defines API client methods for secrets
type SecretAPIClient interface {
SecretList(ctx context.Context, options SecretListOptions) (SecretListResult, error)
SecretCreate(ctx context.Context, options SecretCreateOptions) (SecretCreateResult, error)
SecretRemove(ctx context.Context, id string, options SecretRemoveOptions) (SecretRemoveResult, error)
SecretInspect(ctx context.Context, id string, options SecretInspectOptions) (SecretInspectResult, error)
SecretList(ctx context.Context, options SecretListOptions) (SecretListResult, error)
SecretUpdate(ctx context.Context, id string, options SecretUpdateOptions) (SecretUpdateResult, error)
SecretRemove(ctx context.Context, id string, options SecretRemoveOptions) (SecretRemoveResult, error)
}
// ConfigAPIClient defines API client methods for configs
type ConfigAPIClient interface {
ConfigList(ctx context.Context, options ConfigListOptions) (ConfigListResult, error)
ConfigCreate(ctx context.Context, options ConfigCreateOptions) (ConfigCreateResult, error)
ConfigRemove(ctx context.Context, id string, options ConfigRemoveOptions) (ConfigRemoveResult, error)
ConfigInspect(ctx context.Context, id string, options ConfigInspectOptions) (ConfigInspectResult, error)
ConfigList(ctx context.Context, options ConfigListOptions) (ConfigListResult, error)
ConfigUpdate(ctx context.Context, id string, options ConfigUpdateOptions) (ConfigUpdateResult, error)
ConfigRemove(ctx context.Context, id string, options ConfigRemoveOptions) (ConfigRemoveResult, error)
}

View File

@ -22,18 +22,18 @@ func appendNewline(source []byte) []byte {
return append(source, []byte(streamNewline)...)
}
// FormatStatus formats the specified objects according to the specified format (and id).
func FormatStatus(id, format string, a ...any) []byte {
// formatStatus formats the specified objects according to the specified format (and id).
func formatStatus(id, format string, a ...any) []byte {
str := fmt.Sprintf(format, a...)
b, err := json.Marshal(&jsonstream.Message{ID: id, Status: str})
if err != nil {
return FormatError(err)
return formatError(err)
}
return appendNewline(b)
}
// FormatError formats the error as a JSON object
func FormatError(err error) []byte {
// formatError formats the error as a JSON object
func formatError(err error) []byte {
jsonError, ok := err.(*jsonstream.Error)
if !ok {
jsonError = &jsonstream.Error{Message: err.Error()}
@ -45,7 +45,7 @@ func FormatError(err error) []byte {
}
func (sf *jsonProgressFormatter) formatStatus(id, format string, a ...any) []byte {
return FormatStatus(id, format, a...)
return formatStatus(id, format, a...)
}
// formatProgress formats the progress information for a specified action.
@ -201,28 +201,3 @@ func (out *progressOutput) WriteProgress(prog progress.Progress) error {
return nil
}
// AuxFormatter is a streamFormatter that writes aux progress messages
type AuxFormatter struct {
io.Writer
}
// Emit emits the given interface as an aux progress message
func (sf *AuxFormatter) Emit(id string, aux any) error {
auxJSONBytes, err := json.Marshal(aux)
if err != nil {
return err
}
auxJSON := new(json.RawMessage)
*auxJSON = auxJSONBytes
msgJSON, err := json.Marshal(&jsonstream.Message{ID: id, Aux: auxJSON})
if err != nil {
return err
}
msgJSON = appendNewline(msgJSON)
n, err := sf.Writer.Write(msgJSON)
if n != len(msgJSON) {
return io.ErrShortWrite
}
return err
}

View File

@ -1,47 +0,0 @@
package streamformatter
import (
"encoding/json"
"io"
"github.com/moby/moby/api/types/jsonstream"
)
type streamWriter struct {
io.Writer
lineFormat func([]byte) string
}
func (sw *streamWriter) Write(buf []byte) (int, error) {
formattedBuf := sw.format(buf)
n, err := sw.Writer.Write(formattedBuf)
if n != len(formattedBuf) {
return n, io.ErrShortWrite
}
return len(buf), err
}
func (sw *streamWriter) format(buf []byte) []byte {
msg := &jsonstream.Message{Stream: sw.lineFormat(buf)}
b, err := json.Marshal(msg)
if err != nil {
return FormatError(err)
}
return appendNewline(b)
}
// NewStdoutWriter returns a writer which formats the output as json message
// representing stdout lines
func NewStdoutWriter(out io.Writer) io.Writer {
return &streamWriter{Writer: out, lineFormat: func(buf []byte) string {
return string(buf)
}}
}
// NewStderrWriter returns a writer which formats the output as json message
// representing stderr lines
func NewStderrWriter(out io.Writer) io.Writer {
return &streamWriter{Writer: out, lineFormat: func(buf []byte) string {
return "\033[91m" + string(buf) + "\033[0m"
}}
}

View File

@ -51,11 +51,11 @@ type DiskUsageResult struct {
// ContainersDiskUsage contains disk usage information for containers.
type ContainersDiskUsage struct {
// ActiveContainers is the number of active containers.
ActiveContainers int64
// ActiveCount is the number of active containers.
ActiveCount int64
// TotalContainers is the total number of containers.
TotalContainers int64
// TotalCount is the total number of containers.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
@ -69,11 +69,11 @@ type ContainersDiskUsage struct {
// ImagesDiskUsage contains disk usage information for images.
type ImagesDiskUsage struct {
// ActiveImages is the number of active images.
ActiveImages int64
// ActiveCount is the number of active images.
ActiveCount int64
// TotalImages is the total number of images.
TotalImages int64
// TotalCount is the total number of images.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
@ -87,11 +87,11 @@ type ImagesDiskUsage struct {
// VolumesDiskUsage contains disk usage information for volumes.
type VolumesDiskUsage struct {
// ActiveVolumes is the number of active volumes.
ActiveVolumes int64
// ActiveCount is the number of active volumes.
ActiveCount int64
// TotalVolumes is the total number of volumes.
TotalVolumes int64
// TotalCount is the total number of volumes.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
@ -105,11 +105,11 @@ type VolumesDiskUsage struct {
// BuildCacheDiskUsage contains disk usage information for build cache.
type BuildCacheDiskUsage struct {
// ActiveBuildCacheRecords is the number of active build cache records.
ActiveBuildCacheRecords int64
// ActiveCount is the number of active build cache records.
ActiveCount int64
// TotalBuildCacheRecords is the total number of build cache records.
TotalBuildCacheRecords int64
// TotalCount is the total number of build cache records.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
@ -162,10 +162,10 @@ func (cli *Client) DiskUsage(ctx context.Context, options DiskUsageOptions) (Dis
var r DiskUsageResult
if idu := du.ImageUsage; idu != nil {
r.Images = ImagesDiskUsage{
ActiveImages: idu.ActiveImages,
Reclaimable: idu.Reclaimable,
TotalImages: idu.TotalImages,
TotalSize: idu.TotalSize,
ActiveCount: idu.ActiveCount,
Reclaimable: idu.Reclaimable,
TotalCount: idu.TotalCount,
TotalSize: idu.TotalSize,
}
if options.Verbose {
@ -175,10 +175,10 @@ func (cli *Client) DiskUsage(ctx context.Context, options DiskUsageOptions) (Dis
if cdu := du.ContainerUsage; cdu != nil {
r.Containers = ContainersDiskUsage{
ActiveContainers: cdu.ActiveContainers,
Reclaimable: cdu.Reclaimable,
TotalContainers: cdu.TotalContainers,
TotalSize: cdu.TotalSize,
ActiveCount: cdu.ActiveCount,
Reclaimable: cdu.Reclaimable,
TotalCount: cdu.TotalCount,
TotalSize: cdu.TotalSize,
}
if options.Verbose {
@ -188,10 +188,10 @@ func (cli *Client) DiskUsage(ctx context.Context, options DiskUsageOptions) (Dis
if bdu := du.BuildCacheUsage; bdu != nil {
r.BuildCache = BuildCacheDiskUsage{
ActiveBuildCacheRecords: bdu.ActiveBuildCacheRecords,
Reclaimable: bdu.Reclaimable,
TotalBuildCacheRecords: bdu.TotalBuildCacheRecords,
TotalSize: bdu.TotalSize,
ActiveCount: bdu.ActiveCount,
Reclaimable: bdu.Reclaimable,
TotalCount: bdu.TotalCount,
TotalSize: bdu.TotalSize,
}
if options.Verbose {
@ -201,10 +201,10 @@ func (cli *Client) DiskUsage(ctx context.Context, options DiskUsageOptions) (Dis
if vdu := du.VolumeUsage; vdu != nil {
r.Volumes = VolumesDiskUsage{
ActiveVolumes: vdu.ActiveVolumes,
Reclaimable: vdu.Reclaimable,
TotalVolumes: vdu.TotalVolumes,
TotalSize: vdu.TotalSize,
ActiveCount: vdu.ActiveCount,
Reclaimable: vdu.Reclaimable,
TotalCount: vdu.TotalCount,
TotalSize: vdu.TotalSize,
}
if options.Verbose {
@ -226,15 +226,15 @@ func diskUsageResultFromLegacyAPI(du *system.DiskUsage) DiskUsageResult {
func imageDiskUsageFromLegacyAPI(du *system.DiskUsage) ImagesDiskUsage {
idu := ImagesDiskUsage{
TotalSize: du.LayersSize,
TotalImages: int64(len(du.Images)),
Items: du.Images,
TotalSize: du.LayersSize,
TotalCount: int64(len(du.Images)),
Items: du.Images,
}
var used int64
for _, i := range idu.Items {
if i.Containers > 0 {
idu.ActiveImages++
idu.ActiveCount++
if i.Size == -1 || i.SharedSize == -1 {
continue
@ -243,7 +243,7 @@ func imageDiskUsageFromLegacyAPI(du *system.DiskUsage) ImagesDiskUsage {
}
}
if idu.TotalImages > 0 {
if idu.TotalCount > 0 {
idu.Reclaimable = idu.TotalSize - used
}
@ -252,8 +252,8 @@ func imageDiskUsageFromLegacyAPI(du *system.DiskUsage) ImagesDiskUsage {
func containerDiskUsageFromLegacyAPI(du *system.DiskUsage) ContainersDiskUsage {
cdu := ContainersDiskUsage{
TotalContainers: int64(len(du.Containers)),
Items: du.Containers,
TotalCount: int64(len(du.Containers)),
Items: du.Containers,
}
var used int64
@ -261,7 +261,7 @@ func containerDiskUsageFromLegacyAPI(du *system.DiskUsage) ContainersDiskUsage {
cdu.TotalSize += c.SizeRw
switch strings.ToLower(c.State) {
case "running", "paused", "restarting":
cdu.ActiveContainers++
cdu.ActiveCount++
used += c.SizeRw
}
}
@ -272,8 +272,8 @@ func containerDiskUsageFromLegacyAPI(du *system.DiskUsage) ContainersDiskUsage {
func buildCacheDiskUsageFromLegacyAPI(du *system.DiskUsage) BuildCacheDiskUsage {
bdu := BuildCacheDiskUsage{
TotalBuildCacheRecords: int64(len(du.BuildCache)),
Items: du.BuildCache,
TotalCount: int64(len(du.BuildCache)),
Items: du.BuildCache,
}
var used int64
@ -283,7 +283,7 @@ func buildCacheDiskUsageFromLegacyAPI(du *system.DiskUsage) BuildCacheDiskUsage
}
if b.InUse {
bdu.ActiveBuildCacheRecords++
bdu.ActiveCount++
if !b.Shared {
used += b.Size
}
@ -296,8 +296,8 @@ func buildCacheDiskUsageFromLegacyAPI(du *system.DiskUsage) BuildCacheDiskUsage
func volumeDiskUsageFromLegacyAPI(du *system.DiskUsage) VolumesDiskUsage {
vdu := VolumesDiskUsage{
TotalVolumes: int64(len(du.Volumes)),
Items: du.Volumes,
TotalCount: int64(len(du.Volumes)),
Items: du.Volumes,
}
var used int64
@ -305,7 +305,7 @@ func volumeDiskUsageFromLegacyAPI(du *system.DiskUsage) VolumesDiskUsage {
// Ignore volumes with no usage data
if v.UsageData != nil {
if v.UsageData.RefCount > 0 {
vdu.ActiveVolumes++
vdu.ActiveCount++
used += v.UsageData.Size
}
if v.UsageData.Size > 0 {

4
vendor/modules.txt vendored
View File

@ -167,7 +167,7 @@ github.com/moby/docker-image-spec/specs-go/v1
github.com/moby/go-archive
github.com/moby/go-archive/compression
github.com/moby/go-archive/tarheader
# github.com/moby/moby/api v1.52.0-beta.4.0.20251106221347-217fd7890581
# github.com/moby/moby/api v1.52.0-rc.1
## explicit; go 1.23.0
github.com/moby/moby/api/pkg/authconfig
github.com/moby/moby/api/pkg/stdcopy
@ -189,7 +189,7 @@ github.com/moby/moby/api/types/storage
github.com/moby/moby/api/types/swarm
github.com/moby/moby/api/types/system
github.com/moby/moby/api/types/volume
# github.com/moby/moby/client v0.1.0-beta.3.0.20251106221347-217fd7890581
# github.com/moby/moby/client v0.1.0-rc.1
## explicit; go 1.23.0
github.com/moby/moby/client
github.com/moby/moby/client/internal