-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
105 lines (83 loc) · 2.57 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
COMMONENVVAR = GOOS=linux GOARCH=amd64
BUILDENVVAR = CGO_ENABLED=0
RUNTIME ?= podman
REPOOWNER ?= k8stopologyawareschedwg
IMAGENAME ?= sample-device-plugin
IMAGENAME_WORKLOAD ?= sample-device-workload
IMAGETAG ?= latest
SAMPLE_DEVICE_PLUGIN_CONTAINER_IMAGE ?= quay.io/${REPOOWNER}/${IMAGENAME}:${IMAGETAG}
SAMPLE_DEVICE_WORKLOAD_CONTAINER_IMAGE ?= quay.io/${REPOOWNER}/${IMAGENAME_WORKLOAD}:${IMAGETAG}
KUSTOMIZE_DEPLOY_DIR ?= default
.PHONY: all
all: build
.PHONY: build
build: gofmt
$(COMMONENVVAR) $(BUILDENVVAR) go build -ldflags '-w' -o ./bin/deviceplugin ./cmd/deviceplugin
.PHONY: gofmt
gofmt:
@echo "Running gofmt"
gofmt -s -w `find . -path ./vendor -prune -o -type f -name '*.go' -print`
.PHONY: govet
govet:
@echo "Running go vet"
go vet ./cmd/... ./pkg/...
outdir:
@mkdir -p _out || :
.PHONY: image
image: build
@echo "building image"
$(RUNTIME) build -f images/Dockerfile -t $(SAMPLE_DEVICE_PLUGIN_CONTAINER_IMAGE) .
.PHONY: image-workload
image-workload:
@echo "building image for sample workload"
$(RUNTIME) build -f images/workload/Dockerfile -t $(SAMPLE_DEVICE_WORKLOAD_CONTAINER_IMAGE) images/workload
.PHONY: unit-tests
unit-tests:
@echo "running unit tests"
go test -v ./cmd/... ./pkg/...
.PHONY: push
push: image
@echo "pushing image"
$(RUNTIME) push $(SAMPLE_DEVICE_PLUGIN_CONTAINER_IMAGE)
.PHONY: push-workload
push-workload: image-workload
@echo "pushing image for sample workload"
$(RUNTIME) push $(SAMPLE_DEVICE_WORKLOAD_CONTAINER_IMAGE)
.PHONY: deploy
deploy:
@echo "Deploying device plugins"
kubectl apply -k deployment/overlays/$(KUSTOMIZE_DEPLOY_DIR)
.PHONY: undeploy
undeploy:
@echo "Removing device plugins"
kubectl delete -k deployment/overlays/$(KUSTOMIZE_DEPLOY_DIR)
.PHONY: build-e2e
build-e2e: outdir
@echo "Building E2E tests"
go test -v -c -o _out/device-plugin-e2e.test ./test/e2e/...
.PHONY: e2e-test
e2e-test: build-e2e
@echo "Running E2E tests"
_out/device-plugin-e2e.test -ginkgo.v
.PHONY: test-both
test-both:
kubectl create -f manifests/test-both-success.yaml
.PHONY: deploy-A
deploy-A:
@echo "Deploying device plugin A"
kubectl apply -k deployment/overlays/$(KUSTOMIZE_DEPLOY_DIR)/devicepluginA
.PHONY: test-A
test-A:
kubectl create -f manifests/test-deviceA.yaml
.PHONY: deploy-B
deploy-B:
@echo "Deploying device plugin B"
kubectl apply -k deployment/overlays/$(KUSTOMIZE_DEPLOY_DIR)/devicepluginB
.PHONY: test-B
test-B:
kubectl create -f manifests/test-deviceB.yaml
clean-binaries:
rm -f ./bin/deviceplugin
clean: clean-binaries
kubectl delete -f manifests/devicepluginA-ds.yaml
kubectl delete -f manifests/devicepluginB-ds.yaml