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
|
||||
}
|
||||
|
||||
if resp.Body != nil {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
|
||||
var addrs []string
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
|
@ -81,11 +79,14 @@ func (s *TokenDiscoveryService) Register(addr string) error {
|
|||
resp, err := http.Post(fmt.Sprintf("%s/%s/%s", s.url,
|
||||
"clusters", s.token), "application/json", buf)
|
||||
|
||||
// Force connection close
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateCluster returns a unique cluster token
|
||||
func (s *TokenDiscoveryService) CreateCluster() (string, error) {
|
||||
resp, err := http.Post(fmt.Sprintf("%s/%s", s.url, "clusters"), "", nil)
|
||||
|
|
Loading…
Reference in New Issue