Skip to content

Commit

Permalink
Fix up Makefile to use bundle-images script
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Squizzato <[email protected]>
  • Loading branch information
squizzi committed Oct 11, 2024
1 parent 8f23c9b commit 8a96b35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)/$*))

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 2 additions & 27 deletions scripts/bundle-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8a96b35

Please sign in to comment.