Skip to content

Commit 143c911

Browse files
chore(*): update to go1.7 (#78)
1 parent 7b5abf2 commit 143c911

15 files changed

Lines changed: 28 additions & 155 deletions

File tree

Makefile

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,16 @@ REGISTRY ?= quay.io/
66
IMAGE_PREFIX ?= deisci
77
IMAGE := ${REGISTRY}${IMAGE_PREFIX}/controller-sdk-go-dev:${REVISION}
88

9-
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.16.0
10-
DEV_ENV_WORK_DIR := /go/src/${repo_path}
11-
DEV_ENV_PREFIX := docker run --rm -e CGO_ENABLED=0 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
12-
DEV_ENV_PREFIX_CGO_ENABLED := docker run --rm -e CGO_ENABLED=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
13-
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
14-
15-
# UID and GID of local user
16-
UID := $(shell id -u)
17-
GID := $(shell id -g)
18-
19-
GOTEST = go test --cover --race
20-
21-
bootstrap:
22-
${DEV_ENV_CMD} glide install
23-
24-
glideup:
25-
${DEV_ENV_CMD} glide up
26-
279
test-style: build-test-image
2810
docker run --rm ${IMAGE} lint
2911

30-
test: build-test-image
12+
test-unit: build-test-image
3113
docker run --rm ${IMAGE} test
3214

15+
test: build-test-image test-style test-unit
16+
3317
build-test-image:
3418
docker build -t ${IMAGE} .
3519

36-
push-test-image: build-test-image
20+
push-test-image:
21+
docker push ${IMAGE}

api/appsettings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type AppSettings struct {
1919
Routable *bool `json:"routable,omitempty"`
2020
}
2121

22+
// NewRoutable returns a default value for the AppSettings.Routable field.
2223
func NewRoutable() *bool {
2324
b := true
2425
return &b

apps/apps.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"io"
98
"io/ioutil"
109
"strconv"
1110

@@ -58,11 +57,7 @@ func New(c *deis.Client, appID string) (api.App, error) {
5857
if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
5958
return api.App{}, reqErr
6059
}
61-
// Fix json.Decoder bug in <go1.7
62-
defer func() {
63-
io.Copy(ioutil.Discard, res.Body)
64-
res.Body.Close()
65-
}()
60+
defer res.Body.Close()
6661

6762
app := api.App{}
6863
if err := json.NewDecoder(res.Body).Decode(&app); err != nil {
@@ -80,11 +75,7 @@ func Get(c *deis.Client, appID string) (api.App, error) {
8075
if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
8176
return api.App{}, reqErr
8277
}
83-
// Fix json.Decoder bug in <go1.7
84-
defer func() {
85-
io.Copy(ioutil.Discard, res.Body)
86-
res.Body.Close()
87-
}()
78+
defer res.Body.Close()
8879

8980
app := api.App{}
9081

appsettings/appsettings.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package appsettings
44
import (
55
"encoding/json"
66
"fmt"
7-
"io"
8-
"io/ioutil"
97

108
deis "github.com/deis/controller-sdk-go"
119
"github.com/deis/controller-sdk-go/api"
@@ -19,11 +17,7 @@ func List(c *deis.Client, app string) (api.AppSettings, error) {
1917
if reqErr != nil {
2018
return api.AppSettings{}, reqErr
2119
}
22-
// Fix json.Decoder bug in <go1.7
23-
defer func() {
24-
io.Copy(ioutil.Discard, res.Body)
25-
res.Body.Close()
26-
}()
20+
defer res.Body.Close()
2721

2822
settings := api.AppSettings{}
2923
if err := json.NewDecoder(res.Body).Decode(&settings); err != nil {
@@ -55,11 +49,7 @@ func Set(c *deis.Client, app string, appSettings api.AppSettings) (api.AppSettin
5549
if reqErr != nil {
5650
return api.AppSettings{}, reqErr
5751
}
58-
// Fix json.Decoder bug in <go1.7
59-
defer func() {
60-
io.Copy(ioutil.Discard, res.Body)
61-
res.Body.Close()
62-
}()
52+
defer res.Body.Close()
6353

6454
newAppSettings := api.AppSettings{}
6555
if err = json.NewDecoder(res.Body).Decode(&newAppSettings); err != nil {

auth/auth.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package auth
33

44
import (
55
"encoding/json"
6-
"io"
7-
"io/ioutil"
86

97
deis "github.com/deis/controller-sdk-go"
108
"github.com/deis/controller-sdk-go/api"
@@ -41,11 +39,7 @@ func Login(c *deis.Client, username, password string) (string, error) {
4139
if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
4240
return "", reqErr
4341
}
44-
// Fix json.Decoder bug in <go1.7
45-
defer func() {
46-
io.Copy(ioutil.Discard, res.Body)
47-
res.Body.Close()
48-
}()
42+
defer res.Body.Close()
4943

5044
token := api.AuthLoginResponse{}
5145
if err = json.NewDecoder(res.Body).Decode(&token); err != nil {
@@ -105,11 +99,7 @@ func Regenerate(c *deis.Client, username string, all bool) (string, error) {
10599
if err != nil && !deis.IsErrAPIMismatch(reqErr) {
106100
return "", reqErr
107101
}
108-
// Fix json.Decoder bug in <go1.7
109-
defer func() {
110-
io.Copy(ioutil.Discard, res.Body)
111-
res.Body.Close()
112-
}()
102+
defer res.Body.Close()
113103

114104
if all {
115105
return "", nil
@@ -155,11 +145,7 @@ func Whoami(c *deis.Client) (api.User, error) {
155145
if err != nil {
156146
return api.User{}, err
157147
}
158-
// Fix json.Decoder bug in <go1.7
159-
defer func() {
160-
io.Copy(ioutil.Discard, res.Body)
161-
res.Body.Close()
162-
}()
148+
defer res.Body.Close()
163149

164150
resUser := api.User{}
165151
if err = json.NewDecoder(res.Body).Decode(&resUser); err != nil {

builds/builds.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package builds
44
import (
55
"encoding/json"
66
"fmt"
7-
"io"
8-
"io/ioutil"
97

108
deis "github.com/deis/controller-sdk-go"
119
"github.com/deis/controller-sdk-go/api"
@@ -72,11 +70,7 @@ func New(c *deis.Client, appID string, image string,
7270
if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
7371
return api.Build{}, reqErr
7472
}
75-
// Fix json.Decoder bug in <go1.7
76-
defer func() {
77-
io.Copy(ioutil.Discard, res.Body)
78-
res.Body.Close()
79-
}()
73+
defer res.Body.Close()
8074

8175
build := api.Build{}
8276
if err = json.NewDecoder(res.Body).Decode(&build); err != nil {

certs/certs.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package certs
44
import (
55
"encoding/json"
66
"fmt"
7-
"io"
8-
"io/ioutil"
97

108
deis "github.com/deis/controller-sdk-go"
119
"github.com/deis/controller-sdk-go/api"
@@ -42,11 +40,7 @@ func New(c *deis.Client, cert string, key string, name string) (api.Cert, error)
4240
if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
4341
return api.Cert{}, reqErr
4442
}
45-
// Fix json.Decoder bug in <go1.7
46-
defer func() {
47-
io.Copy(ioutil.Discard, res.Body)
48-
res.Body.Close()
49-
}()
43+
defer res.Body.Close()
5044

5145
resCert := api.Cert{}
5246
if err = json.NewDecoder(res.Body).Decode(&resCert); err != nil {
@@ -63,11 +57,7 @@ func Get(c *deis.Client, name string) (api.Cert, error) {
6357
if reqErr != nil {
6458
return api.Cert{}, reqErr
6559
}
66-
// Fix json.Decoder bug in <go1.7
67-
defer func() {
68-
io.Copy(ioutil.Discard, res.Body)
69-
res.Body.Close()
70-
}()
60+
defer res.Body.Close()
7161

7262
resCert := api.Cert{}
7363
if err := json.NewDecoder(res.Body).Decode(&resCert); err != nil {

config/config.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package config
44
import (
55
"encoding/json"
66
"fmt"
7-
"io"
8-
"io/ioutil"
97

108
deis "github.com/deis/controller-sdk-go"
119
"github.com/deis/controller-sdk-go/api"
@@ -19,11 +17,7 @@ func List(c *deis.Client, app string) (api.Config, error) {
1917
if reqErr != nil {
2018
return api.Config{}, reqErr
2119
}
22-
// Fix json.Decoder bug in <go1.7
23-
defer func() {
24-
io.Copy(ioutil.Discard, res.Body)
25-
res.Body.Close()
26-
}()
20+
defer res.Body.Close()
2721

2822
config := api.Config{}
2923
if err := json.NewDecoder(res.Body).Decode(&config); err != nil {
@@ -57,11 +51,7 @@ func Set(c *deis.Client, app string, config api.Config) (api.Config, error) {
5751
if reqErr != nil {
5852
return api.Config{}, reqErr
5953
}
60-
// Fix json.Decoder bug in <go1.7
61-
defer func() {
62-
io.Copy(ioutil.Discard, res.Body)
63-
res.Body.Close()
64-
}()
54+
defer res.Body.Close()
6555

6656
newConfig := api.Config{}
6757
if err = json.NewDecoder(res.Body).Decode(&newConfig); err != nil {

domains/domains.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package domains
44
import (
55
"encoding/json"
66
"fmt"
7-
"io"
8-
"io/ioutil"
97

108
deis "github.com/deis/controller-sdk-go"
119
"github.com/deis/controller-sdk-go/api"
@@ -44,11 +42,7 @@ func New(c *deis.Client, appID string, domain string) (api.Domain, error) {
4442
if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
4543
return api.Domain{}, reqErr
4644
}
47-
// Fix json.Decoder bug in <go1.7
48-
defer func() {
49-
io.Copy(ioutil.Discard, res.Body)
50-
res.Body.Close()
51-
}()
45+
defer res.Body.Close()
5246

5347
d := api.Domain{}
5448
if err = json.NewDecoder(res.Body).Decode(&d); err != nil {

errors.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"io"
87
"io/ioutil"
98
"net/http"
109
"strings"
@@ -96,12 +95,7 @@ func checkForErrors(res *http.Response) error {
9695
if res.StatusCode >= 200 && res.StatusCode < 400 {
9796
return nil
9897
}
99-
100-
// Fix json.Decoder bug in <go1.7
101-
defer func() {
102-
io.Copy(ioutil.Discard, res.Body)
103-
res.Body.Close()
104-
}()
98+
defer res.Body.Close()
10599

106100
out, err := ioutil.ReadAll(res.Body)
107101
if err != nil {

0 commit comments

Comments
 (0)