Skip to content

Commit e5037b9

Browse files
authored
Pre-populate existing image when modifying a deployment (#6952)
If a user wants to update a deployment to change only the tag of their image, then they must re-enter the entire image URL with the new tag. Instead, we can pre-populate the image field with the existing image URL (including the tag), which means a user can now simply modify the tag without needing to re-enter the full URL themselves. For example, if the deployment is currently using image "hello-world:1.0" and they want to modify it to use "hello-world:1.1", currently they would need to write the full text "hello-world:1.1". This can be quite cumbersome if the URL of the image is long (which it often is). With this change, the existing URL is pre-populated, so the user needs only to replace "0" with "1". If a user does not want to modify the image of the deployment then they can continue to just press "Enter" to keep the existing image as before.
1 parent 0595241 commit e5037b9

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

packages/wrangler/src/cloudchamber/modify.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -187,27 +187,22 @@ async function handleModifyCommand(
187187

188188
const keys = await handleSSH(args, config, deployment);
189189
const givenImage = args.image ?? config.cloudchamber.image;
190-
const imagePrompt = await processArgument<string>(
191-
{ image: givenImage },
192-
"image",
193-
{
194-
question: modifyImageQuestion,
195-
label: "",
196-
validate: (value) => {
197-
if (typeof value !== "string") {
198-
return "unknown error";
199-
}
200-
if (value.endsWith(":latest")) {
201-
return "we don't allow :latest tags";
202-
}
203-
},
204-
defaultValue: givenImage ?? "",
205-
initialValue: givenImage ?? "",
206-
helpText: "if you don't want to modify the image, press return",
207-
type: "text",
208-
}
209-
);
210-
const image = !imagePrompt ? undefined : imagePrompt;
190+
const image = await processArgument<string>({ image: givenImage }, "image", {
191+
question: modifyImageQuestion,
192+
label: "",
193+
validate: (value) => {
194+
if (typeof value !== "string") {
195+
return "unknown error";
196+
}
197+
if (value.endsWith(":latest")) {
198+
return "we don't allow :latest tags";
199+
}
200+
},
201+
defaultValue: givenImage ?? deployment.image,
202+
initialValue: givenImage ?? deployment.image,
203+
helpText: "Press Return to leave unchanged",
204+
type: "text",
205+
});
211206

212207
const locationPick = await getLocation(
213208
{ location: args.location ?? config.cloudchamber.location },
@@ -234,7 +229,7 @@ async function handleModifyCommand(
234229
);
235230

236231
renderDeploymentConfiguration("modify", {
237-
image: image ?? deployment.image,
232+
image,
238233
location: location ?? deployment.location.name,
239234
vcpu: args.vcpu ?? config.cloudchamber.vcpu ?? deployment.vcpu,
240235
memory: args.memory ?? config.cloudchamber.memory ?? deployment.memory,
@@ -247,7 +242,7 @@ async function handleModifyCommand(
247242
});
248243

249244
const yesOrNo = await inputPrompt({
250-
question: "Want to go ahead and modify the deployment?",
245+
question: "Modify the deployment?",
251246
label: "",
252247
type: "confirm",
253248
});
@@ -280,5 +275,4 @@ async function handleModifyCommand(
280275
await waitForPlacement(newDeployment);
281276
}
282277

283-
const modifyImageQuestion =
284-
"Insert the image url you want to change your deployment to";
278+
const modifyImageQuestion = "URL of the image to use in your deployment";

0 commit comments

Comments
 (0)