From c70afaf2fef03a04d469f026aa64a9f10e01b49a Mon Sep 17 00:00:00 2001 From: Brian Vu <64455338+brivu@users.noreply.github.com> Date: Fri, 15 Sep 2023 11:27:47 -0700 Subject: [PATCH] feat:install helm plugin command (#71) * helm-plugin-install (#66) Co-authored-by: Brian Vu <64455338+brivu@users.noreply.github.com> * refactor: rename parameters to snake case * refactor: install script * ci: add testing for helm plugin installation * fix: parameter typo --------- Co-authored-by: akhon --- .circleci/test-deploy.yml | 13 ++++++++++++ README.md | 1 + src/commands/install_helm_plugin.yml | 30 ++++++++++++++++++++++++++++ src/scripts/install_helm_plugin.sh | 12 +++++++++++ 4 files changed, 56 insertions(+) create mode 100644 src/commands/install_helm_plugin.yml create mode 100644 src/scripts/install_helm_plugin.sh diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index c7093ac..0efc861 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -23,6 +23,15 @@ jobs: steps: - helm/install_helm_client: version: << parameters.version >> + helm-plugin-install-test: + docker: + - image: cimg/base:current + parameters: + helm_plugin_url: + type: string + steps: + - helm/install_helm_plugin: + helm_plugin_url: << parameters.helm_plugin_url >> install-helm-on-eks-cluster: docker: - image: cimg/python:3.10 @@ -164,6 +173,10 @@ workflows: name: helm-client-install-specific-version version: v3.0.0 filters: *filters + - helm-plugin-install-test: + name: helm-plugin-install-env + helm_plugin_url: https://github.com/adamreese/helm-env + filters: *filters - aws-eks/create-cluster: name: create-cluster-helm4 cluster-name: ${AWS_RESOURCE_NAME_PREFIX}-helm4-eks diff --git a/README.md b/README.md index 4d7e3f6..d0189e2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Here are the features that the Helm orb provides: - Installing the helm client (`install-helm-client`) - Installing helm charts (`install-helm-chart`) and deleting releases (`delete-helm-release`) +- Installing helm plugin (`helm-plugin-install`) Table of Contents ================= diff --git a/src/commands/install_helm_plugin.yml b/src/commands/install_helm_plugin.yml new file mode 100644 index 0000000..0e16e6e --- /dev/null +++ b/src/commands/install_helm_plugin.yml @@ -0,0 +1,30 @@ +description: | + Installs a helm plugin. + Requirements: helm should be installed on the cluster + +parameters: + helm_plugin_url: + description: | + absolute URL to helm plugin to install + (e.g. https://example.com/helm-plugin/helm-plugin-1.2.3.tgz) + type: string + helm_version: + type: string + default: "v3.8.2" + description: the helm client version to install. e.g. v3.0.0 + no_output_timeout: + description: | + Elapsed time that the helm command can run on CircleCI without output. + The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s” + type: string + default: "30m" + +steps: + - install_helm_client: + version: << parameters.helm_version >> + - run: + name: Install helm plugin + environment: + HELM_STR_PLUGIN_URL: << parameters.helm_plugin_url >> + command: <> + no_output_timeout: << parameters.no_output_timeout >> diff --git a/src/scripts/install_helm_plugin.sh b/src/scripts/install_helm_plugin.sh new file mode 100644 index 0000000..875d99b --- /dev/null +++ b/src/scripts/install_helm_plugin.sh @@ -0,0 +1,12 @@ +#!/bin/bash +HELM_STR_PLUGIN_URL="$(echo "${HELM_STR_PLUGIN_URL}" | circleci env subst)" + +STATUS="$(helm plugin install "${HELM_STR_PLUGIN_URL}")" + +if echo "${STATUS}" | grep "Installed plugin:"; then + echo "Installation successful" + exit 0 +else + echo "Installation failed. Please check the Helm plugin URL" + exit 1 +fi