From 3c041d2ad7cfe17f912456d208738a25d1bc51fe Mon Sep 17 00:00:00 2001 From: CREITZ25 <95033856+CREITZ25@users.noreply.github.com> Date: Mon, 7 Mar 2022 11:07:11 +0100 Subject: [PATCH] #636 Helm Integration #636 Helm Integration --- documentation/cli.asciidoc | 1 + documentation/devonfw-ide-usage.asciidoc | 2 + documentation/helm.asciidoc | 23 ++++++ documentation/scripts.asciidoc | 1 + .../src/main/resources/scripts/command/helm | 77 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 documentation/helm.asciidoc create mode 100644 scripts/src/main/resources/scripts/command/helm diff --git a/documentation/cli.asciidoc b/documentation/cli.asciidoc index 8d010533b..879998d81 100644 --- a/documentation/cli.asciidoc +++ b/documentation/cli.asciidoc @@ -55,6 +55,7 @@ The following commandlets are currently available: * link:docker.asciidoc[docker] * link:eclipse.asciidoc[eclipse] * link:gradle.asciidoc[gradle] +* link:helm.asciidoc[helm] * link:help.asciidoc[help] * link:ide.asciidoc[ide] * link:intellij.asciidoc[intellij] diff --git a/documentation/devonfw-ide-usage.asciidoc b/documentation/devonfw-ide-usage.asciidoc index 10ef6486a..d575ad573 100644 --- a/documentation/devonfw-ide-usage.asciidoc +++ b/documentation/devonfw-ide-usage.asciidoc @@ -22,6 +22,8 @@ include::eclipse.asciidoc[leveloffset=3] include::gradle.asciidoc[leveloffset=3] +include::helm.asciidoc[leveloffset=3] + include::help.asciidoc[leveloffset=3] include::ide.asciidoc[leveloffset=3] diff --git a/documentation/helm.asciidoc b/documentation/helm.asciidoc new file mode 100644 index 000000000..f2f5d4aa0 --- /dev/null +++ b/documentation/helm.asciidoc @@ -0,0 +1,23 @@ +:toc: +toc::[] + += Helm + +The helm commandlet allows to install and use https://www.helm.sh/[Helm]. + +*ATTENTION:* +Currently this feature is new and therefore experimental. +It may change in incompatible ways in the next releases until we reach a stable state. +We hope that all is working fine for you. +However, do not expect everything to work out of the box. +In case you are facing issues (e.g. network problems with Cisco AnyConnect, etc.) please give us feedback so we can improve. + +The arguments (`devon helm «args»`) are explained by the following table: + +.Usage of `devon helm` +[options="header"] +|======================= +|*Argument(s)* |*Meaning* +|`setup` |install helm on your machine. +|`«args»` |call helm with the specified arguments. Call `helm --help` for details or use helm directly as preferred." +|======================= \ No newline at end of file diff --git a/documentation/scripts.asciidoc b/documentation/scripts.asciidoc index 6c593fe8f..25707d75a 100644 --- a/documentation/scripts.asciidoc +++ b/documentation/scripts.asciidoc @@ -13,6 +13,7 @@ This directory is the heart of the `devonfw-ide` and contains the required link: │ ├── link:docker.asciidoc[docker] │ ├── link:eclipse.asciidoc[eclipse] │ ├── link:gradle.asciidoc[gradle] +| ├── link:helm.asciidoc[helm] │ ├── link:help.asciidoc[help] │ ├── link:ide.asciidoc[ide] │ ├── link:intellij.asciidoc[intellij] diff --git a/scripts/src/main/resources/scripts/command/helm b/scripts/src/main/resources/scripts/command/helm new file mode 100644 index 000000000..da5c0986b --- /dev/null +++ b/scripts/src/main/resources/scripts/command/helm @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# autocompletion list +if [ "${1}" = "shortlist" ] +then + if [ -z "${2}" ] + then + echo "setup help" + fi + exit +fi + +if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi +# shellcheck source=scripts/functions +source "$(dirname "${0}")"/../functions + +# Check if helm is installed. +function doIsHelmInstalled() { + if command -v helm &> /dev/null + then + return + else + return 255 + fi +} + +# Call helm with specified arguments. +function doRun() { + doSetup silent + helm "${@}" +} + +function doSetup() { + + if doIsHelmInstalled + then + if [ "${1}" != "silent" ] && ! doIsQuiet + then + helm version + fi + else + # Check if HELM_HOME is already set + if [ -z "${HELM_HOME}" ] + then + HELM_HOME="${DEVON_IDE_HOME}/software/helm" + fi + + # Get leatest release + if [ -z "${HELM_VERSION}" ] + then + doEcho "Getting latest release..." + HELM_VERSION=$(curl -LsH "Accept: application/vnd.github.v3+json" https://api.github.com/repos/helm/helm/releases/latest | awk -F':' '/tag_name/ {print $2}' | awk -F'"' '{print $2}') + fi + + doInstall "-" "${HELM_HOME}" "helm" "${HELM_VERSION}" + fi +} + + +# CLI +case ${1} in +"help" | "-h") + echo "Install helm." + echo + echo "Arguments:" + echo " setup install helm on your machine." + echo " <> call helm with the specified arguments. Call helm --help for details or use helm directly as preferred." + echo +;; +"setup" | "s" | "") + doEcho "Installating helm..." + doSetup +;; +*) + doRun "${@}" +;; +esac