mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Fixed HTTP response status code check for all successful codes
This commit is contained in:
parent
4298912ee7
commit
b85aae84c3
1 changed files with 4 additions and 3 deletions
|
|
@ -5,7 +5,6 @@ package smd
|
|||
// https://github.com/alexlovelltroy/hms-smd
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/bikeshack/magellan/internal/util"
|
||||
// hms "github.com/alexlovelltroy/hms-smd"
|
||||
|
|
@ -52,7 +51,8 @@ func AddRedfishEndpoint(data []byte, headers map[string]string) error {
|
|||
url := makeEndpointUrl("/Inventory/RedfishEndpoints")
|
||||
res, body, err := util.MakeRequest(url, "POST", data, headers)
|
||||
if res != nil {
|
||||
if res.StatusCode != http.StatusOK {
|
||||
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
|
||||
if !statusOk {
|
||||
return fmt.Errorf("could not add redfish endpoint")
|
||||
}
|
||||
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
|
||||
|
|
@ -69,7 +69,8 @@ func UpdateRedfishEndpoint(xname string, data []byte, headers map[string]string)
|
|||
res, body, err := util.MakeRequest(url, "PUT", data, headers)
|
||||
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
|
||||
if res != nil {
|
||||
if res.StatusCode != http.StatusOK {
|
||||
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
|
||||
if !statusOk {
|
||||
return fmt.Errorf("could not update redfish endpoint")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue