Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
cli/command: remove interactive login prompt from docker push/pull#6174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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()) | ||
| @@ -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") | ||
| } | ||
| options := image.PushOptions{ | ||
| All: opts.all, | ||
| RegistryAuth: encodedAuth, | ||
| PrivilegeFunc: requestPrivilege, | ||
| PrivilegeFunc: nil, | ||
Benehiko marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Platform: platform, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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, | ||
Benehiko marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| All: opts.all, | ||
| Platform: opts.platform, | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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). | ||
| @@ -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, | ||
Benehiko marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Args: opts.args, | ||
| } | ||
| return options, nil | ||
| @@ -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 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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, | ||
Benehiko marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Filters: options.filter.Value(), | ||
| Limit: options.limit, | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) { | ||
| @@ -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, | ||
Benehiko marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }) | ||
| if err != nil { | ||
| return err | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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;
docker push/docker pullno longer triggers an interactive login prompt)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).
There was a problem hiding this comment.
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