mirror of https://github.com/docker/docs.git
Merge pull request #407 from vieux/fix_panic_token
fix panic in token discovery
This commit is contained in:
commit
f5205cb7ca
|
@ -49,9 +49,7 @@ func (s *TokenDiscoveryService) Fetch() ([]*discovery.Entry, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.Body != nil {
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
}
|
|
||||||
|
|
||||||
var addrs []string
|
var addrs []string
|
||||||
if resp.StatusCode == http.StatusOK {
|
if resp.StatusCode == http.StatusOK {
|
||||||
|
@ -81,9 +79,12 @@ func (s *TokenDiscoveryService) Register(addr string) error {
|
||||||
resp, err := http.Post(fmt.Sprintf("%s/%s/%s", s.url,
|
resp, err := http.Post(fmt.Sprintf("%s/%s/%s", s.url,
|
||||||
"clusters", s.token), "application/json", buf)
|
"clusters", s.token), "application/json", buf)
|
||||||
|
|
||||||
// Force connection close
|
if err != nil {
|
||||||
resp.Body.Close()
|
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Body.Close()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateCluster returns a unique cluster token
|
// CreateCluster returns a unique cluster token
|
||||||
|
|
Loading…
Reference in New Issue