1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-01 07:21:07 +00:00

Update doAction to not expect a response

Problem:
doAction assumes that an action would have a response body which causes
JSON unmarshal errors

Solution:
Only attempt to Unmarshal when a response is expected
This commit is contained in:
Dan Ramich 2018-04-27 13:33:05 -07:00 committed by Darren Shepherd
parent e6973cb055
commit 98500d10f5

View File

@ -285,6 +285,10 @@ func (a *APIOperations) doAction(
var input io.Reader
if debug {
fmt.Println("POST " + actionURL)
}
if inputObject != nil {
bodyContent, err := json.Marshal(inputObject)
if err != nil {
@ -325,5 +329,8 @@ func (a *APIOperations) doAction(
fmt.Println("Response <= " + string(byteContent))
}
return json.Unmarshal(byteContent, respObject)
if nil != respObject {
return json.Unmarshal(byteContent, respObject)
}
return nil
}