forked from SAP-archive/helm-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
206 lines (164 loc) · 6.26 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Directory to put `go install`ed binaries in.
export GOBIN ?= $(shell pwd)/bin
ROOT_PATH := $(shell pwd)
REPO = $(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/
TAG = $(DOCKER_TAG)
GIT_TAG=$(PULL_BASE_REF)
GIT_REPO=$(REPO_OWNER)/$(REPO_NAME)
export GITHUB_TOKEN=$(BOT_GITHUB_TOKEN)
APP_NAME = helm-broker
TOOLS_NAME = helm-broker-tools
TESTS_NAME = helm-broker-tests
CONTROLLER_NAME = helm-controller
# VERIFY_IGNORE is a grep pattern to exclude files and directories from verification
VERIFY_IGNORE := /vendor\|/automock
# FILES_TO_CHECK is a command used to determine which files should be verified
FILES_TO_CHECK = find . -type f -name "*.go" | grep -v "$(VERIFY_IGNORE)"
# DIRS_TO_CHECK is a command used to determine which directories should be verified
DIRS_TO_CHECK = go list ./... | grep -v "$(VERIFY_IGNORE)"
build:: build-binaries verify test
verify:: vet check-imports-local check-fmt-local
format:: vet goimports fmt golint clean
test:: unit-test integration-test
.PHONY: build-binaries
build-binaries:
./hack/build-binaries.sh
.PHONY: integration-test
integration-test:
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT=2m
go test -tags=integration ./test/integration/
.PHONY: unit-test
unit-test:
go test ./internal/... ./cmd/...
.PHONY: charts-test
charts-test:
./hack/ci/run-chart-test.sh
# Run go fmt against code
.PHONY: fmt
fmt:
go fmt ./internal/... ./cmd/...
# Run go vet against code
.PHONY: vet
vet:
go vet $$($(DIRS_TO_CHECK))
.PHONY: golint
golint:
@go install golang.org/x/lint/golint
@$(GOBIN)/golint $$($(FILES_TO_CHECK))
.PHONY: goimports
goimports:
@go install golang.org/x/tools/cmd/goimports
@$(GOBIN)/goimports -w -l $$($(FILES_TO_CHECK))
.PHONY: check-imports-local
check-imports-local:
@if [ -n "$$(goimports -l $$($(FILES_TO_CHECK)))" ]; then \
echo "✗ some files are not properly formatted or contain not formatted imports. To repair run make imports"; \
goimports -l $$($(FILES_TO_CHECK)); \
exit 1; \
fi;
.PHONY: check-fmt-local
check-fmt-local:
@if [ -n "$$(gofmt -l $$($(FILES_TO_CHECK)))" ]; then \
gofmt -l $$($(FILES_TO_CHECK)); \
echo "✗ some files are not properly formatted. To repair run make fmt"; \
exit 1; \
fi;
.PHONY: pull-licenses
pull-licenses:
ifdef LICENSE_PULLER_PATH
bash $(LICENSE_PULLER_PATH)
else
mkdir -p licenses
endif
.PHONY: generates
# Generate CRD manifests, clients etc.
generates: crd-manifests client
.PHONY: crd-manifests
# Generate CRD manifests
crd-manifests: get-yaml-editor
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd paths=./pkg/apis/... output:crd:dir=charts/helm-broker/templates/crd
mv charts/helm-broker/templates/crd/addons.kyma-project.io_addonsconfigurations.yaml charts/helm-broker/templates/crd/addons-configuration.crd.yaml
mv charts/helm-broker/templates/crd/addons.kyma-project.io_clusteraddonsconfigurations.yaml charts/helm-broker/templates/crd/cluster-addons-configuration.crd.yaml
$(YAML_EDITOR) d -i charts/helm-broker/templates/crd/addons-configuration.crd.yaml metadata.annotations
$(YAML_EDITOR) w -i charts/helm-broker/templates/crd/addons-configuration.crd.yaml metadata.annotations["helm.sh/hook"] "crd-install"
$(YAML_EDITOR) d -i charts/helm-broker/templates/crd/cluster-addons-configuration.crd.yaml metadata.annotations
$(YAML_EDITOR) w -i charts/helm-broker/templates/crd/cluster-addons-configuration.crd.yaml metadata.annotations["helm.sh/hook"] "crd-install"
.PHONY: client
client:
./hack/update-codegen.sh
.PHONY: release
release: tar-chart append-changelog release-branch
./hack/release/push_release.sh $(GIT_TAG) $(GIT_REPO)
.PHONY: generate-changelog
generate-changelog:
./hack/release/generate_changelog.sh $(GIT_TAG) $(REPO_NAME) $(REPO_OWNER)
.PHONY: append-changelog
append-changelog: generate-changelog
./hack/release/append_changelog.sh
.PHONY: release-branch
release-branch:
# release branch named `release-x.y` will be created if the GIT_TAG matches the `x.y.0` version pattern.
./hack/release/create_release_branch.sh $(GIT_TAG) $(GIT_REPO)
.PHONY: tar-chart
tar-chart: create-release-dir
@tar -czvf toCopy/helm-broker-chart.tar.gz -C charts/helm-broker/ . ||:
.PHONY: create-release-dir
create-release-dir:
mkdir -p toCopy
.PHONY: cut-release
cut-release: tag-chart-images update-release-docs
git add .
git commit -m "Bump version to: $(VERSION)"
git tag $(VERSION)
.PHONY: update-release-docs
update-release-docs:
./hack/release/update_release_docs.sh $(VERSION)
.PHONY: tag-chart-images
tag-chart-images: get-yaml-editor
$(YAML_EDITOR) w -i charts/helm-broker/values.yaml global.helm_broker.version $(VERSION)
$(YAML_EDITOR) w -i charts/helm-broker/values.yaml global.helm_broker.dir '$(DIR)'
$(YAML_EDITOR) w -i charts/helm-broker/values.yaml global.helm_controller.version $(VERSION)
$(YAML_EDITOR) w -i charts/helm-broker/values.yaml global.helm_controller.dir '$(DIR)'
$(YAML_EDITOR) w -i charts/helm-broker/values.yaml tests.tag $(VERSION)
$(YAML_EDITOR) w -i charts/helm-broker/values.yaml tests.dir '$(DIR)'
.PHONY: build-image
build-image: pull-licenses
cp broker deploy/broker/helm-broker
cp targz deploy/tools/targz
cp indexbuilder deploy/tools/indexbuilder
cp controller deploy/controller/controller
cp hb_chart_test deploy/tests/hb_chart_test
docker build -t $(APP_NAME) deploy/broker
docker build -t $(CONTROLLER_NAME) deploy/controller
docker build -t $(TOOLS_NAME) deploy/tools
docker build -t $(TESTS_NAME) deploy/tests
.PHONY: push-image
push-image:
docker tag $(APP_NAME) $(REPO)$(APP_NAME):$(TAG)
docker push $(REPO)$(APP_NAME):$(TAG)
docker tag $(CONTROLLER_NAME) $(REPO)$(CONTROLLER_NAME):$(TAG)
docker push $(REPO)$(CONTROLLER_NAME):$(TAG)
docker tag $(TOOLS_NAME) $(REPO)$(TOOLS_NAME):$(TAG)
docker push $(REPO)$(TOOLS_NAME):$(TAG)
docker tag $(TESTS_NAME) $(REPO)$(TESTS_NAME):$(TAG)
docker push $(REPO)$(TESTS_NAME):$(TAG)
.PHONY: ci-pr
ci-pr: build build-image push-image
.PHONY: ci-master
ci-master: build build-image push-image
.PHONY: ci-release
ci-release: build build-image push-image charts-test release
.PHONY: clean
clean:
rm -f broker
rm -f controller
rm -f targz
rm -f indexbuilder
rm -f hb_chart_test
rm -rf bin/
.PHONY: path-to-referenced-charts
path-to-referenced-charts:
@echo "resources/helm-broker"
.PHONY: get-yaml-editor
get-yaml-editor:
$(eval YAML_EDITOR=$(shell ./hack/release/get_yq.sh))