Skip to content

Commit 1d09093

Browse files
chore(*): upgrade docker-go-dev and use new linter (#60)
1 parent 09f8465 commit 1d09093

11 files changed

Lines changed: 25 additions & 34 deletions

File tree

Makefile

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
1-
export GO15VENDOREXPERIMENT=1
2-
31
# the filepath to this repository, relative to $GOPATH/src
42
repo_path = github.com/deis/controller-sdk-go
53

6-
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.10.0
4+
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.16.0
75
DEV_ENV_WORK_DIR := /go/src/${repo_path}
8-
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -e CGO_ENABLED=0 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
9-
DEV_ENV_PREFIX_CGO_ENABLED := docker run --rm -e GO15VENDOREXPERIMENT=1 -e CGO_ENABLED=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
6+
DEV_ENV_PREFIX := docker run --rm -e CGO_ENABLED=0 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
7+
DEV_ENV_PREFIX_CGO_ENABLED := docker run --rm -e CGO_ENABLED=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
108
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
119

12-
GO_FILES = $(wildcard *.go)
13-
GO_PACKAGES = api apps auth builds certs config domains keys perms ps releases users pkg/time
14-
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
15-
GOFMT = gofmtresult=$$(gofmt -e -l -s ${GO_FILES} ${GO_PACKAGES}); if [[ -n $$gofmtresult ]]; then echo "gofmt errors found in the following files: $${gofmtresult}"; false; fi;
16-
GOTEST = go test --cover --race -v
17-
1810
# UID and GID of local user
1911
UID := $(shell id -u)
2012
GID := $(shell id -g)
2113

14+
GOTEST = go test --cover --race
2215

2316
bootstrap:
2417
${DEV_ENV_CMD} glide install
2518

2619
glideup:
2720
${DEV_ENV_CMD} glide up
2821

29-
setup-gotools:
30-
go get -u github.com/golang/lint/golint
31-
go get -u golang.org/x/tools/cmd/cover
32-
go get -u golang.org/x/tools/cmd/vet
33-
3422
test: test-style test-unit
3523

3624
test-style:
37-
${DEV_ENV_CMD} bash -c '${GOFMT}'
38-
${DEV_ENV_CMD} sh -c 'go vet $(repo_path) $(GO_PACKAGES_REPO_PATH)'
39-
@for i in $(addsuffix /...,$(GO_PACKAGES)); do \
40-
${DEV_ENV_CMD} golint $$i; \
41-
done
25+
${DEV_ENV_CMD} lint
4226

4327
test-unit:
4428
${DEV_ENV_PREFIX_CGO_ENABLED} ${DEV_ENV_IMAGE} sh -c '${GOTEST} $$(glide nv)'

api/apps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type App struct {
1010
UUID string `json:"uuid"`
1111
}
1212

13+
// Apps defines a collection of app objects.
1314
type Apps []App
1415

1516
func (a Apps) Len() int { return len(a) }

api/domains.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type Domain struct {
99
Updated string `json:"updated"`
1010
}
1111

12+
// Domains defines a collection of domain objects.
1213
type Domains []Domain
1314

1415
func (d Domains) Len() int { return len(d) }

api/keys.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Key struct {
1010
UUID string `json:"uuid"`
1111
}
1212

13+
// Keys defines a collection of key objects.
1314
type Keys []Key
1415

1516
func (k Keys) Len() int { return len(k) }

api/ps.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ type Pods struct {
1111
Started time.Time `json:"started"`
1212
}
1313

14+
// PodsList defines a collection of app pods.
1415
type PodsList []Pods
1516

1617
func (p PodsList) Len() int { return len(p) }
1718
func (p PodsList) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
1819
func (p PodsList) Less(i, j int) bool { return p[i].Name < p[j].Name }
1920

21+
// PodType holds pods of the same type.
2022
type PodType struct {
2123
Type string
2224
PodsList PodsList
2325
}
2426

27+
// PodTypes holds groups of pods organized by type.
2528
type PodTypes []PodType
2629

2730
func (p PodTypes) Len() int { return len(p) }

api/users.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Date Joined: %s`
3434
u.IsSuperuser, u.IsStaff, u.IsActive, u.DateJoined)
3535
}
3636

37+
// Users holds a collection of user objects.
3738
type Users []User
3839

3940
func (u Users) Len() int { return len(u) }

apps/apps_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ func (f *fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
6161
res.Write(nil)
6262
}
6363

64-
if string(body) == appCreateExpected && f.createID == false {
64+
if string(body) == appCreateExpected && !f.createID {
6565
f.createID = true
6666
res.WriteHeader(http.StatusCreated)
6767
res.Write([]byte(appFixture))
6868
return
69-
} else if string(body) == "" && f.createWithoutID == false {
69+
} else if string(body) == "" && !f.createWithoutID {
7070
f.createWithoutID = true
7171
res.WriteHeader(http.StatusCreated)
7272
res.Write([]byte(appFixture))

auth/auth.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ func Delete(c *deis.Client, username string) error {
8484
// with this new token to avoid authentication errors.
8585
//
8686
// If username is set and all is false, this will regenerate that user's token
87-
// and return a new token. If not targeting yourself, regenerate requires administrative privilages.
87+
// and return a new token. If not targeting yourself, regenerate requires administrative privileges.
8888
//
89-
// If all is true, this will regenerate every user's token. This requires administrative privilages.
89+
// If all is true, this will regenerate every user's token. This requires administrative privileges.
9090
func Regenerate(c *deis.Client, username string, all bool) (string, error) {
9191
var reqBody []byte
9292
var err error
9393

94-
if all == true {
94+
if all {
9595
reqBody, err = json.Marshal(api.AuthRegenerateRequest{All: all})
9696
} else if username != "" {
9797
reqBody, err = json.Marshal(api.AuthRegenerateRequest{Name: username})
@@ -111,7 +111,7 @@ func Regenerate(c *deis.Client, username string, all bool) (string, error) {
111111
res.Body.Close()
112112
}()
113113

114-
if all == true {
114+
if all {
115115
return "", nil
116116
}
117117

@@ -128,7 +128,7 @@ func Regenerate(c *deis.Client, username string, all bool) (string, error) {
128128
// If username if an empty string, change the password of the client's user.
129129
//
130130
// If username is set, change the password of another user and do not require
131-
// their password. This requires administrative privilages.
131+
// their password. This requires administrative privileges.
132132
func Passwd(c *deis.Client, username, password, newPassword string) error {
133133
req := api.AuthPasswdRequest{Password: password, NewPassword: newPassword}
134134

@@ -149,6 +149,7 @@ func Passwd(c *deis.Client, username, password, newPassword string) error {
149149
return err
150150
}
151151

152+
// Whoami retrives the user object for the authenticated user.
152153
func Whoami(c *deis.Client) (api.User, error) {
153154
res, err := c.Request("GET", "/v2/auth/whoami/", nil)
154155
if err != nil {

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func List(c *deis.Client, app string) (api.Config, error) {
3737
// This is a patching operation, which means when you call Set() with an api.Config:
3838
//
3939
// - If the variable does not exist, it will be set.
40-
// - If the variable exists, it will be overwriten.
40+
// - If the variable exists, it will be overwritten.
4141
// - If the variable is set to nil, it will be unset.
4242
// - If the variable was ignored in the api.Config, it will remain unchanged.
4343
//

errors_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ func (m *mockReadCloser) Close() error {
2121
}
2222

2323
func (m *mockReadCloser) Read(msg []byte) (int, error) {
24-
if m.closed == true {
24+
if m.closed {
2525
return 0, errors.New("You can't read on a closed ReadCloser")
2626
}
2727

2828
if m.msg == "" {
2929
return 0, io.EOF
3030
}
3131

32-
for i, b := range []byte(m.msg) {
33-
msg[i] = b
34-
}
32+
copy(msg, []byte(m.msg))
33+
3534
len := len(m.msg)
3635
m.msg = ""
3736
return len, nil

0 commit comments

Comments
 (0)