crossplane

Форк
0
/
Makefile 
197 строк · 7.2 Кб
1
# ====================================================================================
2
# Setup Project
3

4
PROJECT_NAME := crossplane
5
PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)
6

7
PLATFORMS ?= linux_amd64 linux_arm64 linux_arm linux_ppc64le darwin_amd64 darwin_arm64 windows_amd64
8
# -include will silently skip missing files, which allows us
9
# to load those files with a target in the Makefile. If only
10
# "include" was used, the make command would fail and refuse
11
# to run a target until the include commands succeeded.
12
-include build/makelib/common.mk
13

14
# ====================================================================================
15
# Setup Output
16

17
S3_BUCKET ?= crossplane.releases
18
-include build/makelib/output.mk
19

20
# ====================================================================================
21
# Setup Go
22

23
# Set a sane default so that the nprocs calculation below is less noisy on the initial
24
# loading of this file
25
NPROCS ?= 1
26

27
# each of our test suites starts a kube-apiserver and running many test suites in
28
# parallel can lead to high CPU utilization. by default we reduce the parallelism
29
# to half the number of CPU cores.
30
GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))
31

32
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/crossplane $(GO_PROJECT)/cmd/crank
33
GO_TEST_PACKAGES = $(GO_PROJECT)/test/e2e
34
GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.version=$(VERSION)
35
GO_SUBDIRS += cmd internal apis
36
GO111MODULE = on
37
GOLANGCILINT_VERSION = 1.56.2
38
GO_LINT_ARGS ?= "--fix"
39

40
-include build/makelib/golang.mk
41

42
# ====================================================================================
43
# Setup Kubernetes tools
44

45
USE_HELM3 = true
46
HELM3_VERSION = v3.14.0
47
KIND_VERSION = v0.21.0
48
-include build/makelib/k8s_tools.mk
49

50
# ====================================================================================
51
# Setup Helm
52

53
HELM_BASE_URL = https://charts.crossplane.io
54
HELM_S3_BUCKET = crossplane.charts
55
HELM_CHARTS = crossplane
56
HELM_CHART_LINT_ARGS_crossplane = --set nameOverride='',imagePullSecrets=''
57
HELM_DOCS_ENABLED = true
58
HELM_VALUES_TEMPLATE_SKIPPED = true
59
-include build/makelib/helm.mk
60

61
# ====================================================================================
62
# Setup Images
63
# Due to the way that the shared build logic works, images should
64
# all be in folders at the same level (no additional levels of nesting).
65

66
REGISTRY_ORGS ?= docker.io/crossplane xpkg.upbound.io/crossplane
67
IMAGES = crossplane
68
-include build/makelib/imagelight.mk
69

70
# ====================================================================================
71
# Targets
72

73
# run `make help` to see the targets and options
74

75
# We want submodules to be set up the first time `make` is run.
76
# We manage the build/ folder and its Makefiles as a submodule.
77
# The first time `make` is run, the includes of build/*.mk files will
78
# all fail, and this target will be run. The next time, the default as defined
79
# by the includes will be run instead.
80
fallthrough: submodules
81
	@echo Initial setup complete. Running make again . . .
82
	@make
83

84
manifests:
85
	@$(WARN) Deprecated. Please run make generate instead.
86

87
CRD_DIR = cluster/crds
88

89
crds.clean:
90
	@$(INFO) cleaning generated CRDs
91
	@find $(CRD_DIR) -name '*.yaml' -exec sed -i.sed -e '1,1d' {} \; || $(FAIL)
92
	@find $(CRD_DIR) -name '*.yaml.sed' -delete || $(FAIL)
93
	@$(OK) cleaned generated CRDs
94

95
generate.run: gen-kustomize-crds gen-chart-license
96

97
gen-chart-license:
98
	@cp -f LICENSE cluster/charts/crossplane/LICENSE
99

100
generate.done: crds.clean
101

102
gen-kustomize-crds:
103
	@$(INFO) Adding all CRDs to Kustomize file for local development
104
	@rm cluster/kustomization.yaml
105
	@echo "# This kustomization can be used to remotely install all Crossplane CRDs" >> cluster/kustomization.yaml
106
	@echo "# by running kubectl apply -k https://github.com/crossplane/crossplane//cluster?ref=master" >> cluster/kustomization.yaml
107
	@echo "resources:" >> cluster/kustomization.yaml
