Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Context Support for Native Store #67

Closed
shizhMSFT opened this issue May 17, 2023 · 2 comments · Fixed by #68
Closed

Context Support for Native Store #67

shizhMSFT opened this issue May 17, 2023 · 2 comments · Fixed by #68
Assignees
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request

Comments

@shizhMSFT
Copy link
Contributor

shizhMSFT commented May 17, 2023

The native store of oras-credentials-go currently depends on github.com/docker/docker-credential-helpers to interact with docker credential helper binaries and does not support context so that it cannot be cancelled when executing the helper binraries.

We should implement the native store to interact with the helper binaries directly according to the protocol with context support.

Contributors can leverage exec.CommandContext for context support for executing commands.

Note The dependency on golang.org/x/sys/execabs is not required since the security patch is enforced since go 1.19 (see doc).

See also: #18 (comment)

@shizhMSFT shizhMSFT added enhancement New feature or request dependencies Pull requests that update a dependency file labels May 17, 2023
@wangxiaoxuan273
Copy link
Collaborator

@shizhMSFT Here's a question that I need clarification for: the function exec.CommandContext returns a *exec.Cmd. Its ctx field is private, and once the Cmd is created in NewNativeStore(), I can no longer modify it at all.
Given this, how should the ctx field of nativeStore.Get(ctx, serverAddress) be used? It looks like we cannot use it to manipulate the Cmd in the NativeStore instance, as long as we use the Cmd of os/exec. And should we use one context for all operations of a NativeStore instance?

cc: @Wwwsylvia

@shizhMSFT
Copy link
Contributor Author

Given this, how should the ctx field of nativeStore.Get(ctx, serverAddress) be used?

You may consider create a *exe.Cmd instance each time you call nativeStore.Get(ctx, serverAddress) just like the docker credentials helper does. In fact, you should use a brand new instance of *exe.Cmd each time you execute a program.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants