forked from k8snetworkplumbingwg/kubemacpool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (109 loc) · 3.12 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
# Image URL to use all building/pushing image targets
REGISTRY ?= quay.io
REPO ?= kubevirt
IMAGE_TAG ?= latest
IMAGE_GIT_TAG ?= $(shell git describe --abbrev=8 --tags)
IMG ?= $(REPO)/kubemacpool
BIN_DIR = $(CURDIR)/build/_output/bin/
export GOFLAGS=-mod=vendor
export GO111MODULE=on
export GOROOT=$(BIN_DIR)/go/
export GOBIN=$(GOROOT)/bin/
export PATH := $(GOBIN):$(PATH)
GOFMT := $(GOBIN)/gofmt
export GO := $(GOBIN)/go
KUSTOMIZE := $(GOBIN)/kustomize
CONTROLLER_GEN := $(GOBIN)/controller-gen
DEEPCOPY_GEN := $(GOBIN)/deepcopy-gen
GOVERALLS := $(GOBIN)/goveralls
export KUBECTL ?= cluster/kubectl.sh
all: generate
$(GO):
hack/install-go.sh $(BIN_DIR) > /dev/null
$(KUSTOMIZE): go.mod
$(MAKE) tools
$(CONTROLLER_GEN): go.mod
$(MAKE) tools
$(DEEPCOPY_GEN): go.mod
$(MAKE) tools
$(GOVERALLS): go.mod
$(MAKE) tools
$(GOFMT): $(GO)
# Run tests
test: $(GO)
$(GO) test ./pkg/... ./cmd/... -coverprofile cover.out
functest: $(GO)
GO=$(GO) ./hack/functest.sh
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: generate-deploy
$(KUBECTL) apply -f config/test/kubemacpool.yaml
deploy-test: generate-test
$(KUBECTL) apply -f config/test/kubemacpool.yaml
generate-deploy: $(KUSTOMIZE) manifests
$(KUSTOMIZE) build config/release > config/release/kubemacpool.yaml
generate-test: $(KUSTOMIZE) manifests
$(KUSTOMIZE) build config/test > config/test/kubemacpool.yaml
generate-external: $(KUSTOMIZE) manifests
cp -r config/test config/external
cd config/external && \
$(KUSTOMIZE) edit set image quay.io/kubevirt/kubemacpool=$(REGISTRY)/$(IMG)
$(KUSTOMIZE) build config/external > config/external/kubemacpool.yaml
# Generate manifests e.g. CRD, RBAC etc.
manifests: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) crd rbac:roleName=kubemacpool paths=./pkg/... output:crd:dir=config/ output:stdout
# Run go fmt against code
fmt: $(GOFMT)
$(GOFMT) -d pkg/ cmd/ tests/
# Run go vet against code
vet: $(GO)
$(GO) vet ./pkg/... ./cmd/... ./tests/...
# Generate code
generate-go: $(DEEPCOPY_GEN) fmt vet manifests
PATH=$(GOBIN):$(PATH) $(GO) generate ./pkg/... ./cmd/...
generate: generate-go generate-deploy generate-test generate-external
check: $(KUSTOMIZE)
./hack/check.sh
manager: $(GO)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o $(BIN_DIR)/manager github.com/k8snetworkplumbingwg/kubemacpool/cmd/manager
# Build the docker image
container: manager
docker build build/ -t ${REGISTRY}/${IMG}:${IMAGE_TAG}
# Push the docker image
docker-push:
docker push ${REGISTRY}/${IMG}:${IMAGE_TAG}
docker tag ${REGISTRY}/${IMG}:${IMAGE_TAG} ${REGISTRY}/${IMG}:${IMAGE_GIT_TAG}
docker push ${REGISTRY}/${IMG}:${IMAGE_GIT_TAG}
cluster-up:
./cluster/up.sh
cluster-down:
./cluster/down.sh
cluster-sync:
./cluster/sync.sh
cluster-clean:
./cluster/clean.sh
vendor: $(GO)
$(GO) mod tidy
$(GO) mod vendor
tools: $(GO)
GO=$(GO) GOBIN=$(GOBIN) ./hack/install-tools.sh $$(pwd)/tools.go
.PHONY: \
vendor \
test \
deploy \
deploy-test \
generate \
generate-go \
generate-deploy \
generate-test \
manifests \
fmt \
vet \
goveralls \
check \
manager \
container \
push \
cluster-up \
cluster-down \
cluster-sync \
tools