Skip to content

Commit

Permalink
fix: auth with the same name (#1106)
Browse files Browse the repository at this point in the history
* fix: auth with the same name

Signed-off-by: Keming <kemingyang@tensorchord.ai>

* fix

Signed-off-by: Keming <kemingyang@tensorchord.ai>

Signed-off-by: Keming <kemingyang@tensorchord.ai>
  • Loading branch information
kemingy authored Oct 28, 2022
1 parent e831fe9 commit 8f89ba6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/home/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ func (m *generalManager) AuthGetCurrent() (types.AuthConfig, error) {
}

func (m *generalManager) AuthCreate(ac types.AuthConfig, use bool) error {
exist := false
for _, a := range m.auth.Auth {
if a.Name == ac.Name {
// Auth should be idempotent. Thus do not return error here.
return nil
exist = true
}
}
m.auth.Auth = append(m.auth.Auth, ac)
if !exist {
m.auth.Auth = append(m.auth.Auth, ac)
}
if use {
return m.AuthUse(ac.Name)
}
Expand Down

0 comments on commit 8f89ba6

Please sign in to comment.