Merge pull request #205 from ywk253100/bug_fix_for_registry_client

Bug fix for registry client
This commit is contained in:
Wenkai Yin 2016-05-10 11:11:43 +08:00
commit f471f13363
3 changed files with 8 additions and 14 deletions

View File

@ -12,4 +12,4 @@ LDAP_URL=$ldap_url
LDAP_BASE_DN=$ldap_basedn
SELF_REGISTRATION=$self_registration
LOG_LEVEL=debug
GODEBUG=netdns=cgo
GODEBUG=netdns=cgo

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
}