108
	@find $(CRD_DIR) -type f -name '*.yaml' | sort | \
109
		while read filename ;\
110
		do echo "- $${filename#*/}" >> cluster/kustomization.yaml \
111
		; done
112
	@$(OK) All CRDs added to Kustomize file for local development
113

114
# Generate a coverage report for cobertura applying exclusions on
115
# - generated file
116
cobertura:
117
	@cat $(GO_TEST_OUTPUT)/coverage.txt | \
118
		grep -v zz_generated.deepcopy | \
119
		$(GOCOVER_COBERTURA) > $(GO_TEST_OUTPUT)/cobertura-coverage.xml
120

121
e2e-tag-images:
122
	@$(INFO) Tagging E2E test images
123
	@docker tag $(BUILD_REGISTRY)/$(PROJECT_NAME)-$(TARGETARCH) crossplane-e2e/$(PROJECT_NAME):latest || $(FAIL)
124
	@$(OK) Tagged E2E test images
125

126
# NOTE(negz): There's already a go.test.integration target, but it's weird.
127
# This relies on make build building the e2e binary.
128
E2E_TEST_FLAGS ?=
129

130
# TODO(negz): Ideally we'd just tell the E2E tests which CLI tools to invoke.
131
# https://github.com/kubernetes-sigs/e2e-framework/issues/282
132
E2E_PATH = $(WORK_DIR)/e2e
133

134
e2e-run-tests:
135
	@$(INFO) Run E2E tests
136
	@mkdir -p $(E2E_PATH)
137
	@ln -sf $(KIND) $(E2E_PATH)/kind
138
	@ln -sf $(HELM) $(E2E_PATH)/helm
139
	@PATH="$(E2E_PATH):${PATH}" $(GO_TEST_OUTPUT)/e2e $(E2E_TEST_FLAGS) || $(FAIL)
140
	@$(OK) Run E2E tests
141

142
e2e.init: build e2e-tag-images
143

144
e2e.run: $(KIND) $(HELM3) e2e-run-tests
145

146
# Update the submodules, such as the common build scripts.
147
submodules:
148
	@git submodule sync
149
	@git submodule update --init --recursive
150

151
# Install CRDs into a cluster. This is for convenience.
152
install-crds: $(KUBECTL) reviewable
153
	$(KUBECTL) apply -f $(CRD_DIR)
154

155
# Uninstall CRDs from a cluster. This is for convenience.
156
uninstall-crds:
157
	$(KUBECTL) delete -f $(CRD_DIR)
158

159
# NOTE(hasheddan): the build submodule currently overrides XDG_CACHE_HOME in
160
# order to force the Helm 3 to use the .work/helm directory. This causes Go on
161
# Linux machines to use that directory as the build cache as well. We should
162
# adjust this behavior in the build submodule because it is also causing Linux
163
# users to duplicate their build cache, but for now we just make it easier to
164
# identify its location in CI so that we cache between builds.
165
go.cachedir:
166
	@go env GOCACHE
167

168
# This is for running out-of-cluster locally, and is for convenience. Running
169
# this make target will print out the command which was used. For more control,
170
# try running the binary directly with different arguments.
171
run: go.build
172
	@$(INFO) Running Crossplane locally out-of-cluster . . .
173
	@# To see other arguments that can be provided, run the command with --help instead
174
	$(GO_OUT_DIR)/$(PROJECT_NAME) core start --debug
175

176
.PHONY: manifests cobertura submodules fallthrough test-integration run install-crds uninstall-crds gen-kustomize-crds e2e-tests-compile e2e.test.images
177

178
# ====================================================================================
179
# Special Targets
180

181
define CROSSPLANE_MAKE_HELP
182
Crossplane Targets:
183
    cobertura          Generate a coverage report for cobertura applying exclusions on generated files.
184
    submodules         Update the submodules, such as the common build scripts.
185
    run                Run crossplane locally, out-of-cluster. Useful for development.
186

187
endef
188
# The reason CROSSPLANE_MAKE_HELP is used instead of CROSSPLANE_HELP is because the crossplane
189
# binary will try to use CROSSPLANE_HELP if it is set, and this is for something different.
190
export CROSSPLANE_MAKE_HELP
191

192
crossplane.help:
193
	@echo "$$CROSSPLANE_MAKE_HELP"
194

195
help-special: crossplane.help
196

197
.PHONY: crossplane.help help-special
198

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.