Skip to content

Commit eba018e

Browse files
authored
cloudchamber/create: always print deployment and placement ID (#7523)
We currently only print the full deployment ID when the deployment has an IPv4 address. This commit makes the deployment ID always print, as well as the placement ID. We also move the printing of the IPv4 address (if one exists) to the same place as the IPv6 address so that they are printed together. There are a few other nit-picky changes as well. I've tried to make capitalization of labels more consistent (there doesn't appear to be a rule on when someone should be capitalized and when it shouldn't be, but I've at least made it more consistent within the subcommands themselves). I also changed the green "SUCCESS" message to only print once at the very end of the `cloudchamber create` command. This is consistent with the flow for creating a Worker.
1 parent 004af53 commit eba018e

File tree

4 files changed

+44
-39
lines changed

4 files changed

+44
-39
lines changed

packages/wrangler/src/cloudchamber/cli/deployments.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { exit } from "process";
2-
import { cancel, crash, endSection, log } from "@cloudflare/cli";
2+
import { cancel, crash, endSection, log, newline } from "@cloudflare/cli";
33
import { processArgument } from "@cloudflare/cli/args";
44
import { brandColor, dim, yellow } from "@cloudflare/cli/colors";
55
import { spinner } from "@cloudflare/cli/interactive";
@@ -172,11 +172,10 @@ export async function pickDeployment(deploymentIdPrefix?: string) {
172172
}
173173

174174
export function logDeployment(deployment: DeploymentV2) {
175+
log(`${brandColor("image")} ${dim(deployment.image)}`);
175176
log(
176-
`${brandColor("Image")} ${dim(deployment.image)}\n${brandColor(
177-
"Location"
178-
)} ${dim(idToLocationName(deployment.location.name))}\n${brandColor(
179-
"Version"
180-
)} ${dim(`${deployment.version}`)}\n`
177+
`${brandColor("location")} ${dim(idToLocationName(deployment.location.name))}`
181178
);
179+
log(`${brandColor("version")} ${dim(`${deployment.version}`)}`);
180+
newline();
182181
}

packages/wrangler/src/cloudchamber/cli/index.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
endSection,
44
log,
55
logRaw,
6+
newline,
67
status,
78
updateStatus,
89
} from "@cloudflare/cli";
@@ -277,13 +278,20 @@ async function waitForVMToStart(deployment: DeploymentV2) {
277278
checkPlacementStatus(eventPlacement.placement);
278279
}
279280

