forked from k8snetworkplumbingwg/kubemacpool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (68 loc) · 2.5 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
# Image URL to use all building/pushing image targets
REGISTRY ?= quay.io
IMAGE_TAG ?= latest
IMG ?= kubevirt/kubemacpool
DOCKER_BUILDER_LOCATION=hack/docker-image
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
GO := $(GOBIN)/go
export KUBECTL ?= cluster/kubectl.sh
all: generate generate-deploy generate-test
$(GO):
hack/install-go.sh $(BIN_DIR) > /dev/null
$(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: manifests
kustomize build config/release > config/release/kubemacpool.yaml
generate-test: manifests
kustomize build config/test > config/test/kubemacpool.yaml
# Generate manifests e.g. CRD, RBAC etc.
manifests: $(GO)
$(GO) run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go 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) vet ./pkg/... ./cmd/... ./tests/...
# Generate code
generate: fmt vet manifests
go generate ./pkg/... ./cmd/...
goveralls:
./hack/goveralls.sh
docker-goveralls: docker-builder docker-test
DOCKER_BASE_IMAGE=${REGISTRY}/${IMG}:kubemacpool_builder ./hack/run.sh goveralls
docker-generate: docker-builder
DOCKER_BASE_IMAGE=${REGISTRY}/${IMG}:kubemacpool_builder ./hack/run.sh
# Build the docker image
docker-build: docker-builder
docker build . -t ${REGISTRY}/${IMG}:${IMAGE_TAG} --build-arg GO_VERSION=1.12.12
# Build the docker builder image
docker-builder:
docker build ${DOCKER_BUILDER_LOCATION} -t ${REGISTRY}/${IMG}:kubemacpool_builder --build-arg GO_VERSION=1.12.12
# Push the docker image
docker-push:
docker push ${REGISTRY}/${IMG}:${IMAGE_TAG}
cluster-up:
./cluster/up.sh
cluster-down:
./cluster/down.sh
cluster-sync:
./cluster/sync.sh
tools-vendoring: $(GO)
./hack/vendor-tools.sh $$(pwd)/tools.go
.PHONY: test deploy deploy-test generate-deploy generate-test manifests fmt vet generate goveralls docker-goveralls docker-test docker-build docker-push cluster-up cluster-down cluster-sync tools-vendoring docker-build-base-image