Skip to content

Commit 7f85671

Browse files
authored
devonfw#1004: GCloud CLI integration for windows (devonfw#1028)
1 parent 5b60e97 commit 7f85671

File tree

7 files changed

+105
-0
lines changed

7 files changed

+105
-0
lines changed

CHANGELOG.asciidoc

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This file documents all notable changes to https://github.com/devonfw/ide[devonfw-ide].
44

5+
== 2023.01.001
6+
7+
Release with new features and bugfixes:
8+
9+
* https://github.com/devonfw/ide/issues/1004[#1004]: GCloud CLI integration for windows
10+
511
== 2022.12.001
612

713
Release with new features and bugfixes:

documentation/LICENSE.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The following table shows the components that may be used. The column `inclusion
6868
|https://github.com/openshift/oc[OpenShiftCLI]|Optional|https://github.com/openshift/oc/blob/master/LICENSE[ASL 2.0]
6969
|https://github.com/cli/cli/[GitHubCLI]|Optional|https://github.com/cli/cli/blob/trunk/LICENSE[MIT]
7070
|https://quarkus.io/guides/cli-tooling[QuarkusCLI]|Optional|https://github.com/quarkusio/quarkus/blob/main/LICENSE.txt[ASL 2.0]
71+
|https://cloud.google.com/sdk/gcloud[GCloudCLI]|Optional|https://github.com/twistedpair/google-cloud-sdk/blob/master/google-cloud-sdk/LICENSE[ASL 2.0]
7172
|=======================
7273

7374
== Apache Software License - Version 2.0

documentation/cli.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ The following commandlets are currently available:
5757
* link:docker.asciidoc[docker]
5858
* link:dotnet.asciidoc[dotnet]
5959
* link:eclipse.asciidoc[eclipse]
60+
* link:gcloud.asciidoc[gcloud]
6061
* link:gcviewer.asciidoc[gcviewer]
6162
* link:gh.asciidoc[gh]
6263
* link:graalvm.asciidoc[graalvm]

documentation/devonfw-ide-usage.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ include::dotnet.asciidoc[leveloffset=3]
2828

2929
include::eclipse.asciidoc[leveloffset=3]
3030

31+
include::gcloud.asciidoc[leveloffset=3]
32+
3133
include::gcviewer.asciidoc[leveloffset=3]
3234

3335
include::gh.asciidoc[leveloffset=3]

documentation/gcloud.asciidoc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:toc:
2+
toc::[]
3+
4+
= gcloud
5+
6+
The gcloud commandlet allows to install and use https://cloud.google.com/sdk/gcloud[gcloud cli].
7+
8+
The arguments (`devon gcloud «args»`) are explained by the following table:
9+
10+
.Usage of `devon gcloud`
11+
[options="header"]
12+
|=======================
13+
|*Argument(s)* |*Meaning*
14+
|`setup` |install gcloud cli on your machine.
15+
|=======================

documentation/scripts.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This directory is the heart of the `devonfw-ide` and contains the required link:
1515
│ ├── link:docker.asciidoc[docker]
1616
│ ├── link:dotnet.asciidoc[dotnet]
1717
│ ├── link:eclipse.asciidoc[eclipse]
18+
│ ├── link:gcloud.asciidoc[gcloud]
1819
│ ├── link:gcviewer.asciidoc[gcviewer]
1920
│ ├── link:gh.asciidoc[gh]
2021
│ ├── link:graalvm.asciidoc[graalvm]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
# autocompletion list
4+
if [ "${1}" = "shortlist" ]
5+
then
6+
if [ -z "${2}" ]
7+
then
8+
echo "setup version help"
9+
fi
10+
exit
11+
fi
12+
13+
# shellcheck source=scripts/functions
14+
source "$(dirname "${0}")"/../functions
15+
GCLOUD_HOME="${DEVON_IDE_HOME}/software/gcloud"
16+
TOOL_VERSION_COMMAND="${GCLOUD_HOME}/bin/gcloud --version"
17+
# shellcheck source=scripts/commandlet-cli
18+
source "$(dirname "${0}")"/../commandlet-cli
19+
20+
function doConfig() {
21+
local gcloud_config_files="${DEVON_IDE_HOME}/conf/.gcloud"
22+
local gcloud_config_export="export CLOUDSDK_CONFIG=${gcloud_config_files}"
23+
if ! grep -q "${gcloud_config_export}" "${DEVON_IDE_HOME}/conf/devon.properties"
24+
then
25+
doRunCommand "${gcloud_config_export}"
26+
echo -e "\n${gcloud_config_export}" >> "${DEVON_IDE_HOME}/conf/devon.properties"
27+
doEcho "Location of GClouds's configuration files is set to ${gcloud_config_files}"
28+
fi
29+
}
30+
31+
# the path of gcloud modules must be added to python's sys.path via .pth file
32+
function doSetPth() {
33+
local lib_path="${GCLOUD_HOME}/lib"
34+
local win_path
35+
local pth_file="${DEVON_IDE_HOME}/software/python/ext_modules.pth"
36+
if doIsWindows
37+
then
38+
win_path="$(cygpath -w "${lib_path}")"
39+
if ! grep -Fq "${win_path}" "${pth_file}" &> /dev/null
40+
then
41+
echo -e "\n${win_path}" >> "${pth_file}"
42+
fi
43+
fi
44+
}
45+
46+
function doRun() {
47+
doSetup silent
48+
doRunCommand "${GCLOUD_HOME}/bin/gcloud ${*}"
49+
}
50+
51+
function doSetup() {
52+
doDevonCommand python setup silent
53+
doSetPth
54+
doConfig
55+
if doIsWindows
56+
then
57+
doInstall "gcloud" "${GCLOUD_VERSION}" "${1}" "" "${GCLOUD_HOME}"
58+
else
59+
doEchoAttention "GCloud is currently not supported for your operation system."
60+
fi
61+
}
62+
63+
# CLI
64+
case ${1} in
65+
"help" | "-h")
66+
echo "Setup or run GCloud CLI (command-line interface for Google Cloud Service)."
67+
echo
68+
echo "Arguments:"
69+
echo " setup install gcloud on your machine."
70+
echo " «args» call gcloud with the specified arguments. Call gcloud --help for details or use gcloud directly as preferred."
71+
echo
72+
;;
73+
"setup" | "s" | "")
74+
doSetup "${2}"
75+
;;
76+
*)
77+
doRun "${@}"
78+
;;
79+
esac

0 commit comments

Comments
 (0)