Skip to content

Commit 8ea1da5

Browse files
authored
Merge pull request #149 from netlify/go-modules
Update go-swagger libraries to the latest version and update to go modules
2 parents 6aaaf6f + cbfbcde commit 8ea1da5

File tree

11 files changed

+384
-378
lines changed

11 files changed

+384
-378
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: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# CONTRIBUTING
22

3-
We use [go-swagger](https://github.com/go-swagger/go-swagger) to validate our spec against the 2.0 spec of Open API.
4-
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:
6-
7-
https://github.com/go-swagger/go-swagger/releases/tag/0.18.0
3+
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.)
84

95
## Spec validation
106

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

2319
make generate
24-
20+
2521
You may first want to edit swagger.yml to add your field or endpoint definitions.
2622

2723
## Making PRs
@@ -44,3 +40,19 @@ You may first want to edit swagger.yml to add your field or endpoint definitions
4440

4541
By contributing to Netlify Node Client, you agree that your contributions will be licensed
4642
under its [MIT license](LICENSE).
43+
44+
45+
46+
[godoc-img]: https://godoc.org/github.com/netlify/go-client/?status.svg
47+
[godoc]: https://godoc.org/github.com/netlify/go-client
48+
[goreport-img]: https://goreportcard.com/badge/github.com/netlify/go-client
49+
[goreport]: https://goreportcard.com/report/github.com/netlify/go-client
50+
[git-img]: https://img.shields.io/github/release/netlify/go-client.svg
51+
[git]: https://github.com/netlify/go-client/releases/latest
52+
[gobin]: https://github.com/myitcv/gobin
53+
[modules]: https://github.com/golang/go/wiki/Modules
54+
[open-api]: https://github.com/netlify/open-api
55+
[go-swagger]: https://github.com/go-swagger/go-swagger
56+
[go-modules]: https://github.com/golang/go/wiki/Modules
57+
[swagger]: https://github.com/netlify/open-api/blob/master/swagger.yml
58+

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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module github.com/netlify/open-api
2+
3+
go 1.12
4+
5+
require (
6+
github.com/Azure/go-autorest v8.1.0+incompatible
7+
github.com/BurntSushi/toml v0.3.1 // indirect
8+
github.com/PuerkitoBio/purell v1.1.1 // indirect
9+
github.com/cenkalti/backoff v2.1.1+incompatible
10+
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
11+
github.com/go-openapi/analysis v0.18.0 // indirect
12+
github.com/go-openapi/errors v0.18.0
13+
github.com/go-openapi/inflect v0.18.0 // indirect
14+
github.com/go-openapi/jsonpointer v0.18.0 // indirect
15+
github.com/go-openapi/jsonreference v0.18.0 // indirect
16+
github.com/go-openapi/loads v0.18.0 // indirect
17+
github.com/go-openapi/runtime v0.18.0
18+
github.com/go-openapi/spec v0.18.0 // indirect
19+
github.com/go-openapi/strfmt v0.18.0
20+
github.com/go-openapi/swag v0.18.0
21+
github.com/go-openapi/validate v0.18.0
22+
github.com/go-swagger/go-swagger v0.18.0
23+
github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013 // indirect
24+
github.com/google/uuid v1.1.1 // indirect
25+
github.com/gorilla/handlers v1.4.0 // indirect
26+
github.com/jessevdk/go-flags v1.4.0 // indirect
27+
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
28+
github.com/kr/pretty v0.1.0 // indirect
29+
github.com/kyoh86/richgo v0.3.0
30+
github.com/kyoh86/xdg v1.0.0 // indirect
31+
github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f // indirect
32+
github.com/mattn/go-isatty v0.0.6 // indirect
33+
github.com/rsc/goversion v1.2.0
34+
github.com/sirupsen/logrus v1.3.0
35+
github.com/spf13/afero v1.2.1 // indirect
36+
github.com/spf13/viper v1.3.1 // indirect
37+
github.com/stretchr/testify v1.3.0
38+
github.com/toqueteos/webbrowser v1.1.0 // indirect
39+
golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b // indirect
40+
golang.org/x/net v0.0.0-20190226215741-afe646ca25a4
41+
golang.org/x/sys v0.0.0-20190226215855-775f8194d0f9 // indirect
42+
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect
43+
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b // indirect
44+
)

0 commit comments

Comments
 (0)