Skip to content

Commit

Permalink
修复token获取问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kychen committed May 27, 2020
1 parent e4c7b7f commit e68ab6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion registry/tokenpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (t *TokenPool) SetToken(scope, token string) {
// repository:gds-eip/eip-api:pull
if l := strings.Split(scope, ":"); len(l) == 3 {
t.rwm.Lock()
t.tokens[l[2]] = token
t.tokens[l[1]] = token
t.rwm.Unlock()
}

Expand Down
5 changes: 4 additions & 1 deletion registry/tokentransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ func NewTokenTransport(transport http.RoundTripper, username string, password st
var scopeReg = regexp.MustCompile(`^/v2/([A-Za-z0-9/-]+)/\b(tags|manifests|blobs)\b`)

func (t *TokenTransport) GetScope(u string) string {
prefix := "/v2/"
sc := scopeReg.Find([]byte(u))
if sc == nil {
return ""
} else {
return string(sc)
begin := strings.Index(string(sc), prefix) + len(prefix)
end := strings.LastIndex(string(sc), "/")
return string(sc[begin:end])
}
}

Expand Down

0 comments on commit e68ab6e

Please sign in to comment.