failure fast if not 200 when authenticating

Change-Id: Ibe1c38f632d1f0155830f00354de2135ee5aceb6
This commit is contained in:
arkxu 2016-04-25 15:56:57 -07:00
parent 452642dade
commit 16ac1f84b2
1 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package openstack
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"strings"
"time"
@ -91,6 +92,11 @@ func DoAuthRequest(authopts AuthOpts) (AuthRef, error) {
if err != nil {
return nil, errors.New("error reading response body")
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("auth error: %s", rbody)
}
if err = json.Unmarshal(rbody, &auth); err != nil {
return nil, errors.New("error unmarshalling response body")
}