This commit is contained in:
Wenkai Yin 2016-05-10 10:59:59 +08:00
parent 6373497e58
commit f5bf0c1a3f
2 changed files with 7 additions and 13 deletions

View File

@ -21,7 +21,6 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
@ -176,7 +175,7 @@ func (s *standardTokenHandler) generateToken(realm, service string, scopes []str
tk := struct {
Token string `json:"token"`
ExpiresIn string `json:"expires_in"`
ExpiresIn int `json:"expires_in"`
IssuedAt string `json:"issued_at"`
}{}
if err = json.Unmarshal(b, &tk); err != nil {
@ -185,19 +184,14 @@ func (s *standardTokenHandler) generateToken(realm, service string, scopes []str
token = tk.Token
expiresIn, err = strconv.Atoi(tk.ExpiresIn)
expiresIn = tk.ExpiresIn
t, err := time.Parse(time.RFC3339, tk.IssuedAt)
if err != nil {
expiresIn = 0
log.Errorf("error occurred while converting expires_in: %v", err)
log.Errorf("error occurred while parsing issued_at: %v", err)
err = nil
} else {
t, err := time.Parse(time.RFC3339, tk.IssuedAt)
if err != nil {
log.Errorf("error occurred while parsing issued_at: %v", err)
err = nil
} else {
issuedAt = &t
}
issuedAt = &t
}
log.Debug("get token from token server")

View File

@ -103,7 +103,7 @@ func NewRepositoryWithUsername(name, endpoint, username string) (*Repository, er
client: client,
}
log.Debugf("initialized a repository client with username: %s %s", endpoint, name, username)
log.Debugf("initialized a repository client with username: %s %s %s", endpoint, name, username)
return repository, nil
}