diff --git a/buf.lock b/buf.lock index e7928fd11..e761619a5 100644 --- a/buf.lock +++ b/buf.lock @@ -4,4 +4,4 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 7e6f6e774e29406da95bd61cdcdbc8bc + commit: ee48893a270147348e3edc6c1a03de0e diff --git a/cmd/tink-worker/worker/registry.go b/cmd/tink-worker/worker/registry.go index 0eda49a44..144d3714f 100644 --- a/cmd/tink-worker/worker/registry.go +++ b/cmd/tink-worker/worker/registry.go @@ -7,7 +7,7 @@ import ( "io" "path" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/pkg/errors" ) @@ -31,7 +31,7 @@ type ImagePullStatus struct { } // PullImage outputs to stdout the contents of the requested image (relative to the registry). -func (m *containerManager) PullImage(ctx context.Context, image string) error { +func (m *containerManager) PullImage(ctx context.Context, img string) error { l := m.getLogger(ctx) authConfig := registry.AuthConfig{ Username: m.registryDetails.Username, @@ -44,7 +44,7 @@ func (m *containerManager) PullImage(ctx context.Context, image string) error { } authStr := base64.URLEncoding.EncodeToString(encodedJSON) - out, err := m.cli.ImagePull(ctx, path.Join(m.registryDetails.Registry, image), types.ImagePullOptions{RegistryAuth: authStr}) + out, err := m.cli.ImagePull(ctx, path.Join(m.registryDetails.Registry, img), image.PullOptions{RegistryAuth: authStr}) if err != nil { return errors.Wrap(err, "DOCKER PULL") } diff --git a/cmd/tink-worker/worker/registry_test.go b/cmd/tink-worker/worker/registry_test.go index 1ce8a3f92..fcc5a40ad 100644 --- a/cmd/tink-worker/worker/registry_test.go +++ b/cmd/tink-worker/worker/registry_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/go-logr/zapr" "go.uber.org/zap" ) -func (c *fakeDockerClient) ImagePull(context.Context, string, types.ImagePullOptions) (io.ReadCloser, error) { +func (c *fakeDockerClient) ImagePull(context.Context, string, image.PullOptions) (io.ReadCloser, error) { if c.err != nil { return nil, c.err } diff --git a/go.mod b/go.mod index 54b9fec48..7acf126b1 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.21.4 require ( github.com/avast/retry-go v3.0.0+incompatible github.com/distribution/reference v0.5.0 - github.com/docker/docker v25.0.5+incompatible + github.com/docker/docker v26.0.0+incompatible github.com/equinix-labs/otel-init-go v0.0.9 github.com/go-logr/logr v1.4.1 github.com/go-logr/zapr v1.3.0 @@ -75,6 +75,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect diff --git a/go.sum b/go.sum index 37267b96d..df78ae8be 100644 --- a/go.sum +++ b/go.sum @@ -323,8 +323,8 @@ github.com/dgryski/go-lttb v0.0.0-20180810165845-318fcdf10a77/go.mod h1:Va5MyIzk github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= -github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v26.0.0+incompatible h1:Ng2qi+gdKADUa/VM+6b6YaY2nlZhk/lVJiKR/2bMudU= +github.com/docker/docker v26.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -635,6 +635,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= diff --git a/internal/agent/runtime/docker.go b/internal/agent/runtime/docker.go index 74e87f403..20473b941 100644 --- a/internal/agent/runtime/docker.go +++ b/internal/agent/runtime/docker.go @@ -7,8 +7,8 @@ import ( "regexp" retry "github.com/avast/retry-go" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/client" "github.com/go-logr/logr" @@ -31,15 +31,15 @@ type Docker struct { func (d *Docker) Run(ctx context.Context, a workflow.Action) error { pullImage := func() error { // We need the image to be available before we can create a container. - image, err := d.client.ImagePull(ctx, a.Image, types.ImagePullOptions{}) + img, err := d.client.ImagePull(ctx, a.Image, image.PullOptions{}) if err != nil { return fmt.Errorf("docker: %w", err) } - defer image.Close() + defer img.Close() // Docker requires everything to be read from the images ReadCloser for the image to actually // be pulled. We may want to log image pulls in a circular buffer somewhere for debugability. - if _, err = io.Copy(io.Discard, image); err != nil { + if _, err = io.Copy(io.Discard, img); err != nil { return fmt.Errorf("docker: %w", err) } diff --git a/internal/agent/runtime/docker_test.go b/internal/agent/runtime/docker_test.go index 3a38ae7e9..0b43182f0 100644 --- a/internal/agent/runtime/docker_test.go +++ b/internal/agent/runtime/docker_test.go @@ -16,8 +16,8 @@ import ( "github.com/tinkerbell/tink/internal/agent/workflow" "go.uber.org/multierr" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" ) @@ -27,20 +27,20 @@ func TestDockerImageNotPresent(t *testing.T) { t.Fatalf("Received unexpected error: %v", err) } - image := "hello-world" + img := "hello-world" - images, err := clnt.ImageList(context.Background(), types.ImageListOptions{ - Filters: filters.NewArgs(filters.Arg("reference", image)), + images, err := clnt.ImageList(context.Background(), image.ListOptions{ + Filters: filters.NewArgs(filters.Arg("reference", img)), }) if err != nil { t.Fatalf("Unexpected error listing images: %v", err) } var errSum error - for _, image := range images { - _, err := clnt.ImageRemove(context.Background(), image.ID, types.ImageRemoveOptions{}) + for _, img := range images { + _, err := clnt.ImageRemove(context.Background(), img.ID, image.RemoveOptions{}) if err != nil { - errSum = multierr.Append(errSum, fmt.Errorf("deleting image (%v): %v", image.ID, err)) + errSum = multierr.Append(errSum, fmt.Errorf("deleting image (%v): %v", img.ID, err)) } } if errSum != nil { @@ -55,7 +55,7 @@ func TestDockerImageNotPresent(t *testing.T) { action := workflow.Action{ ID: "foobar", - Image: image, + Image: img, } err = rt.Run(context.Background(), action)