Skip to content
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

Subsequent DynamicStore.Put calls do not set credential store once failure #727

Closed
shizhMSFT opened this issue Mar 19, 2024 · 0 comments · Fixed by #728
Closed

Subsequent DynamicStore.Put calls do not set credential store once failure #727

shizhMSFT opened this issue Mar 19, 2024 · 0 comments · Fixed by #728
Labels
bug Something isn't working
Milestone

Comments

@shizhMSFT
Copy link
Contributor

In the following code block:

// Put saves credentials into the store for the given server address.
// Put returns ErrPlaintextPutDisabled if native store is not available and
// [StoreOptions].AllowPlaintextPut is set to false.
func (ds *DynamicStore) Put(ctx context.Context, serverAddress string, cred auth.Credential) (returnErr error) {
if err := ds.getStore(serverAddress).Put(ctx, serverAddress, cred); err != nil {
return err
}
// save the detected creds store back to the config file on first put
ds.setCredsStoreOnce.Do(func() {
if ds.detectedCredsStore != "" {
if err := ds.config.SetCredentialsStore(ds.detectedCredsStore); err != nil {
returnErr = fmt.Errorf("failed to set credsStore: %w", err)
}
}
})
return returnErr
}

If ds.setCredsStoreOnce fails on the first call to Put, the subsequent calls to Put will never attempt to set the credential store again but return success.

@shizhMSFT shizhMSFT added the bug Something isn't working label Mar 19, 2024
@shizhMSFT shizhMSFT added this to the v2.5.0 milestone Mar 19, 2024
Wwwsylvia pushed a commit that referenced this issue Mar 21, 2024
Fix #727

Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant