etcdserver: clean up code format

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-07-21 15:49:02 -07:00
parent 90a5da18cf
commit 51af6a062f
3 changed files with 6 additions and 7 deletions

View File

@ -160,12 +160,12 @@ func NewStore(lg *zap.Logger, server doer, timeout time.Duration) Store {
// passwordStore implements PasswordStore using bcrypt to hash user passwords
type passwordStore struct{}
func (_ passwordStore) CheckPassword(user User, password string) bool {
func (passwordStore) CheckPassword(user User, password string) bool {
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
return err == nil
}
func (_ passwordStore) HashPassword(password string) (string, error) {
func (passwordStore) HashPassword(password string) (string, error) {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(hash), err
}

View File

@ -30,7 +30,7 @@ import (
type fakeDoer struct{}
func (_ fakeDoer) Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error) {
func (fakeDoer) Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error) {
return etcdserver.Response{}, nil
}
@ -372,11 +372,11 @@ func TestEnsure(t *testing.T) {
type fastPasswordStore struct {
}
func (_ fastPasswordStore) CheckPassword(user User, password string) bool {
func (fastPasswordStore) CheckPassword(user User, password string) bool {
return user.Password == password
}
func (_ fastPasswordStore) HashPassword(password string) (string, error) { return password, nil }
func (fastPasswordStore) HashPassword(password string) (string, error) { return password, nil }
func TestCreateAndUpdateUser(t *testing.T) {
olduser := `{"user": "cat", "roles" : ["animal"]}`

View File

@ -216,9 +216,8 @@ func (s *store) Set(nodePath string, dir bool, value string, expireOpts TTLOptio
if getErr != nil {
err = getErr
return nil, err
} else {
value = n.Value
}
value = n.Value
}
// Set new value