-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #77 +/- ##
=======================================
Coverage 82.73% 82.73%
=======================================
Files 6 6
Lines 388 388
=======================================
Hits 321 321
Misses 45 45
Partials 22 22
|
native_store.go
Outdated
@@ -120,6 +122,9 @@ func (ns *nativeStore) Put(ctx context.Context, serverAddress string, cred auth. | |||
return err | |||
} | |||
_, err = ns.exec.Execute(ctx, bytes.NewReader(credJSON), "store") | |||
if err != nil && err.Error() == errExeNotInPathMessage { | |||
return fmt.Errorf("credential store is configured to `desktop` but docker desktop seems not running") |
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.
Should we call it credentials store
by following the consistent naming with Docker? See https://docs.docker.com/engine/reference/commandline/login/#credentials-store
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.
Will this error message Error: error storing credentials:
be added by ORAS to the beginning in this output?
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.
Will this error message
Error: error storing credentials:
be added by ORAS to the beginning in this output?
You can take a look at the screen shot above. It looks like the answer is no. We can change it if we need. @FeynmanZhou
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.
Should we call it
credentials store
by following the consistent naming with Docker? See https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Nice catch. Changed the name.
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.
@wangxiaoxuan273 You can check the log style in other ORAS error logs. If there is a consistent log style in ORAS, we may need to follow it and add it accordingly. If not, we can skip it.
native_store.go
Outdated
@@ -30,6 +31,7 @@ const ( | |||
remoteCredentialsPrefix = "docker-credential-" | |||
emptyUsername = "<token>" | |||
errCredentialsNotFoundMessage = "credentials not found in native keychain" | |||
errExeNotInPathMessage = "exec: \"docker-credential-desktop.exe\": executable file not found in $PATH" |
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.
Should there be a native_store_wsl.go to handle this that or can we count on a generic match?
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.
We don't think a separate wsl.go
file is necessary. We have changed exact string matching to error matching to improve the code.
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.
The code was improved by the time this was merged, but this is exactly the kind of thing you'd want to put in a platform specific module.
native_store.go
Outdated
@@ -30,6 +31,7 @@ const ( | |||
remoteCredentialsPrefix = "docker-credential-" | |||
emptyUsername = "<token>" | |||
errCredentialsNotFoundMessage = "credentials not found in native keychain" | |||
errExeNotInPathMessage = "exec: \"docker-credential-desktop.exe\": executable file not found in $PATH" |
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.
Consider adding the following code to executer.go
.
if execErr, ok := err.(*exec.Error); ok && execErr.Err == exec.ErrNotFound {
return nil, errors.New("credentials store is configured to `desktop` but Docker Desktop seems not running")
}
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.
Added this part. It's a very good suggestion.
native_store.go
Outdated
@@ -120,6 +122,9 @@ func (ns *nativeStore) Put(ctx context.Context, serverAddress string, cred auth. | |||
return err | |||
} | |||
_, err = ns.exec.Execute(ctx, bytes.NewReader(credJSON), "store") | |||
if err != nil && err.Error() == errExeNotInPathMessage { | |||
return fmt.Errorf("credentials store is configured to `desktop` but Docker Desktop seems not running") |
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.
nit:
return fmt.Errorf("credentials store is configured to `desktop` but Docker Desktop seems not running") | |
return fmt.Errorf("credentials store is configured to `desktop.exe` but Docker Desktop seems not running") |
/cc @FeynmanZhou
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.
@shizhMSFT Good catch.
internal/executer/executer.go
Outdated
err = errors.New(errMessage) | ||
return nil, err |
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.
nit: clean code
err = errors.New(errMessage) | |
return nil, err | |
return nil, errors.New(errMessage) |
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.
changed this part and used a switch statement.
internal/executer/executer.go
Outdated
// check if the error is caused by Docker Desktop not running | ||
if execErr, ok := err.(*exec.Error); ok && execErr.Err == exec.ErrNotFound { | ||
return nil, errors.New("credentials store is configured to `desktop` but Docker Desktop seems not running") | ||
} |
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.
What if the binary is not docker-credential-desktop.exe
?
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.
added a third condition.
This version looks good to me. Thanks @wangxiaoxuan273 |
Signed-off-by: Xiaoxuan Wang <[email protected]>
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.
LGTM
Resolves #26