Skip to content

Commit 1a96eef

Browse files
committed
better cloud shell checks
1 parent a12e5b4 commit 1a96eef

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

shell-helpers/detectCloudShell.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
if [[ $(hostname -s) == "cs-"* ]]; then
4+
echo true
5+
else
6+
echo false
7+
fi

shell-helpers/detectGoogleCloud.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/cli.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,24 @@ export async function cli(args) {
117117

118118
// detect if we are on google cloud :)
119119

120-
const checkGoogleCloud = await runHelperScript("detectGoogleCloud");
120+
const checkCloudShell = await runHelperScript("detectCloudShell");
121121

122-
if (!argv.method && checkGoogleCloud && checkGoogleCloud == "true") {
123-
argv.method == "gcloud";
124-
console.log(
125-
"Auto-detected you are on Google Cloud, so we'll deploy there 🚀\nYou can manually change this by executing with --method"
126-
);
127-
} else if (argv.method == undefined) {
122+
if (!argv.method && checkCloudShell && checkCloudShell == "true") {
123+
console.log("It looks like you are using Google Cloud Shell 🚀");
124+
125+
const gcloudCheck = await inquirer.prompt({
126+
type: "confirm",
127+
default: true,
128+
name: "confirm",
129+
message: "Do you want to deploy a new Coder cluster?",
130+
});
131+
132+
if (gcloudCheck.confirm) {
133+
argv.method = "gcloud";
134+
}
135+
}
136+
137+
if (argv.method == undefined) {
128138
argv = {
129139
...argv,
130140
...(await inquirer.prompt({
@@ -149,7 +159,6 @@ export async function cli(args) {
149159
// ensure gcloud-cli is installed and active
150160

151161
// TODO: add better user education on what the prereqs are
152-
console.log("Checking for prerequisites...");
153162
try {
154163
await runHelperScript("googleCloudPrereqs");
155164
console.log("✅", "You seem to have all the dependencies installed!");

0 commit comments

Comments
 (0)