-
Notifications
You must be signed in to change notification settings - Fork 117
/
Makefile
185 lines (150 loc) · 5.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
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
177
178
179
180
181
182
183
184
185
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
-include .env
include hack/tools.mk
IMAGE_REPOSITORY := europe-docker.pkg.dev/gardener-project/public/gardener/machine-controller-manager
IMAGE_TAG := $(shell cat VERSION)
COVERPROFILE := test/output/coverprofile.out
LEADER_ELECT ?= "true" # If LEADER_ELECT is not set in the environment, use the default value "true"
MACHINE_SAFETY_OVERSHOOTING_PERIOD:=1m
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
###########################################
# Setup targets for gardener shoot #
###########################################
.PHONY: gardener-setup
gardener-setup:
@echo "enter project name"; \
read PROJECT; \
echo "enter seed name"; \
read SEED; \
echo "enter shoot name"; \
read SHOOT; \
echo "enter cluster provider(gcp|aws|azure|vsphere|openstack|alicloud|metal|equinix-metal)"; \
read PROVIDER; \
./hack/gardener_local_setup.sh --seed $$SEED --shoot $$SHOOT --project $$PROJECT --provider $$PROVIDER
.PHONY: gardener-local-mcm-up
gardener-local-mcm-up: gardener-setup
$(MAKE) start;
.PHONY: gardener-restore
gardener-restore:
@echo "enter project name"; \
read PROJECT; \
echo "enter shoot name"; \
read SHOOT; \
echo "enter cluster provider(gcp|aws|azure|vsphere|openstack|alicloud|metal|equinix-metal)"; \
read PROVIDER; \
./hack/gardener_local_restore.sh --shoot $$SHOOT --project $$PROJECT --provider $$PROVIDER
###########################################
# Setup targets for non-gardener #
###########################################
.PHONY: non-gardener-setup
non-gardener-setup:
@echo "enter namespace"; \
read NAMESPACE; \
echo "enter control kubeconfig path"; \
read CONTROL_KUBECONFIG_PATH; \
echo "enter target kubeconfig path"; \
read TARGET_KUBECONFIG_PATH; \
echo "enter cluster provider(gcp|aws|azure|vsphere|openstack|alicloud|metal|equinix-metal)"; \
read PROVIDER; \
./hack/non_gardener_local_setup.sh --namespace $$NAMESPACE --control-kubeconfig-path $$CONTROL_KUBECONFIG_PATH --target-kubeconfig-path $$TARGET_KUBECONFIG_PATH --provider $$PROVIDER
.PHONY: non-gardener-local-mcm-up
non-gardener-local-mcm-up: non-gardener-setup
$(MAKE) start;
.PHONY: non-gardener-restore
non-gardener-restore:
@echo "enter namespace"; \
read NAMESPACE; \
echo "enter control kubeconfig path"; \
read CONTROL_KUBECONFIG_PATH; \
echo "enter cluster provider(gcp|aws|azure|vsphere|openstack|alicloud|metal|equinix-metal)"; \
read PROVIDER; \
@echo "enter project name"; \
./hack/non_gardener_local_restore.sh --namespace $$NAMESPACE --control-kubeconfig-path $$CONTROL_KUBECONFIG_PATH --provider $$PROVIDER
#########################################
# Rules for local development scenarios #
#########################################
.PHONY: start
start:
@GO111MODULE=on go run \
cmd/machine-controller-manager/controller_manager.go \
--control-kubeconfig=${CONTROL_KUBECONFIG} \
--target-kubeconfig=${TARGET_KUBECONFIG} \
--namespace=${CONTROL_NAMESPACE} \
--safety-up=2 \
--safety-down=1 \
--machine-safety-overshooting-period=$(MACHINE_SAFETY_OVERSHOOTING_PERIOD) \
--leader-elect=$(LEADER_ELECT) \
--v=3
#################################################################
# Rules related to binary build, Docker image build and release #
#################################################################
.PHONY: tidy
tidy:
@GO111MODULE=on go mod tidy -v
.PHONY: build
build:
@.ci/build
.PHONY: release
release: build docker-image docker-login docker-push
PLATFORM ?= linux/amd64
.PHONY: docker-image
docker-image:
@docker buildx build --platform $(PLATFORM) -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) --rm .
.PHONY: docker-login
docker-login:
@gcloud auth activate-service-account --key-file .kube-secrets/gcr/gcr-readwrite.json
.PHONY: docker-push
docker-push:
@if ! docker images $(IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(IMAGE_TAG); then echo "$(IMAGE_REPOSITORY) version $(IMAGE_TAG) is not yet built. Please run 'make docker-images'"; false; fi
@gcloud docker -- push $(IMAGE_REPOSITORY):$(IMAGE_TAG)
.PHONY: clean
clean:
@rm -rf bin/
#####################################################################
# Rules for verification, formatting, linting, testing and cleaning #
#####################################################################
.PHONY: verify
verify: check test
.PHONY: check
check:
@.ci/check
.PHONY: test
test:
@.ci/test
.PHONY: test-unit
test-unit:
@SKIP_INTEGRATION_TESTS=X .ci/test
.PHONY: test-integration
test-integration:
@SKIP_UNIT_TESTS=X .ci/test
.PHONY: show-coverage
show-coverage:
@if [ ! -f $(COVERPROFILE) ]; then echo "$(COVERPROFILE) is not yet built. Please run 'COVER=true make test'"; false; fi
go tool cover -html $(COVERPROFILE)
.PHONY: test-clean
test-clean:
@find . -name "*.coverprofile" -type f -delete
@rm -f $(COVERPROFILE)
.PHONY: generate
generate: $(VGOPATH) $(DEEPCOPY_GEN) $(DEFAULTER_GEN) $(CONVERSION_GEN) $(OPENAPI_GEN) $(CONTROLLER_GEN) $(GEN_CRD_API_REFERENCE_DOCS)
$(CONTROLLER_GEN) crd paths=./pkg/apis/machine/v1alpha1/... output:crd:dir=kubernetes/crds output:stdout
@./hack/generate-code
@./hack/api-reference/generate-spec-doc.sh
.PHONY: add-license-headers
add-license-headers: $(GO_ADD_LICENSE)
@./hack/add_license_headers.sh
.PHONY: sast
sast: $(GOSEC)
@chmod +xw hack/sast.sh
@./hack/sast.sh
.PHONY: sast-report
sast-report:$(GOSEC)
@chmod +xw hack/sast.sh
@./hack/sast.sh --gosec-report true