From 2b7416ef345a7f483fad677d42028e62ad2268b0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Mar 2022 10:33:08 +0100 Subject: [PATCH] testutil, integration: use types/registry.AuthConfig Signed-off-by: Sebastiaan van Stijn --- integration/plugin/common/plugin_test.go | 3 ++- integration/system/login_test.go | 8 ++++---- testutil/fixtures/plugin/plugin.go | 11 ++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/integration/plugin/common/plugin_test.go b/integration/plugin/common/plugin_test.go index 37ef0b3374..c67af1532b 100644 --- a/integration/plugin/common/plugin_test.go +++ b/integration/plugin/common/plugin_test.go @@ -17,6 +17,7 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/remotes/docker" "github.com/docker/docker/api/types" + registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/testutil/daemon" "github.com/docker/docker/testutil/fixtures/plugin" @@ -125,7 +126,7 @@ func TestPluginInstall(t *testing.T) { name := "test-" + strings.ToLower(t.Name()) repo := path.Join(registry.DefaultURL, name+":latest") - auth := &types.AuthConfig{ServerAddress: registry.DefaultURL, Username: "testuser", Password: "testpassword"} + auth := ®istrytypes.AuthConfig{ServerAddress: registry.DefaultURL, Username: "testuser", Password: "testpassword"} assert.NilError(t, plugin.CreateInRegistry(ctx, repo, auth)) authEncoded, err := json.Marshal(auth) diff --git a/integration/system/login_test.go b/integration/system/login_test.go index 0cabf00612..a47e593416 100644 --- a/integration/system/login_test.go +++ b/integration/system/login_test.go @@ -5,9 +5,9 @@ import ( "fmt" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/integration/internal/requirement" - "github.com/docker/docker/registry" + registrypkg "github.com/docker/docker/registry" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/skip" @@ -20,12 +20,12 @@ func TestLoginFailsWithBadCredentials(t *testing.T) { defer setupTest(t)() client := testEnv.APIClient() - config := types.AuthConfig{ + config := registry.AuthConfig{ Username: "no-user", Password: "no-password", } _, err := client.RegistryLogin(context.Background(), config) assert.Assert(t, err != nil) assert.Check(t, is.ErrorContains(err, "unauthorized: incorrect username or password")) - assert.Check(t, is.ErrorContains(err, fmt.Sprintf("https://%s/v2/", registry.DefaultRegistryHost))) + assert.Check(t, is.ErrorContains(err, fmt.Sprintf("https://%s/v2/", registrypkg.DefaultRegistryHost))) } diff --git a/testutil/fixtures/plugin/plugin.go b/testutil/fixtures/plugin/plugin.go index 81ebc41b64..62664ffd1a 100644 --- a/testutil/fixtures/plugin/plugin.go +++ b/testutil/fixtures/plugin/plugin.go @@ -10,9 +10,10 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/plugin" - "github.com/docker/docker/registry" + registrypkg "github.com/docker/docker/registry" "github.com/pkg/errors" ) @@ -26,7 +27,7 @@ type CreateOpt func(*Config) type Config struct { *types.PluginConfig binPath string - RegistryConfig registry.ServiceOptions + RegistryConfig registrypkg.ServiceOptions } // WithInsecureRegistry specifies that the given registry can skip host-key checking as well as fall back to plain http @@ -77,7 +78,7 @@ func Create(ctx context.Context, c CreateClient, name string, opts ...CreateOpt) // This can be useful when testing plugins on swarm where you don't really want // the plugin to exist on any of the daemons (immediately) and there needs to be // some way to distribute the plugin. -func CreateInRegistry(ctx context.Context, repo string, auth *types.AuthConfig, opts ...CreateOpt) error { +func CreateInRegistry(ctx context.Context, repo string, auth *registry.AuthConfig, opts ...CreateOpt) error { tmpDir, err := os.MkdirTemp("", "create-test-plugin-local") if err != nil { return err @@ -105,7 +106,7 @@ func CreateInRegistry(ctx context.Context, repo string, auth *types.AuthConfig, return nil, nil } - regService, err := registry.NewService(cfg.RegistryConfig) + regService, err := registrypkg.NewService(cfg.RegistryConfig) if err != nil { return err } @@ -130,7 +131,7 @@ func CreateInRegistry(ctx context.Context, repo string, auth *types.AuthConfig, } if auth == nil { - auth = &types.AuthConfig{} + auth = ®istry.AuthConfig{} } err = manager.Push(ctx, repo, nil, auth, io.Discard) return errors.Wrap(err, "error pushing plugin")