helm.mk 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright 2017 The Rook Authors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # the helm charts to build
  15. HELM_CHARTS ?= rook-ceph rook-ceph-cluster
  16. HELM_BASE_URL ?= https://charts.rook.io
  17. HELM_S3_BUCKET ?= rook.chart
  18. HELM_CHARTS_DIR ?= $(ROOT_DIR)/deploy/charts
  19. HELM_OUTPUT_DIR ?= $(OUTPUT_DIR)/charts
  20. HELM_HOME := $(abspath $(CACHE_DIR)/helm)
  21. HELM_VERSION := v3.6.2
  22. HELM := $(TOOLS_HOST_DIR)/helm-$(HELM_VERSION)
  23. HELM_INDEX := $(HELM_OUTPUT_DIR)/index.yaml
  24. export HELM_HOME
  25. $(HELM_OUTPUT_DIR):
  26. @mkdir -p $@
  27. $(HELM):
  28. @echo === installing helm
  29. @mkdir -p $(TOOLS_HOST_DIR)/tmp
  30. @curl -sL https://get.helm.sh/helm-$(HELM_VERSION)-$(shell go env GOHOSTOS)-$(GOHOSTARCH).tar.gz | tar -xz -C $(TOOLS_HOST_DIR)/tmp
  31. @mv $(TOOLS_HOST_DIR)/tmp/$(shell go env GOHOSTOS)-$(GOHOSTARCH)/helm $(HELM)
  32. @rm -fr $(TOOLS_HOST_DIR)/tmp
  33. define helm.chart
  34. $(HELM_OUTPUT_DIR)/$(1)-$(VERSION).tgz: $(HELM) $(HELM_OUTPUT_DIR) $(shell find $(HELM_CHARTS_DIR)/$(1) -type f)
  35. @echo === helm package $(1)
  36. @rm -rf $(OUTPUT_DIR)/$(1)
  37. @cp -aL $(HELM_CHARTS_DIR)/$(1) $(OUTPUT_DIR)
  38. @$(SED_IN_PLACE) 's|master|$(VERSION)|g' $(OUTPUT_DIR)/$(1)/values.yaml
  39. @$(HELM) lint $(abspath $(OUTPUT_DIR)/$(1)) --set image.tag=$(VERSION)
  40. @$(HELM) package --version $(VERSION) --app-version $(VERSION) -d $(HELM_OUTPUT_DIR) $(abspath $(OUTPUT_DIR)/$(1))
  41. $(HELM_INDEX): $(HELM_OUTPUT_DIR)/$(1)-$(VERSION).tgz
  42. endef
  43. $(foreach p,$(HELM_CHARTS),$(eval $(call helm.chart,$(p))))
  44. $(HELM_INDEX): $(HELM) $(HELM_OUTPUT_DIR)
  45. @echo === helm index
  46. @$(HELM) repo index $(HELM_OUTPUT_DIR)
  47. helm.build: $(HELM_INDEX)
  48. # ====================================================================================
  49. # Makefile helper functions for helm-docs: https://github.com/norwoodj/helm-docs
  50. #
  51. HELM_DOCS_VERSION := v1.11.0
  52. HELM_DOCS := $(TOOLS_HOST_DIR)/helm-docs-$(HELM_DOCS_VERSION)
  53. HELM_DOCS_REPO := github.com/norwoodj/helm-docs/cmd/helm-docs
  54. $(HELM_DOCS): ## Installs helm-docs
  55. @echo === installing helm-docs
  56. @mkdir -p $(TOOLS_HOST_DIR)/tmp
  57. @GOBIN=$(TOOLS_HOST_DIR)/tmp GO111MODULE=on go install $(HELM_DOCS_REPO)@$(HELM_DOCS_VERSION)
  58. @mv $(TOOLS_HOST_DIR)/tmp/helm-docs $(HELM_DOCS)
  59. @rm -fr $(TOOLS_HOST_DIR)/tmp