-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,907 additions
and
1,995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
711 changes: 290 additions & 421 deletions
711
internal/templates/grpcwithgw/grpc_service_with_gw.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,70 @@ | ||
export VERSION ?= dev | ||
export VERSION ?= ${GIT_COMMIT} | ||
export GIT_COMMIT ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo unknown) | ||
export LD_FLAGS = -X "main.gitCommit=$(GIT_COMMIT)" -X "main.version=$(VERSION)" | ||
|
||
export GOBIN = $(abspath .)/.tools/bin | ||
export PATH := $(GOBIN):$(PATH) | ||
export GO111MODULE=on | ||
export PATH := $(GOBIN):$(abspath .)/bin:$(PATH) | ||
export CGO_ENABLED=0 | ||
|
||
export V = 0 | ||
export Q = $(if $(filter 1,$V),,@) | ||
export M = $(shell printf "\033[34;1m▶\033[0m") | ||
|
||
export CC = go build -ldflags '$(LD_FLAGS)' | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: deps | ||
deps: | ||
go get -d -v ./... | ||
$(info $(M) fetching deps …) | ||
$Q go get -d -v ./... | ||
$Q go mod tidy | ||
|
||
.PHONY: install-deptools | ||
install-deptools: deps ## install dependent go tools | ||
$Q sh ./scripts/download_protoc.sh && \ | ||
go install golang.org/x/lint/golint/... && \ | ||
go install github.com/cnative/servicebuilder && \ | ||
go install github.com/golang/protobuf/protoc-gen-go && \ | ||
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway && \ | ||
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \ | ||
; $(info $(M) installing protoc, golint, protoc-gen-go, protoc-gen-grpc-gateway, protoc-gen-swagger) | ||
$(info $(M) installing necessary tools …) | ||
$Q sh ./scripts/install_tools_check.sh | ||
|
||
.PHONY: gen | ||
gen: | ||
$Q go generate ./pkg/api ./internal/state ; $(info $(M) generating grpc api server handler, gateway, swagger and metrics & trace store …) | ||
|
||
gen: | ||
$Q go generate ./pkg/api ./pkg/state ; $(info $(M) generating grpc api server handler, gateway, swagger and metrics & trace store …) | ||
.PHONY: fmt | ||
fmt: ## run go fmt on all source files | ||
$(info $(M) formatting …) | ||
$Q goimports -w -local {{ .ModuleName }} ./cmd ./pkg ./internal | ||
|
||
fmt: ; $(info $(M) formatting …) @ ## run go fmt on all source files | ||
@go fmt ./... | ||
.PHONY: vet | ||
vet: ## run go vet on all source files | ||
$(info $(M) vetting …) | ||
$Q go vet ./... | ||
|
||
vet: ; $(info $(M) vetting …) @ ## run go vet on all source files | ||
@go vet ./... | ||
.PHONY: lint | ||
lint: ## run golint | ||
$(info $(M) linting …) | ||
$Q ./.tools/bin/golangci-lint --verbose run ./... --timeout=5m --modules-download-mode=vendor | ||
|
||
lint: ; $(info $(M) linting …) @ ## run golint | ||
@golint ./... | ||
.PHONY: build | ||
build: gen fmt vet ## build service | ||
$(info $(M) building executable …) | ||
$Q $(CC) -o bin/{{ .Name }} ./cmd | ||
|
||
build: gen fmt vet lint ## build service | ||
$Q go build -ldflags '$(LD_FLAGS)' -o bin/{{ .Name }} ./ ; $(info $(M) building executable …) | ||
.PHONY: test | ||
test: ## run go tests with race detector | ||
$(info $(M) testing …) | ||
$Q go test $(GO_TEST_FLAGS) $(shell go list ./...) | ||
|
||
.PHONY: build-image | ||
build-image: ## build container image using docker | ||
$Q docker build --build-arg 'LD_FLAGS=$(LD_FLAGS)' -t {{ .ImageName }}:$(VERSION) . ; $(info $(M) building docker image …) | ||
|
||
.PHONY: push-image | ||
push-image: build-image ## build and publish container image using docker | ||
$Q docker push {{ .ImageName }}:$(VERSION) ; $(info $(M) pushing docker image `…) | ||
|
||
.PHONY: clean | ||
clean: ; $(info $(M) cleaning …) @ ## cleanup everything | ||
@rm -rf bin | ||
@rm -rf test/tests.* test/coverage.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.