forked from openshift/hive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (102 loc) · 3.13 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
BINDIR = bin
SRC_DIRS = pkg contrib
GOFILES = $(shell find $(SRC_DIRS) -name '*.go')
VERIFY_IMPORTS_CONFIG = build/verify-imports/import-rules.yaml
DOCKER_CMD ?= docker
# Image URL to use all building/pushing image targets
IMG ?= hive-controller:latest
all: fmt vet test build
# Run tests
.PHONY: test
test: generate fmt vet manifests
go test ./pkg/... ./cmd/... ./contrib/... -coverprofile cover.out
test-integration: generate
go test ./test/integration/... -coverprofile cover.out
# Builds all of hive's binaries (including utils).
.PHONY: build
build: manager hiveutil
# Build manager binary
manager: generate
go build -o bin/manager github.com/openshift/hive/cmd/manager
# Build hiveutil binary
hiveutil: generate
go build -o bin/hiveutil github.com/openshift/hive/contrib/cmd/hiveutil
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run
run: generate fmt vet
go run ./cmd/manager/main.go --log-level=debug
# Install CRDs into a cluster
.PHONY: install
install: manifests
kubectl apply -f config/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: manifests docker-build
kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f -
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy-sd-dev
deploy-sd-dev: manifests
kubectl apply -f config/crds
kustomize build config/overlays/sd-dev | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
# Run go fmt against code
.PHONY: fmt
fmt:
gofmt -w -s $(SRC_DIRS)
# Run go vet against code
.PHONY: vet
vet:
go vet ./pkg/... ./cmd/... ./contrib/...
# Run verification tests
.PHONY: verify
verify: verify-imports verify-gofmt verify-lint verify-go-vet
# Check import naming
.PHONY: verify-imports
verify-imports: hiveutil
@echo "Verifying import naming"
@sh -c \
'for file in $(GOFILES) ; do \
$(BINDIR)/hiveutil verify-imports -c $(VERIFY_IMPORTS_CONFIG) $$file || exit 1 ; \
done'
# Check import naming
.PHONY: verify-lint
verify-lint:
@echo Verifying golint
@sh -c \
'for file in $(GOFILES) ; do \
golint --set_exit_status $$file || exit 1 ; \
done'
.PHONY: verify-gofmt
verify-gofmt:
@echo Verifying gofmt
@gofmt -l -s $(SRC_DIRS)>.out 2>&1 || true
@[ ! -s .out ] || \
(echo && echo "*** Please run 'make fmt' in order to fix the following:" && \
cat .out && echo && rm .out && false)
@rm .out
.PHONY: verify-go-vet
verify-go-vet: generate
@echo Verifying go vet
@go vet ./cmd/... ./contrib/... $(go list ./pkg/... | grep -v _generated)
# Generate code
.PHONY: generate
generate:
go generate ./pkg/... ./cmd/...
# Build the docker image
.PHONY: docker-build
docker-build: manager hiveutil
$(eval build_path := ./build/hive)
$(eval tmp_build_path := "$(build_path)/tmp")
mkdir -p $(tmp_build_path)
cp $(build_path)/Dockerfile $(tmp_build_path)
cp ./bin/* $(tmp_build_path)
$(DOCKER_CMD) build -t ${IMG} $(tmp_build_path)
rm -rf $(tmp_build_path)
# Push the docker image
.PHONY: docker-push
docker-push:
$(DOCKER_CMD) push ${IMG}