File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 "encoding/json"
66 "flag"
77 "fmt"
8+ "io/ioutil"
89 "net/http"
910 "os"
1011
@@ -85,9 +86,15 @@ func main() {
8586 os .Exit (1 )
8687 }
8788
89+ body , err := ioutil .ReadAll (res .Body )
90+ if err != nil {
91+ fmt .Println (err )
92+ os .Exit (1 )
93+ }
94+
8895 if err != nil || res .StatusCode != 200 {
8996 fmt .Println ("failed retrieving config from controller" )
90- fmt .Println (res . Body )
97+ fmt .Println (body )
9198 os .Exit (1 )
9299 }
93100
Original file line number Diff line number Diff line change @@ -82,19 +82,20 @@ func main() {
8282 log .Fatalln (err )
8383 }
8484
85- if res .StatusCode == 503 {
86- log .Fatalln ("check the controller. is it running?" )
87- } else if res .StatusCode != 200 {
88- log .Fatalf ("failed retrieving config from controller: %s\n " , res .Body )
89- }
90-
9185 defer res .Body .Close ()
92- // Read json response from body
86+
9387 body , err := ioutil .ReadAll (res .Body )
9488 if err != nil {
9589 fmt .Println (err )
9690 os .Exit (1 )
9791 }
92+
93+ if res .StatusCode == 503 {
94+ log .Fatalln ("check the controller. is it running?" )
95+ } else if res .StatusCode != 200 {
96+ log .Fatalf ("failed retrieving config from controller: %s\n " , body )
97+ }
98+
9899 var response map [string ]interface {}
99100 if err := json .Unmarshal (body , & response ); err != nil {
100101 fmt .Println ("invalid controller json response" )
You can’t perform that action at this time.
0 commit comments