diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 7c95b8ef4..6fae2eae7 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -2,6 +2,12 @@ This file documents all notable changes to https://github.com/devonfw/ide[devonfw-ide]. +== 2023.01.001 + +Release with new features and bugfixes: + +* https://github.com/devonfw/ide/issues/1004[#1004]: GCloud CLI integration for windows + == 2022.12.001 Release with new features and bugfixes: diff --git a/documentation/LICENSE.asciidoc b/documentation/LICENSE.asciidoc index 99bffbef5..59206de6d 100644 --- a/documentation/LICENSE.asciidoc +++ b/documentation/LICENSE.asciidoc @@ -68,6 +68,7 @@ The following table shows the components that may be used. The column `inclusion |https://github.com/openshift/oc[OpenShiftCLI]|Optional|https://github.com/openshift/oc/blob/master/LICENSE[ASL 2.0] |https://github.com/cli/cli/[GitHubCLI]|Optional|https://github.com/cli/cli/blob/trunk/LICENSE[MIT] |https://quarkus.io/guides/cli-tooling[QuarkusCLI]|Optional|https://github.com/quarkusio/quarkus/blob/main/LICENSE.txt[ASL 2.0] +|https://cloud.google.com/sdk/gcloud[GCloudCLI]|Optional|https://github.com/twistedpair/google-cloud-sdk/blob/master/google-cloud-sdk/LICENSE[ASL 2.0] |======================= == Apache Software License - Version 2.0 diff --git a/documentation/cli.asciidoc b/documentation/cli.asciidoc index cbb04cbc4..2b4e98796 100644 --- a/documentation/cli.asciidoc +++ b/documentation/cli.asciidoc @@ -57,6 +57,7 @@ The following commandlets are currently available: * link:docker.asciidoc[docker] * link:dotnet.asciidoc[dotnet] * link:eclipse.asciidoc[eclipse] +* link:gcloud.asciidoc[gcloud] * link:gcviewer.asciidoc[gcviewer] * link:gh.asciidoc[gh] * link:graalvm.asciidoc[graalvm] diff --git a/documentation/devonfw-ide-usage.asciidoc b/documentation/devonfw-ide-usage.asciidoc index f4161da84..665410a81 100644 --- a/documentation/devonfw-ide-usage.asciidoc +++ b/documentation/devonfw-ide-usage.asciidoc @@ -28,6 +28,8 @@ include::dotnet.asciidoc[leveloffset=3] include::eclipse.asciidoc[leveloffset=3] +include::gcloud.asciidoc[leveloffset=3] + include::gcviewer.asciidoc[leveloffset=3] include::gh.asciidoc[leveloffset=3] diff --git a/documentation/gcloud.asciidoc b/documentation/gcloud.asciidoc new file mode 100644 index 000000000..84877c57b --- /dev/null +++ b/documentation/gcloud.asciidoc @@ -0,0 +1,15 @@ +:toc: +toc::[] + += gcloud + +The gcloud commandlet allows to install and use https://cloud.google.com/sdk/gcloud[gcloud cli]. + +The arguments (`devon gcloud «args»`) are explained by the following table: + +.Usage of `devon gcloud` +[options="header"] +|======================= +|*Argument(s)* |*Meaning* +|`setup` |install gcloud cli on your machine. +|======================= \ No newline at end of file diff --git a/documentation/scripts.asciidoc b/documentation/scripts.asciidoc index c01fd3689..7f061564f 100644 --- a/documentation/scripts.asciidoc +++ b/documentation/scripts.asciidoc @@ -15,6 +15,7 @@ This directory is the heart of the `devonfw-ide` and contains the required link: │ ├── link:docker.asciidoc[docker] │ ├── link:dotnet.asciidoc[dotnet] │ ├── link:eclipse.asciidoc[eclipse] +│ ├── link:gcloud.asciidoc[gcloud] │ ├── link:gcviewer.asciidoc[gcviewer] │ ├── link:gh.asciidoc[gh] │ ├── link:graalvm.asciidoc[graalvm] diff --git a/scripts/src/main/resources/scripts/command/gcloud b/scripts/src/main/resources/scripts/command/gcloud new file mode 100644 index 000000000..b619903d6 --- /dev/null +++ b/scripts/src/main/resources/scripts/command/gcloud @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# autocompletion list +if [ "${1}" = "shortlist" ] +then + if [ -z "${2}" ] + then + echo "setup version help" + fi + exit +fi + +# shellcheck source=scripts/functions +source "$(dirname "${0}")"/../functions +GCLOUD_HOME="${DEVON_IDE_HOME}/software/gcloud" +TOOL_VERSION_COMMAND="${GCLOUD_HOME}/bin/gcloud --version" +# shellcheck source=scripts/commandlet-cli +source "$(dirname "${0}")"/../commandlet-cli + +function doConfig() { + local gcloud_config_files="${DEVON_IDE_HOME}/conf/.gcloud" + local gcloud_config_export="export CLOUDSDK_CONFIG=${gcloud_config_files}" + if ! grep -q "${gcloud_config_export}" "${DEVON_IDE_HOME}/conf/devon.properties" + then + doRunCommand "${gcloud_config_export}" + echo -e "\n${gcloud_config_export}" >> "${DEVON_IDE_HOME}/conf/devon.properties" + doEcho "Location of GClouds's configuration files is set to ${gcloud_config_files}" + fi +} + +# the path of gcloud modules must be added to python's sys.path via .pth file +function doSetPth() { + local lib_path="${GCLOUD_HOME}/lib" + local win_path + local pth_file="${DEVON_IDE_HOME}/software/python/ext_modules.pth" + if doIsWindows + then + win_path="$(cygpath -w "${lib_path}")" + if ! grep -Fq "${win_path}" "${pth_file}" &> /dev/null + then + echo -e "\n${win_path}" >> "${pth_file}" + fi + fi +} + +function doRun() { + doSetup silent + doRunCommand "${GCLOUD_HOME}/bin/gcloud ${*}" +} + +function doSetup() { + doDevonCommand python setup silent + doSetPth + doConfig + if doIsWindows + then + doInstall "gcloud" "${GCLOUD_VERSION}" "${1}" "" "${GCLOUD_HOME}" + else + doEchoAttention "GCloud is currently not supported for your operation system." + fi +} + +# CLI +case ${1} in +"help" | "-h") + echo "Setup or run GCloud CLI (command-line interface for Google Cloud Service)." + echo + echo "Arguments:" + echo " setup install gcloud on your machine." + echo " «args» call gcloud with the specified arguments. Call gcloud --help for details or use gcloud directly as preferred." + echo +;; +"setup" | "s" | "") + doSetup "${2}" +;; +*) + doRun "${@}" +;; +esac