@@ -305,3 +305,74 @@ endef
305305define gomodver
306306$(shell go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' $(1 ) 2>/dev/null)
307307endef
308+
309+ # #@ Helm Deployment
310+
311+ # # Helm binary to use for deploying the chart
312+ HELM ?= helm
313+ # # Namespace to deploy the Helm release
314+ HELM_NAMESPACE ?= mcp-lifecycle-operator-system
315+ # # Name of the Helm release
316+ HELM_RELEASE ?= mcp-lifecycle-operator
317+ # # Path to the Helm chart directory
318+ HELM_CHART_DIR ?= dist/chart
319+ # # Additional arguments to pass to helm commands
320+ HELM_EXTRA_ARGS ?=
321+
322+ .PHONY : install-helm
323+ install-helm : # # Install the latest version of Helm.
324+ @command -v $(HELM ) > /dev/null 2>&1 || { \
325+ echo " Installing Helm..." && \
326+ curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4 | bash; \
327+ }
328+
329+ .PHONY : helm-deploy
330+ helm-deploy : install-helm # # Deploy manager to the K8s cluster via Helm. Specify an image with IMG.
331+ $(HELM ) upgrade --install $(HELM_RELEASE ) $(HELM_CHART_DIR ) \
332+ --namespace $(HELM_NAMESPACE ) \
333+ --create-namespace \
334+ --set manager.image.repository=$$ {IMG%:* } \
335+ --set manager.image.tag=$$ {IMG## *:} \
336+ --wait \
337+ --timeout 5m \
338+ $(HELM_EXTRA_ARGS )
339+
340+ .PHONY : helm-uninstall
341+ helm-uninstall : # # Uninstall the Helm release from the K8s cluster.
342+ $(HELM ) uninstall $(HELM_RELEASE ) --namespace $(HELM_NAMESPACE )
343+
344+ .PHONY : helm-status
345+ helm-status : # # Show Helm release status.
346+ $(HELM ) status $(HELM_RELEASE ) --namespace $(HELM_NAMESPACE )
347+
348+ .PHONY : helm-history
349+ helm-history : # # Show Helm release history.
350+ $(HELM ) history $(HELM_RELEASE ) --namespace $(HELM_NAMESPACE )
351+
352+ .PHONY : helm-rollback
353+ helm-rollback : # # Rollback to previous Helm release.
354+
355+ # #@ Helm Testing
356+
357+ # # Helm unittest plugin version
358+ HELM_UNITTEST_VERSION ?= 0.6.2
359+
360+ .PHONY : install-helm-unittest
361+ install-helm-unittest : install-helm # # Install helm-unittest plugin if not already installed.
362+ @$(HELM ) plugin list | grep -q unittest || { \
363+ echo " Installing helm-unittest plugin..." && \
364+ $(HELM ) plugin install https://github.com/helm-unittest/helm-unittest.git --version $(HELM_UNITTEST_VERSION ) --verify=false; \
365+ }
366+
367+ .PHONY : helm-test
368+ helm-test : install-helm-unittest # # Run helm-unittest tests for the Helm chart.
369+ $(HELM ) unittest $(HELM_CHART_DIR )
370+
371+ .PHONY : helm-test-verbose
372+ helm-test-verbose : install-helm-unittest # # Run helm-unittest tests with verbose output.
373+ $(HELM ) unittest $(HELM_CHART_DIR ) -d
374+
375+ .PHONY : helm-test-debug
376+ helm-test-debug : install-helm-unittest # # Run helm-unittest tests with debug output and rendered templates.
377+ $(HELM ) unittest $(HELM_CHART_DIR ) -d --debug
378+ $(HELM ) rollback $(HELM_RELEASE ) --namespace $(HELM_NAMESPACE )
0 commit comments