Skip to content

Commit 6bcc9ce

Browse files
authored
Merge pull request docker#6174 from Benehiko/remove-prompt-privilege-func
cli/command: remove interactive login prompt from docker push/pull
2 parents 46b8679 + 2b56b66 commit 6bcc9ce

File tree

6 files changed

+8
-31
lines changed

6 files changed

+8
-31
lines changed

cli/command/image/push.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ Image index won't be pushed, meaning that other manifests, including attestation
7474
}
7575

7676
// runPush performs a push against the engine based on the specified options.
77-
//
78-
//nolint:gocyclo // ignore cyclomatic complexity 17 of func `runPush` is high (> 16) for now.
7977
func runPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error {
8078
var platform *ocispec.Platform
8179
out := tui.NewOutput(dockerCli.Out())
@@ -115,14 +113,10 @@ To push the complete multi-platform image, remove the --platform flag.
115113
if err != nil {
116114
return err
117115
}
118-
var requestPrivilege registrytypes.RequestAuthConfig
119-
if dockerCli.In().IsTerminal() {
120-
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, "push")
121-
}
122116
options := image.PushOptions{
123117
All: opts.all,
124118
RegistryAuth: encodedAuth,
125-
PrivilegeFunc: requestPrivilege,
119+
PrivilegeFunc: nil,
126120
Platform: platform,
127121
}
128122

cli/command/image/trust.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,9 @@ func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth tru
149149
if err != nil {
150150
return err
151151
}
152-
var requestPrivilege registrytypes.RequestAuthConfig
153-
if cli.In().IsTerminal() {
154-
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(cli, imgRefAndAuth.RepoInfo().Index, "pull")
155-
}
156152
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), image.PullOptions{
157153
RegistryAuth: encodedAuth,
158-
PrivilegeFunc: requestPrivilege,
154+
PrivilegeFunc: nil,
159155
All: opts.all,
160156
Platform: opts.platform,
161157
})

cli/command/plugin/install.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func newInstallCommand(dockerCli command.Cli) *cobra.Command {
5656
return cmd
5757
}
5858

59-
func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOptions, cmdName string) (types.PluginInstallOptions, error) {
59+
func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOptions) (types.PluginInstallOptions, error) {
6060
// Names with both tag and digest will be treated by the daemon
6161
// as a pull by digest with a local name for the tag
6262
// (if no local name is provided).
@@ -90,18 +90,13 @@ func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOpti
9090
return types.PluginInstallOptions{}, err
9191
}
9292

93-
var requestPrivilege registrytypes.RequestAuthConfig
94-
if dockerCli.In().IsTerminal() {
95-
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, cmdName)
96-
}
97-
9893
options := types.PluginInstallOptions{
9994
RegistryAuth: encodedAuth,
10095
RemoteRef: remote,
10196
Disabled: opts.disable,
10297
AcceptAllPermissions: opts.grantPerms,
10398
AcceptPermissionsFunc: acceptPrivileges(dockerCli, opts.remote),
104-
PrivilegeFunc: requestPrivilege,
99+
PrivilegeFunc: nil,
105100
Args: opts.args,
106101
}
107102
return options, nil
@@ -120,7 +115,7 @@ func runInstall(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
120115
localName = reference.FamiliarString(reference.TagNameOnly(aref))
121116
}
122117

123-
options, err := buildPullConfig(ctx, dockerCLI, opts, "plugin install")
118+
options, err := buildPullConfig(ctx, dockerCLI, opts)
124119
if err != nil {
125120
return err
126121
}

cli/command/plugin/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func runUpgrade(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
7373
}
7474
}
7575

76-
options, err := buildPullConfig(ctx, dockerCLI, opts, "plugin upgrade")
76+
options, err := buildPullConfig(ctx, dockerCLI, opts)
7777
if err != nil {
7878
return err
7979
}

cli/command/registry/search.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,9 @@ func runSearch(ctx context.Context, dockerCli command.Cli, options searchOptions
6363
return err
6464
}
6565

66-
var requestPrivilege registrytypes.RequestAuthConfig
67-
if dockerCli.In().IsTerminal() {
68-
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, indexInfo, "search")
69-
}
7066
results, err := dockerCli.Client().ImageSearch(ctx, options.term, registrytypes.SearchOptions{
7167
RegistryAuth: encodedAuth,
72-
PrivilegeFunc: requestPrivilege,
68+
PrivilegeFunc: nil,
7369
Filters: options.filter.Value(),
7470
Limit: options.limit,
7571
})

cli/command/trust/sign.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
8282
return trust.NotaryError(imgRefAndAuth.RepoInfo().Name.Name(), err)
8383
}
8484
}
85-
var requestPrivilege registrytypes.RequestAuthConfig
86-
if dockerCLI.In().IsTerminal() {
87-
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCLI, imgRefAndAuth.RepoInfo().Index, "push")
88-
}
8985
target, err := createTarget(notaryRepo, imgRefAndAuth.Tag())
9086
if err != nil || options.local {
9187
switch err := err.(type) {
@@ -104,7 +100,7 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
104100
}
105101
responseBody, err := dockerCLI.Client().ImagePush(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), imagetypes.PushOptions{
106102
RegistryAuth: encodedAuth,
107-
PrivilegeFunc: requestPrivilege,
103+
PrivilegeFunc: nil,
108104
})
109105
if err != nil {
110106
return err

0 commit comments

Comments
 (0)