Skip to content

Commit 4ebaac4

Browse files
committed
Switch to go modules and version toolchain
1 parent 6aaaf6f commit 4ebaac4

File tree

10 files changed

+273
-374
lines changed

10 files changed

+273
-374
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ vendor
33
*node_modules
44
yarn.lock
55
dist
6+
.vscode
7+
.gobincache

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
language: go
33

44
go:
5-
- "1.10"
6-
- "1.11"
7-
5+
- "1.12"
6+
env:
7+
- GO111MODULE=on
88
install: make deps
99
script: make test
1010
notifications:

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
We use [go-swagger](https://github.com/go-swagger/go-swagger) to validate our spec against the 2.0 spec of Open API.
44

5-
We currently depend on version 0.18.0 of the go swagger toolchain. You can download the binary for your platform from this release page:
5+
[We currently depend on version 0.18.0 of the go swagger toolchain. You can download the binary for your platform from this release page:
66

7-
https://github.com/go-swagger/go-swagger/releases/tag/0.18.0
7+
https://github.com/go-swagger/go-swagger/releases/tag/0.18.0](The go-client is an [netlify/open-api][open-api] derived http client generated using [go-swagger][go-swagger]. Starting with version [`2.0.0`](https://github.com/netlify/go-client/releases/tag/v2.0.0) it is managed with [Go 1.11 modules][go-modules], and all external tools used for generation are managed with [gobin][gobin] + Go modules. The [`swagger.yml`][swagger] is consumed as a vendored build-time asset via a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). See [GMBE:Tools as dependencies](https://github.com/go-modules-by-example/index/tree/master/010_tools) and [GMBE:Using `gobin` to install/run tools](https://github.com/go-modules-by-example/index/tree/master/017_using_gobin) for a deeper explanation.)
88

99
## Spec validation
1010

@@ -21,7 +21,7 @@ The Go client must be regenerated after every change to the `swagger.yml`.
2121
You can use this command to generate the Go client:
2222

2323
make generate
24-
24+
2525
You may first want to edit swagger.yml to add your field or endpoint definitions.
2626

2727
## Making PRs

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
.PHONY: all build deps generate help test validate
22
CHECK_FILES?=$$(go list ./... | grep -v /vendor/)
3+
SWAGGER_SPEC=swagger.yml
34

45
help: ## Show this help.
56
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
67

7-
all: validate generate build ## Validate the swagger spec, generate the code and build it.
8+
all: deps generate build test ## Validate the swagger spec, generate the code and build it.
89

910
build: ## Build the API Go client.
10-
cd ./go && go build ./...
11+
go build ./go/...
1112

1213
deps: ## Download dependencies.
13-
go get -u github.com/golang/dep/cmd/dep && cd ./go && dep ensure
14+
GO111MODULE=off go get -u github.com/myitcv/gobin && go mod download
1415

1516
generate: validate ## Generate the API Go client and the JSON document for the UI.
16-
swagger generate client -A netlify -f swagger.yml -t go -c plumbing --with-flatten=full
17+
go generate
1718

1819
test: ## Test the go code.
19-
cd ./go && go test -v $(CHECK_FILES)
20+
gobin -m -run github.com/kyoh86/richgo test -v $(CHECK_FILES)
2021

2122
validate: ## Check that the swagger spec is valid.
22-
swagger validate swagger.yml
23+
gobin -m -run github.com/go-swagger/go-swagger/cmd/swagger validate $(SWAGGER_SPEC)

generate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package tools
2+
3+
//go:generate gobin -m -run github.com/go-swagger/go-swagger/cmd/swagger generate client -A netlify -f swagger.yml -t go -c plumbing --with-flatten=full

go.mod

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module github.com/netlify/open-api
2+
3+
go 1.12
4+
5+
require (
6+
contrib.go.opencensus.io/exporter/ocagent v0.4.6 // indirect
7+
github.com/Azure/go-autorest v11.5.0+incompatible
8+
github.com/cenkalti/backoff v2.1.1+incompatible
9+
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
10+
github.com/go-openapi/errors v0.18.0
11+
github.com/go-openapi/inflect v0.18.0 // indirect
12+
github.com/go-openapi/runtime v0.18.0
13+
github.com/go-openapi/strfmt v0.18.0
14+
github.com/go-openapi/swag v0.18.0
15+
github.com/go-openapi/validate v0.18.0
16+
github.com/go-swagger/go-swagger v0.18.0
17+
github.com/gorilla/handlers v1.4.0 // indirect
18+
github.com/jessevdk/go-flags v1.4.0 // indirect
19+
github.com/kr/pretty v0.1.0 // indirect
20+
github.com/kyoh86/richgo v0.3.0 // indirect
21+
github.com/rsc/goversion v1.2.0
22+
github.com/sirupsen/logrus v1.3.0
23+
github.com/spf13/viper v1.3.1 // indirect
24+
github.com/stretchr/testify v1.2.2
25+
github.com/toqueteos/webbrowser v1.1.0 // indirect
26+
go.opencensus.io v0.19.0 // indirect
27+
golang.org/x/net v0.0.0-20190226215741-afe646ca25a4
28+
)

go.sum

Lines changed: 216 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)