-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
156 lines (124 loc) · 3.78 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
GOPATH ?= $(HOME)/go
GOBIN ?= $(GOPATH)/bin
GOIMPORTS = $(GOBIN)/goimports
CONTROLLERGEN = $(GOBIN)/controller-gen
IMG ?= tackle2-hub:latest
HUB_BASE_URL ?= http://localhost:8080
PKG = ./addon/... \
./api/... \
./assessment/... \
./auth/... \
./binding/... \
./controller/... \
./cmd/... \
./database/... \
./encryption/... \
./importer/... \
./k8s/... \
./metrics/... \
./migration/... \
./model/... \
./nas/... \
./reaper/... \
./seed/... \
./settings/... \
./tar/... \
./task/... \
./test/... \
./tracker/...
PKGDIR = $(subst /...,,$(PKG))
BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd
# Build ALL commands.
cmd: hub addon
# Format the code.
fmt: $(GOIMPORTS)
$(GOIMPORTS) -w $(PKGDIR)
# Run go vet against code
vet:
go vet $(PKG)
# Build hub
hub: generate fmt vet
go build $(BUILD)
# Build image
docker-build:
docker build -t $(IMG) .
podman-build:
podman build -t $(IMG) .
# Build manager binary with compiler optimizations disabled
debug: generate fmt vet
go build -gcflags=all="-N -l" $(BUILD)
docker: vet
go build $(BUILD)
# Run against the configured Kubernetes cluster in ~/.kube/config
run: fmt vet
go run ./cmd/main.go
run-addon:
go run ./hack/cmd/addon/main.go
# Generate manifests e.g. CRD, Webhooks
manifests: $(CONTROLLERGEN)
$(CONTROLLERGEN) $(CRD_OPTIONS) \
crd rbac:roleName=manager-role \
paths="./..." output:crd:artifacts:config=generated/crd/bases output:crd:dir=generated/crd
# Generate code
generate: $(CONTROLLERGEN)
$(CONTROLLERGEN) object:headerFile="./generated/boilerplate" paths="./..."
# Ensure controller-gen installed.
$(CONTROLLERGEN):
go install sigs.k8s.io/controller-tools/cmd/[email protected]
# Ensure goimports installed.
$(GOIMPORTS):
go install golang.org/x/tools/cmd/[email protected]
# Build SAMPLE ADDON
addon: fmt vet
go build -o bin/addon github.com/konveyor/tackle2-hub/hack/cmd/addon
docs: docs-html docs-openapi3 docs-binding
# Build Swagger API spec into ./docs directory
docs-swagger:
$(GOBIN)/swag init --parseDependency --parseInternal --parseDepth 1 -g pkg.go --dir api,assessment
# Build OpenAPI 3.0 docs
docs-openapi3: docs-swagger
curl -X POST -H "Content-Type: application/json" -d @docs/swagger.json https://converter.swagger.io/api/convert | jq > docs/openapi3.json
# Build HTML docs from Swagger API spec
docs-html: docs-openapi3
redoc-cli bundle -o docs/index.html docs/openapi3.json
# Build binding doc.
docs-binding:
go doc --all addon > docs/binding.txt
.PHONY: start-minikube
START_MINIKUBE_SH = ./bin/start-minikube.sh
start-minikube:
ifeq (,$(wildcard $(START_MINIKUBE_SH)))
@{ \
set -e ;\
mkdir -p $(dir $(START_MINIKUBE_SH)) ;\
curl -sSLo $(START_MINIKUBE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/start-minikube.sh ;\
chmod +x $(START_MINIKUBE_SH) ;\
}
endif
$(START_MINIKUBE_SH);
.PHONY: install-tackle
INSTALL_TACKLE_SH = ./bin/install-tackle.sh
install-tackle:
ifeq (,$(wildcard $(INSTALL_TACKLE_SH)))
@{ \
set -e ;\
mkdir -p $(dir $(INSTALL_TACKLE_SH)) ;\
curl -sSLo $(INSTALL_TACKLE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/install-tackle.sh ;\
chmod +x $(INSTALL_TACKLE_SH) ;\
}
endif
$(INSTALL_TACKLE_SH);
# Run test targets always (not producing test dirs there).
.PHONY: test test-api test-integration migration
# Run unit tests (all tests outside /test directory).
test:
go test -count=1 -v $(shell go list ./... | grep -v "hub/test")
test-db:
go test -count=1 -timeout=6h -v ./database...
# Run Hub REST API tests.
test-api:
HUB_BASE_URL=$(HUB_BASE_URL) go test -count=1 -p=1 -v -failfast ./test/api/...
# Run Hub test suite.
test-all: test-unit test-api
migration:
hack/next-migration.sh