Skip to content

Commit dafca34

Browse files
committed
fix(builder): return error message as string
1 parent 65cc1f9 commit dafca34

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

builder/bin/get-app-config.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
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

builder/bin/publish-release-controller.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff 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")

0 commit comments

Comments
 (0)