Skip to content

Update go-swagger libraries to the latest version and update to go modules #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ vendor
*node_modules
yarn.lock
dist
.vscode
.gobincache
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
language: go

go:
- "1.10"
- "1.11"

- "1.12"
env:
- GO111MODULE=on
install: make deps
script: make test
notifications:
Expand Down
24 changes: 18 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# CONTRIBUTING

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

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:

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.)

## Spec validation

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

make generate

You may first want to edit swagger.yml to add your field or endpoint definitions.

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

By contributing to Netlify Node Client, you agree that your contributions will be licensed
under its [MIT license](LICENSE).



[godoc-img]: https://godoc.org/github.com/netlify/go-client/?status.svg
[godoc]: https://godoc.org/github.com/netlify/go-client
[goreport-img]: https://goreportcard.com/badge/github.com/netlify/go-client
[goreport]: https://goreportcard.com/report/github.com/netlify/go-client
[git-img]: https://img.shields.io/github/release/netlify/go-client.svg
[git]: https://github.com/netlify/go-client/releases/latest
[gobin]: https://github.com/myitcv/gobin
[modules]: https://github.com/golang/go/wiki/Modules
[open-api]: https://github.com/netlify/open-api
[go-swagger]: https://github.com/go-swagger/go-swagger
[go-modules]: https://github.com/golang/go/wiki/Modules
[swagger]: https://github.com/netlify/open-api/blob/master/swagger.yml

13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
.PHONY: all build deps generate help test validate
CHECK_FILES?=$$(go list ./... | grep -v /vendor/)
SWAGGER_SPEC=swagger.yml

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

all: validate generate build ## Validate the swagger spec, generate the code and build it.
all: deps generate build test ## Validate the swagger spec, generate the code and build it.

build: ## Build the API Go client.
cd ./go && go build ./...
go build ./go/...

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

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

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

validate: ## Check that the swagger spec is valid.
swagger validate swagger.yml
gobin -m -run github.com/go-swagger/go-swagger/cmd/swagger validate $(SWAGGER_SPEC)
3 changes: 3 additions & 0 deletions generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package tools

//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
44 changes: 44 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module github.com/netlify/open-api

go 1.12

require (
github.com/Azure/go-autorest v8.1.0+incompatible
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/cenkalti/backoff v2.1.1+incompatible
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/go-openapi/analysis v0.18.0 // indirect
github.com/go-openapi/errors v0.18.0
github.com/go-openapi/inflect v0.18.0 // indirect
github.com/go-openapi/jsonpointer v0.18.0 // indirect
github.com/go-openapi/jsonreference v0.18.0 // indirect
github.com/go-openapi/loads v0.18.0 // indirect
github.com/go-openapi/runtime v0.18.0
github.com/go-openapi/spec v0.18.0 // indirect
github.com/go-openapi/strfmt v0.18.0
github.com/go-openapi/swag v0.18.0
github.com/go-openapi/validate v0.18.0
github.com/go-swagger/go-swagger v0.18.0
github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gorilla/handlers v1.4.0 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kyoh86/richgo v0.3.0
github.com/kyoh86/xdg v1.0.0 // indirect
github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f // indirect
github.com/mattn/go-isatty v0.0.6 // indirect
github.com/rsc/goversion v1.2.0
github.com/sirupsen/logrus v1.3.0
github.com/spf13/afero v1.2.1 // indirect
github.com/spf13/viper v1.3.1 // indirect
github.com/stretchr/testify v1.3.0
github.com/toqueteos/webbrowser v1.1.0 // indirect
golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b // indirect
golang.org/x/net v0.0.0-20190226215741-afe646ca25a4
golang.org/x/sys v0.0.0-20190226215855-775f8194d0f9 // indirect
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b // indirect
)
Loading