-
Notifications
You must be signed in to change notification settings - Fork 56
/
Makefile
105 lines (83 loc) · 2.9 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
DBG ?= 0
VERSION ?= $(shell git describe --always --abbrev=7)
MUTABLE_TAG ?= latest
PROJECT ?= cluster-api-provider-libvirt
ORG_PATH ?= github.com/openshift
REPO_PATH ?= $(ORG_PATH)/$(PROJECT)
IMAGE ?= origin-libvirt-machine-controllers
ifeq ($(DBG),1)
GOGCFLAGS ?= -gcflags=all="-N -l"
endif
.PHONY: all
all: build images check
CONTAINER_RUNTIME ?= podman
NO_DOCKER ?= 1
ifeq ($(NO_DOCKER), 1)
DOCKER_CMD =
IMAGE_BUILD_CMD = imagebuilder
CGO_ENABLED = 1
else
DOCKER_CMD := $(CONTAINER_RUNTIME) run --rm -e CGO_ENABLED=1 -v "$(PWD):/go/src/$(REPO_PATH):Z" -w "/go/src/$(REPO_PATH)" registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.19-openshift-4.13
IMAGE_BUILD_CMD = $(CONTAINER_RUNTIME) build
endif
.PHONY: depend-update
depend-update:
GO111MODULE=on go mod tidy
GO111MODULE=on go mod vendor
.PHONY: generate
generate: gendeepcopy gencode
.PHONY: gencode
encode:
go install $(GOGCFLAGS) -ldflags '-extldflags "-static"' github.com/openshift/cluster-api-provider-libvirt/vendor/github.com/golang/mock/mockgen
go generate ./pkg/... ./cmd/...
.PHONY: gendeepcopy
gendeepcopy:
go build -o $(shell go env GOPATH)/bin/deepcopy-gen "$(REPO_PATH)/vendor/k8s.io/code-generator/cmd/deepcopy-gen"
$(shell go env GOPATH)/bin/deepcopy-gen \
-i ./pkg/apis/libvirtproviderconfig,./pkg/apis/libvirtproviderconfig/v1beta1 \
-O zz_generated.deepcopy \
-h hack/boilerplate.go.txt
.PHONY: build
build: ## build binaries
$(DOCKER_CMD) go build $(GOGCFLAGS) -o bin/machine-controller "$(REPO_PATH)/cmd/manager"
$(DOCKER_CMD) go test $(GOGCFLAGS) -c -o bin/machines.test "$(REPO_PATH)/test/machines"
.PHONY: images
images: ## Create images
$(IMAGE_BUILD_CMD) -t "$(IMAGE):$(VERSION)" -t "$(IMAGE):$(MUTABLE_TAG)" ./
.PHONY: push
push:
$(CONTAINER_RUNTIME) push "$(IMAGE):$(VERSION)"
$(CONTAINER_RUNTIME) push "$(IMAGE):$(MUTABLE_TAG)"
.PHONY: check
check: fmt vet lint test check-pkg ## Check your code
.PHONY: check-pkg
check-pkg:
./hack/verify-actuator-pkg.sh
.PHONY: test
test: # Run unit test
$(DOCKER_CMD) go test -race -cover ./cmd/... ./pkg/cloud/libvirt/client/...
.PHONY: build-e2e
build-e2e:
$(DOCKER_CMD) go test -c -o bin/machines.test "$(REPO_PATH)/test/machines"
.PHONY: test-e2e
test-e2e: images build-e2e e2e-provision ## Run end-to-end test
hack/test-e2e.sh || ($(MAKE) e2e-clean && false)
$(MAKE) e2e-clean
.PHONY: e2e-provision
e2e-provision:
hack/packet-provision.sh install
.PHONY: e2e-clean
e2e-clean:
hack/packet-provision.sh destroy
.PHONY: lint
lint: ## Go lint your code
hack/go-lint.sh -min_confidence 0.3 $(go list -f '{{ .ImportPath }}' ./...)
.PHONY: fmt
fmt: ## Go fmt your code
hack/go-fmt.sh .
.PHONY: vet
vet: ## Apply go vet to all go files
hack/go-vet.sh ./...
.PHONY: help
help:
@grep -E '^[a-zA-Z/0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'