diff --git a/pkg/v1/daemon/image.go b/pkg/v1/daemon/image.go index 94025e831..98c749ac3 100644 --- a/pkg/v1/daemon/image.go +++ b/pkg/v1/daemon/image.go @@ -17,6 +17,7 @@ package daemon import ( "bytes" "context" + "fmt" "io" "sync" "time" @@ -234,9 +235,20 @@ func (i *image) LayerByDiffID(h v1.Hash) (v1.Layer, error) { } func (i *image) configHistory(author string) ([]v1.History, error) { - historyItems, err := i.opener.client.ImageHistory(i.opener.ctx, i.ref.String()) - if err != nil { - return nil, err + var historyItems []api.HistoryResponseItem + var err error + if pre28, ok := i.opener.client.(clientPre28); ok { + historyItems, err = pre28.ImageHistory(i.opener.ctx, i.ref.String()) + if err != nil { + return nil, err + } + } else if post28, ok := i.opener.client.(clientPost28); ok { + historyItems, err = post28.ImageHistory(i.opener.ctx, i.ref.String()) + if err != nil { + return nil, err + } + } else { + return nil, fmt.Errorf("client does not implement ImageHistory: %T", i.opener.client) } history := make([]v1.History, len(historyItems)) diff --git a/pkg/v1/daemon/options.go b/pkg/v1/daemon/options.go index ce6cfab20..5b3b82433 100644 --- a/pkg/v1/daemon/options.go +++ b/pkg/v1/daemon/options.go @@ -100,5 +100,17 @@ type Client interface { ImageLoad(context.Context, io.Reader, ...client.ImageLoadOption) (api.LoadResponse, error) ImageTag(context.Context, string, string) error ImageInspectWithRaw(context.Context, string) (api.InspectResponse, []byte, error) +} + +// https://github.com/google/go-containerregistry/issues/2072 +// Docker v28.0 changed the API signature for ImageHistory, in ways that broke callers dependent on the old signature. +// This is a temporary workaround to allow the daemon package to work with both pre- and post-28.0 clients. +// After some time, we can remove this workaround and require a post-28.0 client with the variadic args. + +type clientPre28 interface { + ImageHistory(context.Context, string) ([]api.HistoryResponseItem, error) +} + +type clientPost28 interface { ImageHistory(context.Context, string, ...client.ImageHistoryOption) ([]api.HistoryResponseItem, error) }