From f249714bfe489e2bbb892ca6ac45c37c715cb60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Va=C5=A1ek?= Date: Thu, 20 Jun 2024 08:07:17 +0200 Subject: [PATCH] chore: removed deprecated types (#2378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej VaĊĦek --- hack/update-builder.go | 10 +++++----- pkg/docker/pusher.go | 6 +++--- pkg/docker/pusher_test.go | 10 +++++----- pkg/docker/zz_close_guarding_client_generated.go | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/hack/update-builder.go b/hack/update-builder.go index 9ffae63a2e..7b7892d738 100644 --- a/hack/update-builder.go +++ b/hack/update-builder.go @@ -24,8 +24,8 @@ import ( "github.com/buildpacks/pack/buildpackage" pack "github.com/buildpacks/pack/pkg/client" "github.com/buildpacks/pack/pkg/dist" - "github.com/buildpacks/pack/pkg/image" - "github.com/docker/docker/api/types" + bpimage "github.com/buildpacks/pack/pkg/image" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" docker "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" @@ -138,7 +138,7 @@ func buildBuilderImage(ctx context.Context, variant string) error { BuilderName: newBuilderImageTagged, Config: builderConfig, Publish: false, - PullPolicy: image.PullIfNotPresent, + PullPolicy: bpimage.PullIfNotPresent, Labels: map[string]string{ "org.opencontainers.image.description": "Paketo Jammy builder enriched with Rust and Func-Go buildpacks.", "org.opencontainers.image.source": "https://github.com/knative/func", @@ -170,7 +170,7 @@ func buildBuilderImage(ctx context.Context, variant string) error { if err != nil { return fmt.Errorf("cannot marshal credentials: %w", err) } - imagePushOptions := types.ImagePushOptions{ + imagePushOptions := image.PushOptions{ All: false, RegistryAuth: base64.StdEncoding.EncodeToString(bs), } @@ -326,7 +326,7 @@ func buildBuildpackImage(ctx context.Context, bp buildpack) error { Format: pack.FormatImage, Config: cfg, Publish: false, - PullPolicy: image.PullIfNotPresent, + PullPolicy: bpimage.PullIfNotPresent, Registry: "", Flatten: false, FlattenExclude: nil, diff --git a/pkg/docker/pusher.go b/pkg/docker/pusher.go index 0fb26a3dcf..bdc7b3fbb3 100644 --- a/pkg/docker/pusher.go +++ b/pkg/docker/pusher.go @@ -15,7 +15,7 @@ import ( fn "knative.dev/func/pkg/functions" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" @@ -43,7 +43,7 @@ type CredentialsProvider func(ctx context.Context, image string) (Credentials, e // PusherDockerClient is sub-interface of client.CommonAPIClient required by pusher. type PusherDockerClient interface { daemon.Client - ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) + ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error) Close() error } @@ -225,7 +225,7 @@ func (n *Pusher) daemonPush(ctx context.Context, f fn.Function, credentials Cred return "", err } - opts := types.ImagePushOptions{RegistryAuth: base64.StdEncoding.EncodeToString(b)} + opts := image.PushOptions{RegistryAuth: base64.StdEncoding.EncodeToString(b)} r, err := cli.ImagePush(ctx, f.Build.Image, opts) if err != nil { diff --git a/pkg/docker/pusher_test.go b/pkg/docker/pusher_test.go index 48bd5b5e25..7be54d90d7 100644 --- a/pkg/docker/pusher_test.go +++ b/pkg/docker/pusher_test.go @@ -115,7 +115,7 @@ func TestPush(t *testing.T) { dockerClient := newMockPusherDockerClient() - pushReachable := func(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { + pushReachable := func(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error) { if ref != functionImageRemote { return nil, fmt.Errorf("unexpected ref") } @@ -168,7 +168,7 @@ func TestPush(t *testing.T) { `)), nil } - pushUnreachable := func(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { + pushUnreachable := func(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error) { return io.NopCloser(strings.NewReader(`{"errorDetail": {"message": "...no such host..."}}`)), nil } @@ -270,7 +270,7 @@ func TestPush(t *testing.T) { func newMockPusherDockerClient() *mockPusherDockerClient { return &mockPusherDockerClient{ - imagePush: func(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { + imagePush: func(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error) { return nil, fmt.Errorf(" imagePush not implemented") }, imageSave: func(ctx context.Context, strings []string) (io.ReadCloser, error) { @@ -286,7 +286,7 @@ func newMockPusherDockerClient() *mockPusherDockerClient { type mockPusherDockerClient struct { negotiateAPIVersion func(ctx context.Context) - imagePush func(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) + imagePush func(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error) imageSave func(ctx context.Context, strings []string) (io.ReadCloser, error) imageInspect func(ctx context.Context, s string) (types.ImageInspect, []byte, error) close func() error @@ -312,7 +312,7 @@ func (m *mockPusherDockerClient) ImageInspectWithRaw(ctx context.Context, s stri return m.imageInspect(ctx, s) } -func (m *mockPusherDockerClient) ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { +func (m *mockPusherDockerClient) ImagePush(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error) { return m.imagePush(ctx, ref, options) } diff --git a/pkg/docker/zz_close_guarding_client_generated.go b/pkg/docker/zz_close_guarding_client_generated.go index f50eda94bf..49fa9dc7fb 100644 --- a/pkg/docker/zz_close_guarding_client_generated.go +++ b/pkg/docker/zz_close_guarding_client_generated.go @@ -451,7 +451,7 @@ func (c *closeGuardingClient) ImageBuild(arg0 context.Context, arg1 io.Reader, a return c.pimpl.ImageBuild(arg0, arg1, arg2) } -func (c *closeGuardingClient) ImageCreate(arg0 context.Context, arg1 string, arg2 types.ImageCreateOptions) (io.ReadCloser, error) { +func (c *closeGuardingClient) ImageCreate(arg0 context.Context, arg1 string, arg2 image.CreateOptions) (io.ReadCloser, error) { c.m.RLock() defer c.m.RUnlock() if c.closed { @@ -469,7 +469,7 @@ func (c *closeGuardingClient) ImageHistory(arg0 context.Context, arg1 string) ([ return c.pimpl.ImageHistory(arg0, arg1) } -func (c *closeGuardingClient) ImageImport(arg0 context.Context, arg1 types.ImageImportSource, arg2 string, arg3 types.ImageImportOptions) (io.ReadCloser, error) { +func (c *closeGuardingClient) ImageImport(arg0 context.Context, arg1 types.ImageImportSource, arg2 string, arg3 image.ImportOptions) (io.ReadCloser, error) { c.m.RLock() defer c.m.RUnlock() if c.closed { @@ -487,7 +487,7 @@ func (c *closeGuardingClient) ImageInspectWithRaw(arg0 context.Context, arg1 str return c.pimpl.ImageInspectWithRaw(arg0, arg1) } -func (c *closeGuardingClient) ImageList(arg0 context.Context, arg1 types.ImageListOptions) ([]image.Summary, error) { +func (c *closeGuardingClient) ImageList(arg0 context.Context, arg1 image.ListOptions) ([]image.Summary, error) { c.m.RLock() defer c.m.RUnlock() if c.closed { @@ -505,7 +505,7 @@ func (c *closeGuardingClient) ImageLoad(arg0 context.Context, arg1 io.Reader, ar return c.pimpl.ImageLoad(arg0, arg1, arg2) } -func (c *closeGuardingClient) ImagePull(arg0 context.Context, arg1 string, arg2 types.ImagePullOptions) (io.ReadCloser, error) { +func (c *closeGuardingClient) ImagePull(arg0 context.Context, arg1 string, arg2 image.PullOptions) (io.ReadCloser, error) { c.m.RLock() defer c.m.RUnlock() if c.closed { @@ -514,7 +514,7 @@ func (c *closeGuardingClient) ImagePull(arg0 context.Context, arg1 string, arg2 return c.pimpl.ImagePull(arg0, arg1, arg2) } -func (c *closeGuardingClient) ImagePush(arg0 context.Context, arg1 string, arg2 types.ImagePushOptions) (io.ReadCloser, error) { +func (c *closeGuardingClient) ImagePush(arg0 context.Context, arg1 string, arg2 image.PushOptions) (io.ReadCloser, error) { c.m.RLock() defer c.m.RUnlock() if c.closed { @@ -523,7 +523,7 @@ func (c *closeGuardingClient) ImagePush(arg0 context.Context, arg1 string, arg2 return c.pimpl.ImagePush(arg0, arg1, arg2) } -func (c *closeGuardingClient) ImageRemove(arg0 context.Context, arg1 string, arg2 types.ImageRemoveOptions) ([]image.DeleteResponse, error) { +func (c *closeGuardingClient) ImageRemove(arg0 context.Context, arg1 string, arg2 image.RemoveOptions) ([]image.DeleteResponse, error) { c.m.RLock() defer c.m.RUnlock() if c.closed {