Skip to content

Commit

Permalink
[make] Adding targets for chart management and sync with repo
Browse files Browse the repository at this point in the history
Signed-off-by: dd di cesare <[email protected]>
  • Loading branch information
didierofrivia committed Jul 24, 2024
1 parent a463595 commit 3fc5221
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ REGISTRY = quay.io
# Organization in container registry
ORG ?= kuadrant

# Repo in the container registry
DEFAULT_REPO = kuadrant-operator
REPO ?= $(DEFAULT_REPO)

# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
#
Expand Down Expand Up @@ -254,6 +258,23 @@ $(GINKGO):
.PHONY: ginkgo
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.

HELM = ./bin/helm
HELM_VERSION = v3.15.0
$(HELM):
@{ \
set -e ;\
mkdir -p $(dir $(HELM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
wget -O helm.tar.gz https://get.helm.sh/helm-$(HELM_VERSION)-$${OS}-$${ARCH}.tar.gz ;\
tar -zxvf helm.tar.gz ;\
mv $${OS}-$${ARCH}/helm $(HELM) ;\
chmod +x $(HELM) ;\
rm -rf $${OS}-$${ARCH} helm.tar.gz ;\
}

.PHONY: helm
helm: $(HELM) ## Download helm locally if necessary.

##@ Development
define patch-config
envsubst \
Expand Down
4 changes: 4 additions & 0 deletions config/helm/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace: kuadrant-system

resources:
- ../default
64 changes: 64 additions & 0 deletions make/helm.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
##@ Helm Charts

.PHONY: helm-build
helm-build: $(YQ) kustomize manifests ## Build the helm chart from kustomize manifests
# Set desired operator image and related wasm shim image
V="$(RELATED_IMAGE_WASMSHIM)" \
$(YQ) eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_WASMSHIM").value) = strenv(V)' -i config/manager/manager.yaml
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
# Build the helm chart templates from kustomize manifests
$(KUSTOMIZE) build config/helm > charts/kuadrant-operator/templates/manifests.yaml
# Set the helm chart version and dependencies versions
V="$(BUNDLE_VERSION)" $(YQ) -i e '.version = strenv(V)' charts/kuadrant-operator/Chart.yaml
V="$(AUTHORINO_OPERATOR_BUNDLE_VERSION)" $(YQ) -i e '(.dependencies[] | select(.name == "authorino-operator").version) = strenv(V)' charts/kuadrant-operator/Chart.yaml
V="$(LIMITADOR_OPERATOR_BUNDLE_VERSION)" $(YQ) -i e '(.dependencies[] | select(.name == "limitador-operator").version) = strenv(V)' charts/kuadrant-operator/Chart.yaml
V="$(DNS_OPERATOR_BUNDLE_VERSION)" $(YQ) -i e '(.dependencies[] | select(.name == "dns-operator").version) = strenv(V)' charts/kuadrant-operator/Chart.yaml

.PHONY: helm-install
helm-install: $(HELM) ## Install the helm chart
# Install the helm chart in the cluster
$(HELM) install $(REPO) charts/$(REPO)

.PHONY: helm-uninstall
helm-uninstall: $(HELM) ## Uninstall the helm chart
# Uninstall the helm chart from the cluster
$(HELM) uninstall $(REPO)

.PHONY: helm-upgrade
helm-upgrade: $(HELM) ## Upgrade the helm chart
# Upgrade the helm chart in the cluster
$(HELM) upgrade $(REPO) charts/$(REPO)

.PHONY: helm-package
helm-package: $(HELM) ## Package the helm chart
# Package the helm chart
$(HELM) package charts/$(REPO)

# GitHub Token with permissions to upload to the release assets
HELM_WORKFLOWS_TOKEN ?= <YOUR-TOKEN>
# GitHub Release Asset Browser Download URL, it can be find in the output of the uploaded asset
BROWSER_DOWNLOAD_URL ?= <BROWSER-DOWNLOAD-URL>
# Github repo name for the helm charts repository
HELM_REPO_NAME ?= helm-charts

CHART_VERSION ?= $(BUNDLE_VERSION)

.PHONY: helm-sync-package-created
helm-sync-package-created: ## Sync the helm chart package to the helm-charts repo
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $(HELM_WORKFLOWS_TOKEN)" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$(ORG)/$(HELM_REPO_NAME)/dispatches \
-d '{"event_type":"chart-created","client_payload":{"chart":"$(REPO)","version":"$(CHART_VERSION)", "browser_download_url": "$(BROWSER_DOWNLOAD_URL)"}}'

.PHONY: helm-sync-package-deleted
helm-sync-package-deleted: ## Sync the deleted helm chart package to the helm-charts repo
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $(HELM_WORKFLOWS_TOKEN)" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$(ORG)/$(HELM_REPO_NAME)/dispatches \
-d '{"event_type":"chart-deleted","client_payload":{"chart":"$(REPO)","version":"$(CHART_VERSION)"}}'

0 comments on commit 3fc5221

Please sign in to comment.