vendor: github.com/moby/moby/client v0.4.1, moby/api v1.54.2

- https://github.com/moby/moby/compare/api/v1.54.1...api/v1.54.2
- https://github.com/moby/moby/compare/client/v0.4.0...client/v0.4.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2026-04-21 12:16:59 +02:00
parent 478d9b19a2
commit a2e6003124
6 changed files with 108 additions and 42 deletions
+2 -2
View File
@@ -32,8 +32,8 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/moby/buildkit v0.29.1-0.20260408185135-a243ce438aee github.com/moby/buildkit v0.29.1-0.20260408185135-a243ce438aee
github.com/moby/go-archive v0.2.0 github.com/moby/go-archive v0.2.0
github.com/moby/moby/api v1.54.1 github.com/moby/moby/api v1.54.2
github.com/moby/moby/client v0.4.0 github.com/moby/moby/client v0.4.1
github.com/moby/policy-helpers v0.0.0-20260324161837-b7c0b994300b github.com/moby/policy-helpers v0.0.0-20260324161837-b7c0b994300b
github.com/moby/sys/atomicwriter v0.1.0 github.com/moby/sys/atomicwriter v0.1.0
github.com/moby/sys/mountinfo v0.7.2 github.com/moby/sys/mountinfo v0.7.2
+4 -4
View File
@@ -428,10 +428,10 @@ github.com/moby/go-archive v0.2.0 h1:zg5QDUM2mi0JIM9fdQZWC7U8+2ZfixfTYoHL7rWUcP8
github.com/moby/go-archive v0.2.0/go.mod h1:mNeivT14o8xU+5q1YnNrkQVpK+dnNe/K6fHqnTg4qPU= github.com/moby/go-archive v0.2.0/go.mod h1:mNeivT14o8xU+5q1YnNrkQVpK+dnNe/K6fHqnTg4qPU=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/moby/api v1.54.1 h1:TqVzuJkOLsgLDDwNLmYqACUuTehOHRGKiPhvH8V3Nn4= github.com/moby/moby/api v1.54.2 h1:wiat9QAhnDQjA7wk1kh/TqHz2I1uUA7M7t9SAl/JNXg=
github.com/moby/moby/api v1.54.1/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs= github.com/moby/moby/api v1.54.2/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs=
github.com/moby/moby/client v0.4.0 h1:S+2XegzHQrrvTCvF6s5HFzcrywWQmuVnhOXe2kiWjIw= github.com/moby/moby/client v0.4.1 h1:DMQgisVoMkmMs7fp3ROSdiBnoAu8+vo3GggFl06M/wY=
github.com/moby/moby/client v0.4.0/go.mod h1:QWPbvWchQbxBNdaLSpoKpCdf5E+WxFAgNHogCWDoa7g= github.com/moby/moby/client v0.4.1/go.mod h1:z52C9O2POPOsnxZAy//WtKcQ32P+jT/NGeXu/7nfjGQ=
github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U=
github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/policy-helpers v0.0.0-20260324161837-b7c0b994300b h1:lvBBM2ACrsG5/O1G1caEwlh0XeqA89IQK3xq0Sh/5NI= github.com/moby/policy-helpers v0.0.0-20260324161837-b7c0b994300b h1:lvBBM2ACrsG5/O1G1caEwlh0XeqA89IQK3xq0Sh/5NI=
+28 -16
View File
@@ -12,8 +12,9 @@ const rs = 0x1E
type DecoderFn func(v any) error type DecoderFn func(v any) error
// NewJSONStreamDecoder builds adequate DecoderFn to read json records formatted with specified content-type // NewJSONStreamDecoder builds a DecoderFn to read a stream of JSON records
func NewJSONStreamDecoder(r io.Reader, contentType string) DecoderFn { // formatted with the specified content-type.
func NewJSONStreamDecoder(r io.Reader, contentType types.MediaType) DecoderFn {
switch contentType { switch contentType {
case types.MediaTypeJSONSequence: case types.MediaTypeJSONSequence:
return json.NewDecoder(NewRSFilterReader(r)).Decode return json.NewDecoder(NewRSFilterReader(r)).Decode
@@ -24,27 +25,38 @@ func NewJSONStreamDecoder(r io.Reader, contentType string) DecoderFn {
} }
} }
// RSFilterReader wraps an io.Reader and filters out ASCII RS characters type rsFilterReader struct {
type RSFilterReader struct {
reader io.Reader reader io.Reader
buffer []byte
} }
// NewRSFilterReader creates a new RSFilterReader that filters out RS characters // NewRSFilterReader creates an [io.Reader] that filters out ASCII Record Separators (RS).
func NewRSFilterReader(r io.Reader) *RSFilterReader { func NewRSFilterReader(r io.Reader) io.Reader {
return &RSFilterReader{ return &rsFilterReader{reader: r}
reader: r,
buffer: make([]byte, 4096), // Internal buffer for reading chunks
}
} }
// Read implements the io.Reader interface, filtering out RS characters func (r *rsFilterReader) Read(p []byte) (int, error) {
func (r *RSFilterReader) Read(p []byte) (n int, err error) {
if len(p) == 0 { if len(p) == 0 {
return 0, nil return 0, nil
} }
n, err = r.reader.Read(p) for {
filtered := slices.DeleteFunc(p[:n], func(b byte) bool { return b == rs }) n, err := r.reader.Read(p)
return len(filtered), err if n == 0 {
return 0, err
}
filtered := slices.DeleteFunc(p[:n], func(b byte) bool { return b == rs })
n = len(filtered)
if err != nil {
if err == io.EOF && n > 0 {
return n, nil
}
return n, err
}
if n == 0 {
// Avoid returning (0, nil) after consuming input; keep reading until data or an error (e.g., EOF).
continue
}
return n, nil
}
} }
+64 -13
View File
@@ -8,6 +8,8 @@ import (
"iter" "iter"
"sync" "sync"
"github.com/containerd/errdefs/pkg/errhttp"
"github.com/moby/moby/api/types/jsonstream" "github.com/moby/moby/api/types/jsonstream"
) )
@@ -44,41 +46,90 @@ func (r Stream) Close() error {
var _ io.ReadCloser = Stream{} var _ io.ReadCloser = Stream{}
// JSONMessages decodes the response stream as a sequence of JSONMessages. // JSONMessages decodes the response stream as a sequence of [jsonstream.Message].
// if stream ends or context is cancelled, the underlying [io.Reader] is closed. // The underlying [io.Reader] is closed when the stream ends or if the context
// is cancelled.
func (r Stream) JSONMessages(ctx context.Context) iter.Seq2[jsonstream.Message, error] { func (r Stream) JSONMessages(ctx context.Context) iter.Seq2[jsonstream.Message, error] {
stop := context.AfterFunc(ctx, func() { stop := context.AfterFunc(ctx, func() {
_ = r.Close() _ = r.Close()
}) })
dec := json.NewDecoder(r)
return func(yield func(jsonstream.Message, error) bool) { return func(yield func(jsonstream.Message, error) bool) {
defer func() { defer func() {
stop() // unregister AfterFunc stop() // unregister AfterFunc
r.Close() _ = r.Close()
}() }()
dec := json.NewDecoder(r)
for { for {
var jm jsonstream.Message var jm jsonstream.Message
err := dec.Decode(&jm) if err := dec.Decode(&jm); err != nil {
if errors.Is(err, io.EOF) { if errors.Is(err, io.EOF) {
break return
} }
if ctx.Err() != nil { if err := ctx.Err(); err != nil {
yield(jm, ctx.Err()) // Do not return decoding errors if the context was
// cancelled, because the decoding errors may be due
// to the context being cancelled.
yield(jsonstream.Message{}, err)
return
}
yield(jsonstream.Message{}, err)
return return
} }
if !yield(jm, err) { if !yield(jm, nil) {
return return
} }
} }
} }
} }
// Wait waits for operation to complete and detects errors reported as JSONMessage // Wait consumes the stream until completion.
//
// It returns nil if the operation completes successfully. Errors are
// returned if the context is canceled, a decoding/transport failure
// occurs, or a JSON message reports an error ([jsonstream.Message.Error]).
func (r Stream) Wait(ctx context.Context) error { func (r Stream) Wait(ctx context.Context) error {
for _, err := range r.JSONMessages(ctx) { for jm, err := range r.JSONMessages(ctx) {
if err != nil { if err != nil {
// decode, transport and context cancellation errors.
return err return err
} }
if jm.Error != nil {
// push/pull failures.
return httpErrorFromStatusCode(jm.Error, jm.Error.Code)
}
} }
return nil return nil
} }
type httpError struct {
err error
errdef error
}
func (e *httpError) Error() string {
return e.err.Error()
}
func (e *httpError) Unwrap() error {
return e.err
}
func (e *httpError) Is(target error) bool {
return errors.Is(e.errdef, target)
}
// httpErrorFromStatusCode creates an errdef error, based on the provided HTTP status-code
//
// TODO(thaJeztah): unify with the implementation in client and move to an internal package
// see https://github.com/moby/moby/blob/client/v0.4.0/client/errors.go#L76-L114
func httpErrorFromStatusCode(err error, statusCode int) error {
if err == nil {
return nil
}
return &httpError{
err: err,
errdef: errhttp.ToNative(statusCode),
}
}
+8 -5
View File
@@ -244,12 +244,15 @@ func imageDiskUsageFromLegacyAPI(du *legacyDiskUsage) ImagesDiskUsage {
Items: du.Images, Items: du.Images,
} }
for _, i := range idu.Items { for _, img := range idu.Items {
if i.Containers > 0 { switch {
case img.Containers < 0:
// No container-count information available; skip (assume it's in use).
case img.Containers > 0:
idu.ActiveCount++ idu.ActiveCount++
} else if i.Size != -1 && i.SharedSize != -1 { case img.Containers == 0 && img.Size != -1 && img.SharedSize != -1:
// Only count reclaimable size if we have size information reclaimable := img.Size - img.SharedSize
idu.Reclaimable += (i.Size - i.SharedSize) idu.Reclaimable += reclaimable
} }
} }
+2 -2
View File
@@ -756,7 +756,7 @@ github.com/moby/go-archive/tarheader
# github.com/moby/locker v1.0.1 # github.com/moby/locker v1.0.1
## explicit; go 1.13 ## explicit; go 1.13
github.com/moby/locker github.com/moby/locker
# github.com/moby/moby/api v1.54.1 # github.com/moby/moby/api v1.54.2
## explicit; go 1.24 ## explicit; go 1.24
github.com/moby/moby/api/pkg/authconfig github.com/moby/moby/api/pkg/authconfig
github.com/moby/moby/api/pkg/stdcopy github.com/moby/moby/api/pkg/stdcopy
@@ -777,7 +777,7 @@ github.com/moby/moby/api/types/storage
github.com/moby/moby/api/types/swarm github.com/moby/moby/api/types/swarm
github.com/moby/moby/api/types/system github.com/moby/moby/api/types/system
github.com/moby/moby/api/types/volume github.com/moby/moby/api/types/volume
# github.com/moby/moby/client v0.4.0 # github.com/moby/moby/client v0.4.1
## explicit; go 1.24 ## explicit; go 1.24
github.com/moby/moby/client github.com/moby/moby/client
github.com/moby/moby/client/internal github.com/moby/moby/client/internal