-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
117 lines (90 loc) · 4.19 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
# Allows overriding of the container runtime
CONTAINER_RUNTIME ?= docker
# Allows overriding of the registry to push the generated image to
REGISTRY ?= quay.io
# Allows overriding of the repository to push the image to
REPOSITORY ?= openshift
# Allows overriding of the tag to generate for the image
TAG ?= latest
# when non-empty it enables "--refreshresource=false" deployment
DEPLOY_MODE ?=
# amount of pods the daemonset will produce before starting end-to-end tests
DAEMONSET_PODS ?= 3
# end-to-end test suite name
TEST_SUITE ?= normal
# ent-to-end test timeout
TEST_TIMEOUT ?= 30m
TARGET_GOOS ?= $(shell go env GOOS)
TARGET_GOARCH ?= $(shell go env GOARCH)
# For golang 1.16, race detection is only widely supported for amd64 architectures (linux, windows, darwin, and freebsd).
# Race detection for ARM is only currently supported for linux (no darwin or windows support yet).
# s390x and ppc64le do not support race detection at present.
ifeq ($(TARGET_GOARCH), amd64)
RACE = -race
endif
GOFLAGS ?= -a -mod=vendor -buildvcs=false $(RACE)
.DEFAULT_GOAL := help
all: clean verify build test
.PHONY: all
test: ## Run unit tests. Example: make test
env GOOS=$(TARGET_GOOS) GOARCH=$(TARGET_GOARCH) go test $(GOFLAGS) -count 1 ./cmd/... ./pkg/...
.PHONY: test
config: ## Overwrites the configuration ConfigMap with local settings
./hack/configmap.sh $(DEPLOY_MODE)
.PHONY: config
test-e2e-no-deploy:
TEST_SUITE=$(TEST_SUITE) TEST_TIMEOUT=$(TEST_TIMEOUT) DAEMONSET_PODS=$(DAEMONSET_PODS) ./hack/test-e2e.sh
.PHONY: test-e2e-no-deploy
test-e2e: test-e2e-no-deploy
test-e2e-no-refreshresources: TEST_SUITE = "norefresh"
test-e2e-no-refreshresources: test-e2e
test-e2e-slow: TEST_SUITE = "slow"
test-e2e-slow: test-e2e
test-e2e-disruptive: TEST_SUITE = "disruptive"
test-e2e-disruptive: test-e2e
verify: ## Run verifications. Example: make verify
go vet ./cmd/... ./pkg/... ./test/...
gofmt -w ./cmd/ ./pkg/ ./test/
hack/verify-imports.sh
.PHONY: verify
build: ## Build the executable. Example: make build
env GOOS=$(TARGET_GOOS) GOARCH=$(TARGET_GOARCH) go build $(GOFLAGS) -o _output/csi-driver-shared-resource ./cmd/csidriver
.PHONY: build
build-webhook: ## Build the executable. Example: make build
env GOOS=$(TARGET_GOOS) GOARCH=$(TARGET_GOARCH) go build $(GOFLAGS) -o _output/csi-driver-shared-resource-webhook ./cmd/webhook
.PHONY: build-webhook
build-image: ## Build the images and push them to the remote registry. Example: make build-image
rm -rf _output
$(CONTAINER_RUNTIME) build -f Dockerfile -t $(REGISTRY)/$(REPOSITORY)/origin-csi-driver-shared-resource:$(TAG) .
$(CONTAINER_RUNTIME) push $(REGISTRY)/$(REPOSITORY)/origin-csi-driver-shared-resource:$(TAG)
.PHONY: build-image
build-mustgather-image: ## Build the customer must gather images and push them to the remote registry. Example: make build-mustgather-image
rm -rf _output
$(CONTAINER_RUNTIME) build -f Dockerfile.mustgather -t $(REGISTRY)/$(REPOSITORY)/origin-csi-driver-shared-resource-mustgather:$(TAG) .
$(CONTAINER_RUNTIME) push $(REGISTRY)/$(REPOSITORY)/origin-csi-driver-shared-resource-mustgather:$(TAG)
.PHONY: build-mustgather-image
build-webhook-image: ## Build the customer must gather images and push them to the remote registry. Example: make build-mustgather-image
rm -rf _output
$(CONTAINER_RUNTIME) build -f Dockerfile.webhook -t $(REGISTRY)/$(REPOSITORY)/origin-csi-driver-shared-resource-webhook:$(TAG) .
$(CONTAINER_RUNTIME) push $(REGISTRY)/$(REPOSITORY)/origin-csi-driver-shared-resource-webhook:$(TAG)
.PHONY: build-webhook-image
clean: ## Clean up the workspace. Example: make clean
rm -rf _output
.PHONY: clean
vendor: ## Vendor Go dependencies. Example: make vendor
go mod tidy
go mod vendor
.PHONY: vendor
imports: ## Organize imports in go files using goio. Example: make imports
go run ./vendor/github.com/go-imports-organizer/goio
.PHONY: imports
verify-imports: ## Run import verifications. Example: make verify-imports
hack/verify-imports.sh
.PHONY: verify-imports
help: ## Print this help. Example: make help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: help
.PHONY: smoke
smoke:
@echo "Testing csi driver shares resource on openshift"
@./hack/smoke-test.sh