Skip to content

Commit

Permalink
Pre-populate existing image when modifying a deployment (#6952)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gpanders authored Oct 11, 2024
1 parent 0595241 commit e5037b9
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions packages/wrangler/src/cloudchamber/modify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,27 +187,22 @@ async function handleModifyCommand(

const keys = await handleSSH(args, config, deployment);
const givenImage = args.image ?? config.cloudchamber.image;
const imagePrompt = await processArgument<string>(
{ image: givenImage },
"image",
{
question: modifyImageQuestion,
label: "",
validate: (value) => {
if (typeof value !== "string") {
return "unknown error";
}
if (value.endsWith(":latest")) {
return "we don't allow :latest tags";
}
},
defaultValue: givenImage ?? "",
initialValue: givenImage ?? "",
helpText: "if you don't want to modify the image, press return",
type: "text",
}
);
const image = !imagePrompt ? undefined : imagePrompt;
const image = await processArgument<string>({ image: givenImage }, "image", {
question: modifyImageQuestion,
label: "",
validate: (value) => {
if (typeof value !== "string") {
return "unknown error";
}
if (value.endsWith(":latest")) {
return "we don't allow :latest tags";
}
},
defaultValue: givenImage ?? deployment.image,
initialValue: givenImage ?? deployment.image,
helpText: "Press Return to leave unchanged",
type: "text",
});

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

renderDeploymentConfiguration("modify", {
image: image ?? deployment.image,
image,
location: location ?? deployment.location.name,
vcpu: args.vcpu ?? config.cloudchamber.vcpu ?? deployment.vcpu,
memory: args.memory ?? config.cloudchamber.memory ?? deployment.memory,
Expand All @@ -247,7 +242,7 @@ async function handleModifyCommand(
});

const yesOrNo = await inputPrompt({
question: "Want to go ahead and modify the deployment?",
question: "Modify the deployment?",
label: "",
type: "confirm",
});
Expand Down Expand Up @@ -280,5 +275,4 @@ async function handleModifyCommand(
await waitForPlacement(newDeployment);
}

const modifyImageQuestion =
"Insert the image url you want to change your deployment to";
const modifyImageQuestion = "URL of the image to use in your deployment";

0 comments on commit e5037b9

Please sign in to comment.