280-
updateStatus(status.success + " Created your container");
281-
log(
282-
`${brandColor("assigned ipv6 address")} ${dim(
283-
eventPlacement.placement.status["ipv6Address"]
284-
)}\n`
285-
);
286-
endSection("Your container is up and running");
281+
const ipv4 = eventPlacement.placement.status["ipv4Address"];
282+
if (ipv4) {
283+
log(`${brandColor("assigned IPv4 address")} ${dim(ipv4)}\n`);
284+
}
285+
286+
const ipv6 = eventPlacement.placement.status["ipv6Address"];
287+
if (ipv6) {
288+
log(`${brandColor("assigned IPv6 address")} ${dim(ipv6)}\n`);
289+
}
290+
291+
endSection("Done");
292+
293+
logRaw(status.success + " Created your container\n");
294+
287295
logRaw(
288296
`Run ${brandColor(
289297
`wrangler cloudchamber list ${deployment.id.slice(0, 6)}`
@@ -334,15 +342,18 @@ async function waitForPlacementInstance(deployment: DeploymentV2) {
334342
}
335343

336344
updateStatus(
337-
"Assigned placement in " + idToLocationName(deployment.location.name)
345+
"Assigned placement in " + idToLocationName(deployment.location.name),
346+
false
338347
);
339-
if (d.current_placement?.deployment_version) {
348+
349+
if (d.current_placement !== undefined) {
340350
log(
341-
`${brandColor("assigned placement")} ${dim(
342-
`version ${d.current_placement.deployment_version}`
343-
)}\n`
351+
`${brandColor("version")} ${dim(d.current_placement.deployment_version)}`
344352
);
353+
log(`${brandColor("id")} ${dim(d.current_placement?.id)}`);
354+
newline();
345355
}
356+
346357
deployment.current_placement = d.current_placement;
347358
}
348359

@@ -370,7 +381,6 @@ export async function waitForPlacement(deployment: DeploymentV2) {
370381
crash(
371382
"Couldn't retrieve a new deployment: " + getDeploymentError.message
372383
);
373-
return;
374384
}
375385

376386
currentDeployment = newDeployment;

packages/wrangler/src/cloudchamber/common.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,15 @@ export function renderDeploymentConfiguration(
344344
}
345345

346346
const containerInformation = [
347-
["Image", image],
348-
["Location", idToLocationName(location)],
349-
["VCPU", `${vcpu}`],
350-
["Memory", memory],
351-
["Environment variables", environmentVariablesText],
352-
["Labels", labelsText],
347+
["image", image],
348+
["location", idToLocationName(location)],
349+
["vCPU", `${vcpu}`],
350+
["memory", memory],
351+
["environment variables", environmentVariablesText],
352+
["labels", labelsText],
353353
...(network === undefined
354354
? []
355-
: [
356-
["Include IPv4", network.assign_ipv4 === "predefined" ? "yes" : "no"],
357-
]),
355+
: [["IPv4", network.assign_ipv4 === "predefined" ? "yes" : "no"]]),
358356
] as const;
359357

360358
updateStatus(

packages/wrangler/src/cloudchamber/create.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import {
33
endSection,
44
log,
55
startSection,
6-
status,
76
updateStatus,
87
} from "@cloudflare/cli";
98
import { processArgument } from "@cloudflare/cli/args";
9+
import { brandColor, dim } from "@cloudflare/cli/colors";
1010
import { inputPrompt, spinner } from "@cloudflare/cli/interactive";
1111
import { pollSSHKeysUntilCondition, waitForPlacement } from "./cli";
1212
import { getLocation } from "./cli/locations";
@@ -171,9 +171,9 @@ async function askWhichSSHKeysDoTheyWantToAdd(
171171

172172
if (keys.length === 1) {
173173
const yes = await inputPrompt({
174-
question: `Do you want to add the ssh key ${keyItems[0].name}?`,
174+
question: `Do you want to add the SSH key ${keyItems[0].name}?`,
175175
type: "confirm",
176-
helpText: "You need this to ssh into the VM",
176+
helpText: "You need this to SSH into the VM",
177177
defaultValue: false,
178178
label: "",
179179
});
@@ -190,15 +190,15 @@ async function askWhichSSHKeysDoTheyWantToAdd(
190190

191191
const res = await inputPrompt({
192192
question:
193-
"You have multiple ssh keys in your account, what do you want to do for this new deployment?",
194-
label: "",
193+
"You have multiple SSH keys in your account, what do you want to do for this new deployment?",
194+
label: "ssh",
195195
defaultValue: false,
196196
helpText: "",
197197
type: "select",
198198
options: [
199199
{ label: "Add all of them", value: "all" },
200200
{ label: "Select the keys", value: "select" },
201-
{ label: "Don't add any ssh keys", value: "none" },
201+
{ label: "Don't add any SSH keys", value: "none" },
202202
],
203203
});
204204
if (res === "all") {
@@ -294,7 +294,7 @@ async function handleCreateCommand(
294294

295295
const yes = await inputPrompt({
296296
type: "confirm",
297-
question: "Do you want to go ahead and create your container?",
297+
question: "Proceed?",
298298
label: "",
299299
});
300300
if (!yes) {
@@ -323,10 +323,8 @@ async function handleCreateCommand(
323323
}
324324

325325
stop();
326-
updateStatus(`${status.success} Created deployment!`);
327-
if (deployment.network?.ipv4) {
328-
log(`${deployment.id}\nIP: ${deployment.network.ipv4}`);
329-
}
326+
updateStatus("Created deployment", false);
327+
log(`${brandColor("id")} ${dim(deployment.id)}\n`);
330328

331329
endSection("Creating a placement for your container");
332330
startSection("Create a Cloudflare container", "Step 2 of 2");

0 commit comments

Comments
 (0)