forked from openshift/cluster-node-tuning-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
139 lines (117 loc) · 4.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
PACKAGE=github.com/openshift/cluster-node-tuning-operator
PACKAGE_BIN=$(lastword $(subst /, ,$(PACKAGE)))
PACKAGE_MAIN=$(PACKAGE)/cmd/$(PACKAGE_BIN)
# Build-specific variables
OUT_DIR=_output
GOBINDATA_BIN=$(OUT_DIR)/go-bindata
BINDATA=pkg/manifests/bindata.go
ASSETS=$(shell find assets -name \*.yaml)
GO=GOOS=linux GO111MODULE=on GOFLAGS=-mod=vendor go
GO_BUILD_RECIPE=$(GO) build -o $(OUT_DIR)/$(PACKAGE_BIN) -ldflags '-X $(PACKAGE)/version.Version=$(REV)' $(PACKAGE_MAIN)
GOFMT_CHECK=$(shell find . -not \( \( -wholename './.*' -o -wholename '*/vendor/*' \) -prune \) -name '*.go' | sort -u | xargs gofmt -s -l)
REV=$(shell git describe --long --tags --match='v*' --always --dirty)
# Upstream tuned daemon variables
TUNED_REPO:=https://github.com/redhat-performance/tuned.git
TUNED_COMMIT:=bcbf2a54899d73605aaa7318b6578066de2155f2
TUNED_DIR:=daemon
# API-related variables
API_TYPES_DIR:=pkg/apis/tuned/v1
API_TYPES:=$(wildcard $(API_TYPES_DIR)/*_types.go)
API_ZZ_GENERATED:=zz_generated.deepcopy
API_TYPES_GENERATED:=$(API_TYPES_DIR)/$(API_ZZ_GENERATED).go
API_GO_HEADER_FILE:=pkg/apis/header.go.txt
# Container image-related variables
IMAGE_BUILD_CMD=podman build --no-cache
IMAGE_PUSH_CMD=podman push
DOCKERFILE=Dockerfile
REGISTRY=quay.io
ORG=openshift
TAG=$(shell git rev-parse --abbrev-ref HEAD)
IMAGE=$(REGISTRY)/$(ORG)/origin-cluster-node-tuning-operator:$(TAG)
all: build
# Do not put any includes above the "all" target. We want the default target to build
# the operator.
include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
targets/openshift/operator/profile-manifests.mk \
)
clone-tuned:
(cd assets/tuned && \
rm -rf $(TUNED_DIR) && \
git clone -n $(TUNED_REPO) $(TUNED_DIR) && \
cd $(TUNED_DIR) && git checkout $(TUNED_COMMIT) && cd .. && \
rm -rf $(TUNED_DIR)/.git)
build: $(BINDATA) pkg/generated
$(GO_BUILD_RECIPE)
ln -sf $(PACKAGE_BIN) $(OUT_DIR)/openshift-tuned
$(BINDATA): $(GOBINDATA_BIN) $(ASSETS)
$(GOBINDATA_BIN) -mode 420 -modtime 1 -pkg manifests -o $(BINDATA) assets/...
gofmt -s -w $(BINDATA)
pkg/generated: $(API_TYPES)
$(GO) run k8s.io/code-generator/cmd/deepcopy-gen \
--input-dirs $(PACKAGE)/pkg/apis/tuned/v1 \
-O $(API_ZZ_GENERATED) \
--go-header-file $(API_GO_HEADER_FILE) \
--bounding-dirs $(PACKAGE)/pkg/apis \
--output-base tmp
$(GO) run k8s.io/code-generator/cmd/client-gen \
--clientset-name versioned \
--input-base '' \
--input $(PACKAGE)/pkg/apis/tuned/v1 \
--go-header-file $(API_GO_HEADER_FILE) \
--output-package $(PACKAGE)/pkg/generated/clientset \
--output-base tmp
$(GO) run k8s.io/code-generator/cmd/lister-gen \
--input-dirs $(PACKAGE)/pkg/apis/tuned/v1 \
--go-header-file $(API_GO_HEADER_FILE) \
--output-package $(PACKAGE)/pkg/generated/listers \
--output-base tmp
$(GO) run k8s.io/code-generator/cmd/informer-gen \
--input-dirs $(PACKAGE)/pkg/apis/tuned/v1 \
--versioned-clientset-package $(PACKAGE)/pkg/generated/clientset/versioned \
--listers-package $(PACKAGE)/pkg/generated/listers \
--go-header-file $(API_GO_HEADER_FILE) \
--output-package $(PACKAGE)/pkg/generated/informers \
--output-base tmp
tar c tmp | tar x --strip-components=4
touch $@
crd-schema-gen:
# TODO: look into using https://github.com/openshift/build-machinery-go/ and yaml patches
$(GO) run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/ schemapatch:manifests=./manifests paths=./pkg/apis/tuned/v1 output:dir=./manifests
yq w -i ./manifests/20-crd-tuned.yaml -s ./manifests/20-crd-tuned.yaml-patch
$(GOBINDATA_BIN):
$(GO) build -o $(GOBINDATA_BIN) ./vendor/github.com/kevinburke/go-bindata/go-bindata
test-e2e:
for d in core basic reboots; do \
KUBERNETES_CONFIG="$(KUBECONFIG)" $(GO) test -v -timeout 40m ./test/e2e/$$d -ginkgo.v -ginkgo.noColor -ginkgo.failFast || exit; \
done
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
vet: $(BINDATA)
$(GO) vet ./...
test:
$(GO) test ./cmd/... ./pkg/... -coverprofile cover.out
clean:
$(GO) clean $(PACKAGE_MAIN)
rm -rf $(BINDATA) $(OUT_DIR)
local-image:
$(IMAGE_BUILD_CMD) $(IMAGE_BUILD_EXTRA_OPTS) -t $(IMAGE) -f $(DOCKERFILE) .
local-image-push:
$(IMAGE_PUSH_CMD) $(IMAGE_PUSH_EXTRA_OPTS) $(IMAGE)
# This will include additional actions on the update and verify targets to ensure that profile patches are applied
# to manifest files
# $0 - macro name
# $1 - target name
# $2 - profile patches directory
# $3 - manifests directory
$(call add-profile-manifests,manifests,./profile-patches,./manifests)
.PHONY: all build deepcopy crd-schema-gen test-e2e verify verify-gofmt clean local-image local-image-push