Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cli/command/image/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ Image index won't be pushed, meaning that other manifests, including attestation
}

// runPush performs a push against the engine based on the specified options.
//
//nolint:gocyclo // ignore cyclomatic complexity 17 of func `runPush` is high (> 16) for now.
func runPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error {
var platform *ocispec.Platform
out := tui.NewOutput(dockerCli.Out())
Expand Down Expand Up @@ -115,14 +113,10 @@ To push the complete multi-platform image, remove the --platform flag.
if err != nil {
return err
}
var requestPrivilege registrytypes.RequestAuthConfig
if dockerCli.In().IsTerminal() {
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, "push")
}
Comment on lines -118 to -121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have time; perhaps cleaner would be to;

  • Put these changes in a separate commit / PR (change-log would be about docker push / docker pull no longer triggers an interactive login prompt)
  • The "deprecation" in a separate commit/PR (change-log would be relevant for users of the go module, not impacting end-users)

Separate commits, but same PR is probably fine, but would be good to update the PR title (and change-log to have separate items for each, because different audience).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow-up PR to deprecate #6184

options := image.PushOptions{
All: opts.all,
RegistryAuth: encodedAuth,
PrivilegeFunc: requestPrivilege,
PrivilegeFunc: nil,
Platform: platform,
}

Expand Down
6 changes: 1 addition & 5 deletions cli/command/image/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,9 @@ func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth tru
if err != nil {
return err
}
var requestPrivilege registrytypes.RequestAuthConfig
if cli.In().IsTerminal() {
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(cli, imgRefAndAuth.RepoInfo().Index, "pull")
}
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), image.PullOptions{
RegistryAuth: encodedAuth,
PrivilegeFunc: requestPrivilege,
PrivilegeFunc: nil,
All: opts.all,
Platform: opts.platform,
})
Expand Down
11 changes: 3 additions & 8 deletions cli/command/plugin/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func newInstallCommand(dockerCli command.Cli) *cobra.Command {
return cmd
}

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

var requestPrivilege registrytypes.RequestAuthConfig
if dockerCli.In().IsTerminal() {
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, cmdName)
}

options := types.PluginInstallOptions{
RegistryAuth: encodedAuth,
RemoteRef: remote,
Disabled: opts.disable,
AcceptAllPermissions: opts.grantPerms,
AcceptPermissionsFunc: acceptPrivileges(dockerCli, opts.remote),
PrivilegeFunc: requestPrivilege,
PrivilegeFunc: nil,
Args: opts.args,
}
return options, nil
Expand All @@ -120,7 +115,7 @@ func runInstall(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
localName = reference.FamiliarString(reference.TagNameOnly(aref))
}

options, err := buildPullConfig(ctx, dockerCLI, opts, "plugin install")
options, err := buildPullConfig(ctx, dockerCLI, opts)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/plugin/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func runUpgrade(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
}
}

options, err := buildPullConfig(ctx, dockerCLI, opts, "plugin upgrade")
options, err := buildPullConfig(ctx, dockerCLI, opts)
if err != nil {
return err
}
Expand Down
6 changes: 1 addition & 5 deletions cli/command/registry/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,9 @@ func runSearch(ctx context.Context, dockerCli command.Cli, options searchOptions
return err
}

var requestPrivilege registrytypes.RequestAuthConfig
if dockerCli.In().IsTerminal() {
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, indexInfo, "search")
}
results, err := dockerCli.Client().ImageSearch(ctx, options.term, registrytypes.SearchOptions{
RegistryAuth: encodedAuth,
PrivilegeFunc: requestPrivilege,
PrivilegeFunc: nil,
Filters: options.filter.Value(),
Limit: options.limit,
})
Expand Down
6 changes: 1 addition & 5 deletions cli/command/trust/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
return trust.NotaryError(imgRefAndAuth.RepoInfo().Name.Name(), err)
}
}
var requestPrivilege registrytypes.RequestAuthConfig
if dockerCLI.In().IsTerminal() {
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCLI, imgRefAndAuth.RepoInfo().Index, "push")
}
target, err := createTarget(notaryRepo, imgRefAndAuth.Tag())
if err != nil || options.local {
switch err := err.(type) {
Expand All @@ -104,7 +100,7 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
}
responseBody, err := dockerCLI.Client().ImagePush(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), imagetypes.PushOptions{
RegistryAuth: encodedAuth,
PrivilegeFunc: requestPrivilege,
PrivilegeFunc: nil,
})
if err != nil {
return err
Expand Down
Loading