diff --git a/go.mod b/go.mod index 4e22b96cfd..a3cdd67e14 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/containerd/protobuild v0.3.0 github.com/containerd/ttrpc v1.2.3 github.com/containerd/typeurl/v2 v2.1.1 + github.com/docker/docker v24.0.7+incompatible github.com/google/go-cmp v0.6.0 github.com/google/go-containerregistry v0.19.0 github.com/josephspurrier/goversioninfo v1.4.0 @@ -56,7 +57,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/docker/cli v24.0.0+incompatible // indirect github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v24.0.7+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/README.md b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/README.md deleted file mode 100644 index 74fc3a87c0..0000000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# `daemon` - -[![GoDoc](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/daemon?status.svg)](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/daemon) - -The `daemon` package enables reading/writing images from/to the docker daemon. - -It is not fully fleshed out, but is useful for interoperability, see various issues: - -* https://github.com/google/go-containerregistry/issues/205 -* https://github.com/google/go-containerregistry/issues/552 -* https://github.com/google/go-containerregistry/issues/627 diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/doc.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/doc.go deleted file mode 100644 index ac05d96121..0000000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 Google LLC All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package daemon provides facilities for reading/writing v1.Image from/to -// a running daemon. -package daemon diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go deleted file mode 100644 index d2efcb372e..0000000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright 2018 Google LLC All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package daemon - -import ( - "bytes" - "context" - "io" - "sync" - "time" - - api "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - - "github.com/google/go-containerregistry/pkg/name" - v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/google/go-containerregistry/pkg/v1/tarball" - "github.com/google/go-containerregistry/pkg/v1/types" -) - -type image struct { - ref name.Reference - opener *imageOpener - tarballImage v1.Image - computed bool - id *v1.Hash - configFile *v1.ConfigFile - - once sync.Once - err error -} - -type imageOpener struct { - ref name.Reference - ctx context.Context - - buffered bool - client Client - - once sync.Once - bytes []byte - err error -} - -func (i *imageOpener) saveImage() (io.ReadCloser, error) { - return i.client.ImageSave(i.ctx, []string{i.ref.Name()}) -} - -func (i *imageOpener) bufferedOpener() (io.ReadCloser, error) { - // Store the tarball in memory and return a new reader into the bytes each time we need to access something. - i.once.Do(func() { - i.bytes, i.err = func() ([]byte, error) { - rc, err := i.saveImage() - if err != nil { - return nil, err - } - defer rc.Close() - - return io.ReadAll(rc) - }() - }) - - // Wrap the bytes in a ReadCloser so it looks like an opened file. - return io.NopCloser(bytes.NewReader(i.bytes)), i.err -} - -func (i *imageOpener) opener() tarball.Opener { - if i.buffered { - return i.bufferedOpener - } - - // To avoid storing the tarball in memory, do a save every time we need to access something. - return i.saveImage -} - -// Image provides access to an image reference from the Docker daemon, -// applying functional options to the underlying imageOpener before -// resolving the reference into a v1.Image. -func Image(ref name.Reference, options ...Option) (v1.Image, error) { - o, err := makeOptions(options...) - if err != nil { - return nil, err - } - - i := &imageOpener{ - ref: ref, - buffered: o.buffered, - client: o.client, - ctx: o.ctx, - } - - img := &image{ - ref: ref, - opener: i, - } - - // Eagerly fetch Image ID to ensure it actually exists. - // https://github.com/google/go-containerregistry/issues/1186 - id, err := img.ConfigName() - if err != nil { - return nil, err - } - img.id = &id - - return img, nil -} - -func (i *image) initialize() error { - // Don't re-initialize tarball if already initialized. - if i.tarballImage == nil { - i.once.Do(func() { - i.tarballImage, i.err = tarball.Image(i.opener.opener(), nil) - }) - } - return i.err -} - -func (i *image) compute() error { - // Don't re-compute if already computed. - if i.computed { - return nil - } - - inspect, _, err := i.opener.client.ImageInspectWithRaw(i.opener.ctx, i.ref.String()) - if err != nil { - return err - } - - configFile, err := i.computeConfigFile(inspect) - if err != nil { - return err - } - - i.configFile = configFile - i.computed = true - - return nil -} - -func (i *image) Layers() ([]v1.Layer, error) { - if err := i.initialize(); err != nil { - return nil, err - } - return i.tarballImage.Layers() -} - -func (i *image) MediaType() (types.MediaType, error) { - if err := i.initialize(); err != nil { - return "", err - } - return i.tarballImage.MediaType() -} - -func (i *image) Size() (int64, error) { - if err := i.initialize(); err != nil { - return 0, err - } - return i.tarballImage.Size() -} - -func (i *image) ConfigName() (v1.Hash, error) { - if i.id != nil { - return *i.id, nil - } - res, _, err := i.opener.client.ImageInspectWithRaw(i.opener.ctx, i.ref.String()) - if err != nil { - return v1.Hash{}, err - } - return v1.NewHash(res.ID) -} - -func (i *image) ConfigFile() (*v1.ConfigFile, error) { - if err := i.compute(); err != nil { - return nil, err - } - return i.configFile.DeepCopy(), nil -} - -func (i *image) RawConfigFile() ([]byte, error) { - if err := i.initialize(); err != nil { - return nil, err - } - - // RawConfigFile cannot be generated from "docker inspect" because Docker Engine API returns serialized data, - // and formatting information of the raw config such as indent and prefix will be lost. - return i.tarballImage.RawConfigFile() -} - -func (i *image) Digest() (v1.Hash, error) { - if err := i.initialize(); err != nil { - return v1.Hash{}, err - } - return i.tarballImage.Digest() -} - -func (i *image) Manifest() (*v1.Manifest, error) { - if err := i.initialize(); err != nil { - return nil, err - } - return i.tarballImage.Manifest() -} - -func (i *image) RawManifest() ([]byte, error) { - if err := i.initialize(); err != nil { - return nil, err - } - return i.tarballImage.RawManifest() -} - -func (i *image) LayerByDigest(h v1.Hash) (v1.Layer, error) { - if err := i.initialize(); err != nil { - return nil, err - } - return i.tarballImage.LayerByDigest(h) -} - -func (i *image) LayerByDiffID(h v1.Hash) (v1.Layer, error) { - if err := i.initialize(); err != nil { - return nil, err - } - return i.tarballImage.LayerByDiffID(h) -} - -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 - } - - history := make([]v1.History, len(historyItems)) - for j, h := range historyItems { - history[j] = v1.History{ - Author: author, - Created: v1.Time{ - Time: time.Unix(h.Created, 0).UTC(), - }, - CreatedBy: h.CreatedBy, - Comment: h.Comment, - EmptyLayer: h.Size == 0, - } - } - return history, nil -} - -func (i *image) diffIDs(rootFS api.RootFS) ([]v1.Hash, error) { - diffIDs := make([]v1.Hash, len(rootFS.Layers)) - for j, l := range rootFS.Layers { - h, err := v1.NewHash(l) - if err != nil { - return nil, err - } - diffIDs[j] = h - } - return diffIDs, nil -} - -func (i *image) computeConfigFile(inspect api.ImageInspect) (*v1.ConfigFile, error) { - diffIDs, err := i.diffIDs(inspect.RootFS) - if err != nil { - return nil, err - } - - history, err := i.configHistory(inspect.Author) - if err != nil { - return nil, err - } - - created, err := time.Parse(time.RFC3339Nano, inspect.Created) - if err != nil { - return nil, err - } - - return &v1.ConfigFile{ - Architecture: inspect.Architecture, - Author: inspect.Author, - Container: inspect.Container, - Created: v1.Time{Time: created}, - DockerVersion: inspect.DockerVersion, - History: history, - OS: inspect.Os, - RootFS: v1.RootFS{ - Type: inspect.RootFS.Type, - DiffIDs: diffIDs, - }, - Config: i.computeImageConfig(inspect.Config), - OSVersion: inspect.OsVersion, - }, nil -} - -func (i *image) computeImageConfig(config *container.Config) v1.Config { - if config == nil { - return v1.Config{} - } - - c := v1.Config{ - AttachStderr: config.AttachStderr, - AttachStdin: config.AttachStdin, - AttachStdout: config.AttachStdout, - Cmd: config.Cmd, - Domainname: config.Domainname, - Entrypoint: config.Entrypoint, - Env: config.Env, - Hostname: config.Hostname, - Image: config.Image, - Labels: config.Labels, - OnBuild: config.OnBuild, - OpenStdin: config.OpenStdin, - StdinOnce: config.StdinOnce, - Tty: config.Tty, - User: config.User, - Volumes: config.Volumes, - WorkingDir: config.WorkingDir, - ArgsEscaped: config.ArgsEscaped, - NetworkDisabled: config.NetworkDisabled, - MacAddress: config.MacAddress, - StopSignal: config.StopSignal, - Shell: config.Shell, - } - - if config.Healthcheck != nil { - c.Healthcheck = &v1.HealthConfig{ - Test: config.Healthcheck.Test, - Interval: config.Healthcheck.Interval, - Timeout: config.Healthcheck.Timeout, - StartPeriod: config.Healthcheck.StartPeriod, - Retries: config.Healthcheck.Retries, - } - } - - if len(config.ExposedPorts) > 0 { - c.ExposedPorts = map[string]struct{}{} - for port := range c.ExposedPorts { - c.ExposedPorts[port] = struct{}{} - } - } - - return c -} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go deleted file mode 100644 index b806463697..0000000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2018 Google LLC All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package daemon - -import ( - "context" - "io" - - "github.com/docker/docker/api/types" - api "github.com/docker/docker/api/types/image" - "github.com/docker/docker/client" -) - -// ImageOption is an alias for Option. -// Deprecated: Use Option instead. -type ImageOption Option - -// Option is a functional option for daemon operations. -type Option func(*options) - -type options struct { - ctx context.Context - client Client - buffered bool -} - -var defaultClient = func() (Client, error) { - return client.NewClientWithOpts(client.FromEnv) -} - -func makeOptions(opts ...Option) (*options, error) { - o := &options{ - buffered: true, - ctx: context.Background(), - } - for _, opt := range opts { - opt(o) - } - - if o.client == nil { - client, err := defaultClient() - if err != nil { - return nil, err - } - o.client = client - } - o.client.NegotiateAPIVersion(o.ctx) - - return o, nil -} - -// WithBufferedOpener buffers the image. -func WithBufferedOpener() Option { - return func(o *options) { - o.buffered = true - } -} - -// WithUnbufferedOpener streams the image to avoid buffering. -func WithUnbufferedOpener() Option { - return func(o *options) { - o.buffered = false - } -} - -// WithClient is a functional option to allow injecting a docker client. -// -// By default, github.com/docker/docker/client.FromEnv is used. -func WithClient(client Client) Option { - return func(o *options) { - o.client = client - } -} - -// WithContext is a functional option to pass through a context.Context. -// -// By default, context.Background() is used. -func WithContext(ctx context.Context) Option { - return func(o *options) { - o.ctx = ctx - } -} - -// Client represents the subset of a docker client that the daemon -// package uses. -type Client interface { - NegotiateAPIVersion(ctx context.Context) - ImageSave(context.Context, []string) (io.ReadCloser, error) - ImageLoad(context.Context, io.Reader, bool) (types.ImageLoadResponse, error) - ImageTag(context.Context, string, string) error - ImageInspectWithRaw(context.Context, string) (types.ImageInspect, []byte, error) - ImageHistory(context.Context, string) ([]api.HistoryResponseItem, error) -} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go deleted file mode 100644 index 3ca5b52dd2..0000000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2018 Google LLC All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package daemon - -import ( - "fmt" - "io" - - "github.com/google/go-containerregistry/pkg/name" - v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/google/go-containerregistry/pkg/v1/tarball" -) - -// Tag adds a tag to an already existent image. -func Tag(src, dest name.Tag, options ...Option) error { - o, err := makeOptions(options...) - if err != nil { - return err - } - - return o.client.ImageTag(o.ctx, src.String(), dest.String()) -} - -// Write saves the image into the daemon as the given tag. -func Write(tag name.Tag, img v1.Image, options ...Option) (string, error) { - o, err := makeOptions(options...) - if err != nil { - return "", err - } - - // If we already have this image by this image ID, we can skip loading it. - id, err := img.ConfigName() - if err != nil { - return "", fmt.Errorf("computing image ID: %w", err) - } - if resp, _, err := o.client.ImageInspectWithRaw(o.ctx, id.String()); err == nil { - want := tag.String() - - // If we already have this tag, we can skip tagging it. - for _, have := range resp.RepoTags { - if have == want { - return "", nil - } - } - - return "", o.client.ImageTag(o.ctx, id.String(), want) - } - - pr, pw := io.Pipe() - go func() { - pw.CloseWithError(tarball.Write(tag, img, pw)) - }() - - // write the image in docker save format first, then load it - resp, err := o.client.ImageLoad(o.ctx, pr, false) - if err != nil { - return "", fmt.Errorf("error loading image: %w", err) - } - defer resp.Body.Close() - b, err := io.ReadAll(resp.Body) - response := string(b) - if err != nil { - return response, fmt.Errorf("error reading load response body: %w", err) - } - return response, nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 7bed2b17a5..bd3fba6943 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -241,7 +241,6 @@ github.com/google/go-containerregistry/pkg/compression github.com/google/go-containerregistry/pkg/logs github.com/google/go-containerregistry/pkg/name github.com/google/go-containerregistry/pkg/v1 -github.com/google/go-containerregistry/pkg/v1/daemon github.com/google/go-containerregistry/pkg/v1/empty github.com/google/go-containerregistry/pkg/v1/match github.com/google/go-containerregistry/pkg/v1/mutate