diff --git a/Makefile b/Makefile index 6c2992c0..2e1d3092 100644 --- a/Makefile +++ b/Makefile @@ -139,14 +139,21 @@ IMAGES_PACKAGE_DIR ?= $(LOCALBIN)/images $(IMAGES_PACKAGE_DIR): | $(LOCALBIN) rm -rf $(IMAGES_PACKAGE_DIR) mkdir -p $(IMAGES_PACKAGE_DIR) -PACKAGE_FOR_AIRGAP ?= false TEMPLATE_FOLDERS = $(patsubst $(TEMPLATES_DIR)/%,%,$(wildcard $(TEMPLATES_DIR)/*)) -.PHONY: helm-package +.PHONY: helm-package ## Package Helm charts used by HMC. helm-package: $(CHARTS_PACKAGE_DIR) helm @make $(patsubst %,package-%-tmpl,$(TEMPLATE_FOLDERS)) +.PHONY: bundle-images ## Create a tarball with all images used by HMC. +bundle-images: $(IMAGES_PACKAGE_DIR) + @KUBECTL=$(KUBECTL) YQ=$(YQ) HELM=$(HELM) NAMESPACE=$(NAMESPACE) BUNDLE_TARBALL=$(CHARTS_PACKAGE_DIR)/hmc-images-$(VERSION).tgz bash -c "./scripts/bundle-images.sh" + +.PHONY: airgap-package ## Create a tarball with all images and Helm charts used by HMC, useful for deploying in air-gapped environments. +airgap-package: helm-package bundle-images + tar -czf hmc-charts-images.tgz $(CHARTS_PACKAGE_DIR) $(IMAGES_PACKAGE_DIR) + package-%-tmpl: @make TEMPLATES_SUBDIR=$(TEMPLATES_DIR)/$* $(patsubst %,package-chart-%,$(shell ls $(TEMPLATES_DIR)/$*)) @@ -155,9 +162,6 @@ lint-chart-%: $(HELM) lint --strict $(TEMPLATES_SUBDIR)/$* package-chart-%: lint-chart-% - @if [ $(PACKAGE_FOR_AIRGAP) ]; then \ - echo $(TEMPLATES_SUBDIR)/$*; \ - fi $(HELM) package --destination $(CHARTS_PACKAGE_DIR) $(TEMPLATES_SUBDIR)/$* LD_FLAGS?= -s -w @@ -425,7 +429,6 @@ HELM_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/helm/helm/master/scrip $(HELM): | $(LOCALBIN) rm -f $(LOCALBIN)/helm-* curl -s $(HELM_INSTALL_SCRIPT) | USE_SUDO=false HELM_INSTALL_DIR=$(LOCALBIN) DESIRED_VERSION=$(HELM_VERSION) BINARY_NAME=helm-$(HELM_VERSION) PATH="$(LOCALBIN):$(PATH)" bash - $(HELM) plugin install https://github.com/nikhilsbhat/helm-images $(FLUX_HELM_CRD): $(EXTERNAL_CRD_DIR) rm -f $(FLUX_HELM_CRD) diff --git a/scripts/bundle-images.sh b/scripts/bundle-images.sh index 362d6edf..04fc3161 100644 --- a/scripts/bundle-images.sh +++ b/scripts/bundle-images.sh @@ -20,33 +20,8 @@ # this scripts functionality. # Usage: make bundle-images -if [ -z $YQ ]; then - echo "YQ must be set to the path of the yq binary" - echo "Use 'make bundle-images' instead of running this script directly to populate this value" - exit 1 -fi - -if [ -z $HELM ]; then - echo "HELM must be set to the path of the helm binary" - echo "Use 'make bundle-images' instead of running this script directly to populate this value" - exit 1 -fi - -if [ -z $KIND_CLUSTER_NAME ]; then - echo "KIND_CLUSTER_NAME must be set to the name of the kind cluster" - echo "Use 'make bundle-images' instead of running this script directly to populate this value" - exit 1 -fi - -if [ -z $NAMESPACE ]; then - echo "NAMESPACE must be set to the namespace where HMC is deployed" - echo "Use 'make bundle-images' instead of running this script directly to populate this value" - exit 1 -fi - -if [ -z $BUNDLE_TARBALL ]; then - echo "BUNDLE_TARBALL must be set to the name of the tarball to create" - echo "Use 'make bundle-images' instead of running this script directly to populate this value" +if [ "$(YQ)" == "" ] || [ "$(KUBECTL)" == "" ] || [ "$(HELM)" == "" ] || [ "$(KIND_CLUSTER_NAME)" == "" ] || [ "$(NAMESPACE)" == "" ] || [ "$(BUNDLE_TARBALL)" == "" ]; then + echo "This script should not be run directly. Use 'make bundle-images' instead." exit 1 fi