-
Notifications
You must be signed in to change notification settings - Fork 297
enhance: add method for recreating all credentials #951
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
enhance: add method for recreating all credentials #951
Conversation
Signed-off-by: Grant Linville <[email protected]>
Signed-off-by: Grant Linville <[email protected]>
pkg/credentials/store.go
Outdated
s.recreateAllLock.Lock() | ||
authConfig, err := store.Get(serverAddress) | ||
if err != nil { | ||
s.recreateAllLock.Unlock() | ||
|
||
if IsCredentialsNotFoundError(err) { | ||
// This can happen if the credential was deleted between the GetAll and the Get by another thread. | ||
continue | ||
} | ||
return err | ||
} | ||
|
||
if err := store.Erase(serverAddress); err != nil { | ||
s.recreateAllLock.Unlock() | ||
return err | ||
} | ||
|
||
if err := store.Store(authConfig); err != nil { | ||
s.recreateAllLock.Unlock() | ||
return err | ||
} | ||
s.recreateAllLock.Unlock() | ||
} | ||
|
||
return nil |
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.
Writing a helper function for this will allow you to use defer s.recreateAllLock.Unlock()
.
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.
oh good call
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.
fixed
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 once Donnie's feedback is addressed.
Signed-off-by: Grant Linville <[email protected]>
for obot-platform/obot#1997