-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
176 lines (146 loc) · 5.76 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
.PHONY: all test templates yamls
.FORCE:
GO_CMD ?= go
GO_FMT ?= gofmt
CONTAINER_COMMAND := $(or ${CONTAINER_COMMAND},podman)
IMAGE_BUILD_CMD ?= ${CONTAINER_COMMAND} build
IMAGE_BUILD_EXTRA_OPTS ?=
IMAGE_PUSH_CMD ?= podman push
CONTAINER_RUN_CMD ?= podman run
MDL ?= mdl
K8S_CODE_GENERATOR ?= ../code-generator
VERSION := $(shell git describe --tags --dirty --always)
IMAGE_REGISTRY ?= registry.k8s.io/nfd
IMAGE_TAG_NAME ?= $(VERSION)
IMAGE_EXTRA_TAG_NAMES ?=
IMAGE_NAME := node-feature-discovery
IMAGE_REPO := $(IMAGE_REGISTRY)/$(IMAGE_NAME)
IMAGE_TAG ?= $(IMAGE_REPO):$(IMAGE_TAG_NAME)
IMAGE_EXTRA_TAGS := $(foreach tag,$(IMAGE_EXTRA_TAG_NAMES),$(IMAGE_REPO):$(tag))
K8S_NAMESPACE ?= node-feature-discovery
OPENSHIFT ?=
# We use different mount prefix for local and container builds.
# Take CONTAINER_HOSTMOUNT_PREFIX from HOSTMOUNT_PREFIX if only the latter is specified
ifdef HOSTMOUNT_PREFIX
CONTAINER_HOSTMOUNT_PREFIX := $(HOSTMOUNT_PREFIX)
else
CONTAINER_HOSTMOUNT_PREFIX := /host-
endif
HOSTMOUNT_PREFIX ?= /host-
KUBECONFIG ?=
E2E_TEST_CONFIG ?=
E2E_PULL_IF_NOT_PRESENT ?= false
E2E_TEST_FULL_IMAGE ?= false
E2E_GINKGO_LABEL_FILTER ?=
LDFLAGS = -ldflags "-s -w -X openshift/node-feature-discovery/pkg/version.version=$(VERSION) -X openshift/node-feature-discovery/pkg/utils/hostpath.pathPrefix=$(HOSTMOUNT_PREFIX)"
all: image
build:
@mkdir -p bin
$(GO_CMD) build -v -o bin/ $(LDFLAGS) ./cmd/...
install:
$(GO_CMD) install -v $(LDFLAGS) ./cmd/...
local-image: image
image: yamls
$(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \
--build-arg HOSTMOUNT_PREFIX=$(CONTAINER_HOSTMOUNT_PREFIX) \
-t $(IMAGE_TAG) \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)) \
$(IMAGE_BUILD_EXTRA_OPTS) ./
# clean NFD labels on all nodes
# devel only
deploy-prune:
kubectl apply --validate=false -k deployment/overlays/prune/
kubectl wait --for=condition=complete job -l app=nfd -n node-feature-discovery
kubectl delete -k deployment/overlays/prune/
yamls:
@./hack/kustomize.sh $(K8S_NAMESPACE) $(IMAGE_REPO) $(IMAGE_TAG_NAME)
deploy: yamls
kubectl apply -k .
templates:
@# Need to prepend each line in the sample config with spaces in order to
@# fit correctly in the configmap spec.
@sed s'/^/ /' deployment/components/worker-config/nfd-worker.conf.example > nfd-worker.conf.tmp
@sed s'/^/ /' deployment/components/master-config/nfd-master.conf.example > nfd-master.conf.tmp
@sed s'/^/ /' deployment/components/topology-updater-config/nfd-topology-updater.conf.example > nfd-topology-updater.conf.tmp
@# The sed magic below replaces the block of text between the lines with start and end markers
@start=NFD-MASTER-CONF-START-DO-NOT-REMOVE; \
end=NFD-MASTER-CONF-END-DO-NOT-REMOVE; \
sed -e "/$$start/,/$$end/{ /$$start/{ p; r nfd-master.conf.tmp" \
-e "}; /$$end/p; d }" -i deployment/helm/node-feature-discovery/values.yaml
@start=NFD-WORKER-CONF-START-DO-NOT-REMOVE; \
end=NFD-WORKER-CONF-END-DO-NOT-REMOVE; \
sed -e "/$$start/,/$$end/{ /$$start/{ p; r nfd-worker.conf.tmp" \
-e "}; /$$end/p; d }" -i deployment/helm/node-feature-discovery/values.yaml
@start=NFD-TOPOLOGY-UPDATER-CONF-START-DO-NOT-REMOVE; \
end=NFD-TOPOLOGY-UPDATER-CONF-END-DO-NOT-REMOVE; \
sed -e "/$$start/,/$$end/{ /$$start/{ p; r nfd-topology-updater.conf.tmp" \
-e "}; /$$end/p; d }" -i deployment/helm/node-feature-discovery/values.yaml
@rm nfd-master.conf.tmp
@rm nfd-worker.conf.tmp
generate:
go mod vendor
go generate ./cmd/... ./pkg/... ./source/...
rm -rf vendor/
controller-gen object crd output:crd:stdout paths=./pkg/apis/... > deployment/base/nfd-crds/nodefeaturerule-crd.yaml
cp deployment/base/nfd-crds/nodefeaturerule-crd.yaml deployment/helm/node-feature-discovery/manifests/
rm -rf sigs.k8s.io
$(K8S_CODE_GENERATOR)/generate-groups.sh client,informer,lister \
openshift/node-feature-discovery/pkg/generated \
openshift/node-feature-discovery/pkg/apis \
"nfd:v1alpha1" --output-base=. \
--go-header-file hack/boilerplate.go.txt
rm -rf pkg/generated
mv openshift/node-feature-discovery/pkg/generated pkg/
rm -rf sigs.k8s.io
verify: verify-gofmt
verify-gofmt:
ifeq (, $(GOFMT_CHECK))
@echo "verify-gofmt: OK"
else
@echo "verify-gofmt: ERROR: gofmt failed on the following files:"
@echo "$(GOFMT_CHECK)"
@echo ""
@echo "For details, run: gofmt -d -s $(GOFMT_CHECK)"
@echo ""
@exit 1
endif
ci-lint:
golangci-lint run --timeout 10m
lint:
golint -set_exit_status ./...
mdlint:
${CONTAINER_RUN_CMD} \
--rm \
--volume "${PWD}:/workdir:ro,z" \
--workdir /workdir \
ruby:slim \
/workdir/scripts/test-infra/mdlint.sh
helm-lint:
helm lint --strict deployment/helm/node-feature-discovery/
test:
$(GO_CMD) test -covermode=atomic -coverprofile=coverage.out ./cmd/... ./pkg/... ./source/...
e2e-test:
@if [ -z ${KUBECONFIG} ]; then echo "[ERR] KUBECONFIG missing, must be defined"; exit 1; fi
$(GO_CMD) test -timeout=1h -v ./test/e2e/ -args \
-nfd.repo=$(IMAGE_REPO) -nfd.tag=$(IMAGE_TAG_NAME) \
-kubeconfig=$(KUBECONFIG) \
-nfd.e2e-config=$(E2E_TEST_CONFIG) \
-nfd.pull-if-not-present=$(E2E_PULL_IF_NOT_PRESENT) \
-ginkgo.focus="\[k8s-sigs\/node-feature-discovery\]" \
-ginkgo.label-filter=$(E2E_GINKGO_LABEL_FILTER) \
-ginkgo.v \
$(if $(OPENSHIFT),-nfd.openshift,)
if [ "$(E2E_TEST_FULL_IMAGE)" = "true" ]; then \
$(GO_CMD) test -timeout=1h -v ./test/e2e/ -args \
-nfd.repo=$(IMAGE_REPO) -nfd.tag=$(IMAGE_TAG_NAME)-full \
-kubeconfig=$(KUBECONFIG) \
-nfd.e2e-config=$(E2E_TEST_CONFIG) \
-nfd.pull-if-not-present=$(E2E_PULL_IF_NOT_PRESENT) \
-ginkgo.focus="\[k8s-sigs\/node-feature-discovery\]" \
-ginkgo.label-filter=$(E2E_GINKGO_LABEL_FILTER) \
-ginkgo.v \
$(if $(OPENSHIFT),-nfd.openshift,); \
fi
local-image-push: push
push:
$(IMAGE_PUSH_CMD) $(IMAGE_TAG)