Skip to content

Commit f2c8b9d

Browse files
committed
cli/command/plugin: simplify auth
Now that 3f5b1bd removed DCT, which needed some of the intermediate types (indexInfo), we can simplify the auth code further and just get the base64-encoded AuthConfig to be set as header. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent cfd7e54 commit f2c8b9d

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

cli/command/plugin/install.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import (
1010
"github.com/docker/cli/cli/command"
1111
"github.com/docker/cli/internal/jsonstream"
1212
"github.com/docker/cli/internal/prompt"
13-
"github.com/docker/cli/internal/registry"
1413
"github.com/moby/moby/api/types/plugin"
15-
registrytypes "github.com/moby/moby/api/types/registry"
1614
"github.com/moby/moby/client"
1715
"github.com/pkg/errors"
1816
"github.com/spf13/cobra"
@@ -60,8 +58,7 @@ func buildPullConfig(dockerCLI command.Cli, opts pluginOptions) (client.PluginIn
6058
return client.PluginInstallOptions{}, err
6159
}
6260

63-
authConfig := command.ResolveAuthConfig(dockerCLI.ConfigFile(), registry.NewIndexInfo(ref))
64-
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
61+
encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), ref.String())
6562
if err != nil {
6663
return client.PluginInstallOptions{}, err
6764
}

cli/command/plugin/push.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/internal/jsonstream"
11-
"github.com/docker/cli/internal/registry"
12-
registrytypes "github.com/moby/moby/api/types/registry"
1311
"github.com/spf13/cobra"
1412
)
1513

@@ -40,8 +38,7 @@ func runPush(ctx context.Context, dockerCli command.Cli, name string) error {
4038
}
4139

4240
named = reference.TagNameOnly(named)
43-
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), registry.NewIndexInfo(named))
44-
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
41+
encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCli.ConfigFile(), named.String())
4542
if err != nil {
4643
return err
4744
}

0 commit comments

Comments
 (0)