mirror of https://github.com/databricks/cli.git
rename DeleteKey to Delete
This commit is contained in:
parent
171c3fdd75
commit
37067ef933
|
@ -9,7 +9,7 @@ import (
|
||||||
type TokenCache interface {
|
type TokenCache interface {
|
||||||
Store(key string, t *oauth2.Token) error
|
Store(key string, t *oauth2.Token) error
|
||||||
Lookup(key string) (*oauth2.Token, error)
|
Lookup(key string) (*oauth2.Token, error)
|
||||||
DeleteKey(key string) error
|
Delete(key string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
var tokenCache int
|
var tokenCache int
|
||||||
|
|
|
@ -73,7 +73,7 @@ func (c *FileTokenCache) Lookup(key string) (*oauth2.Token, error) {
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FileTokenCache) DeleteKey(key string) error {
|
func (c *FileTokenCache) Delete(key string) error {
|
||||||
err := c.load()
|
err := c.load()
|
||||||
if errors.Is(err, fs.ErrNotExist) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
return ErrNotConfigured
|
return ErrNotConfigured
|
||||||
|
|
|
@ -118,7 +118,7 @@ func TestStoreAndDeleteKey(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
l := &FileTokenCache{}
|
l := &FileTokenCache{}
|
||||||
err = l.DeleteKey("x")
|
err = l.Delete("x")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(l.Tokens))
|
assert.Equal(t, 1, len(l.Tokens))
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ func TestDeleteKeyNotExist(t *testing.T) {
|
||||||
c := &FileTokenCache{
|
c := &FileTokenCache{
|
||||||
Tokens: map[string]*oauth2.Token{},
|
Tokens: map[string]*oauth2.Token{},
|
||||||
}
|
}
|
||||||
err := c.DeleteKey("x")
|
err := c.Delete("x")
|
||||||
assert.Equal(t, ErrNotConfigured, err)
|
assert.Equal(t, ErrNotConfigured, err)
|
||||||
|
|
||||||
_, err = c.Lookup("x")
|
_, err = c.Lookup("x")
|
||||||
|
|
|
@ -23,8 +23,8 @@ func (i *InMemoryTokenCache) Store(key string, t *oauth2.Token) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteKey implements TokenCache.
|
// Delete implements TokenCache.
|
||||||
func (i *InMemoryTokenCache) DeleteKey(key string) error {
|
func (i *InMemoryTokenCache) Delete(key string) error {
|
||||||
_, ok := i.Tokens[key]
|
_, ok := i.Tokens[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrNotConfigured
|
return ErrNotConfigured
|
||||||
|
|
|
@ -58,7 +58,7 @@ func TestInMemoryDeleteKey(t *testing.T) {
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = c.DeleteKey("x")
|
err = c.Delete("x")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(c.Tokens))
|
assert.Equal(t, 1, len(c.Tokens))
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ func TestInMemoryDeleteKeyNotExist(t *testing.T) {
|
||||||
c := &InMemoryTokenCache{
|
c := &InMemoryTokenCache{
|
||||||
Tokens: map[string]*oauth2.Token{},
|
Tokens: map[string]*oauth2.Token{},
|
||||||
}
|
}
|
||||||
err := c.DeleteKey("x")
|
err := c.Delete("x")
|
||||||
assert.Equal(t, ErrNotConfigured, err)
|
assert.Equal(t, ErrNotConfigured, err)
|
||||||
|
|
||||||
_, err = c.Lookup("x")
|
_, err = c.Lookup("x")
|
||||||
|
|
|
@ -152,7 +152,7 @@ func (a *PersistentAuth) ClearToken(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
// lookup token identified by host (and possibly the account id)
|
// lookup token identified by host (and possibly the account id)
|
||||||
key := a.key()
|
key := a.key()
|
||||||
return a.cache.DeleteKey(key)
|
return a.cache.Delete(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PersistentAuth) init(ctx context.Context) error {
|
func (a *PersistentAuth) init(ctx context.Context) error {
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (m *tokenCacheMock) Lookup(key string) (*oauth2.Token, error) {
|
||||||
return m.lookup(key)
|
return m.lookup(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tokenCacheMock) DeleteKey(key string) error {
|
func (m *tokenCacheMock) Delete(key string) error {
|
||||||
if m.deleteKey == nil {
|
if m.deleteKey == nil {
|
||||||
panic("no deleteKey mock")
|
panic("no deleteKey mock")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue