-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
105 lines (87 loc) · 3.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
export GO111MODULE := on
ROOTDIR := $(shell pwd)
VENDORDIR := $(ROOTDIR)/vendor
QUIET=@
VERIFYARGS ?=
GOOS ?=
GOOS := $(if $(GOOS),$(GOOS),linux)
GOARCH ?=
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GOENV := CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GO_BUILD := $(GO) build -trimpath
pkgs = $(shell $(GO) list ./... | grep -v vendor)
help:
> @echo "Xene - Makefile"
> @echo ""
> @echo "Available make targets:"
> @echo ""
> @echo "* build: Run build script to build xene binary."
> @echo "* check-lint: Check if the formatting is correct for the go code, using golangci lint."
> @echo "* fix-lint: Fixes lint errors generated by golangci lint"
> @echo "* format: Format go code in the repository, run this before committing anything."
> @echo "* govet: Run govet on the code to check for any mistakes."
> @echo "* docs: Build docs site using mkdocs in site/ directory"
> @echo "* check-api-docs: checks the integrity of API docs for xene."
> @echo "* proto: Generate protobuf client and server code for definitions in pkg/proto/."
> @echo "* apiserver-gen: Generate swagger client, models and docs for apiserver."
> @echo "* docker: Create docker image for xene"
> @echo ""
# Build status
build:
> @echo "Building xene..."
> @./contrib/scripts/build.sh
# Check go formatting
check-lint:
> @echo "[*] Checking for formatting and linting errors"
> @./contrib/scripts/check-fmt.sh
> @golangci-lint run ./...
fix-lint:
> @echo "[*] Fixing lint errors using golangci-lint"
> @golangci-lint run ./... --fix
# Format code using gofmt
format:
> @echo "[*] Formatting code"
> @$(GO) fmt $(pkgs)
# Vet code using go vet
govet:
> @echo "[*] Vetting code, checking for mistakes"
> @$(GO) vet $(pkgs)
docs:
> @echo "[*] Building docs.."
> @rm -rf site/
> @mkdocs build
> @python contrib/scripts/swagger-docs.py
check-api-docs:
> @echo "[*] Checking API docs integrity"
> @./contrib/scripts/check-api-docs.sh
proto:
> @echo "[*] Generating proto definitions"
> @protoc -I pkg/proto pkg/proto/agent.proto --go_out=plugins=grpc:pkg/proto
apiserver-gen:
> @echo "[*] Generating swagger documentation"
> @swag init --generatedTime=false --dir pkg/apiserver/ --output pkg/apiserver/docs/
> @echo "[*] Generating swagger apiserver clients"
> @cd pkg/apiserver
> @swagger generate client -f docs/swagger.yaml
docker:
> @echo "[*] Starting to build docker image for xene"
> @docker build . -f contrib/docker/Dockerfile -t fristonio/xene
> @docker build . -f contrib/docker/Dockerfile.agent -t fristonio/xene-agent
docker-compose-up:
> @echo "[*] Starting docker compose setup for xene"
> @docker-compose -f contrib/docker/docker-compose.yml up
docker-compose-down:
> @echo "[*] Shutting down docker compose setup for xene"
> @docker-compose -f contrib/docker/docker-compose.yml down
.PHONY: build format check-lint fix-lint govet help docs proto apiserver-gen docker docker-compose-up docker-compose-down