Add command updateImage for updating a container image via revision draft#477
Add command updateImage for updating a container image via revision draft#477MicroFish91 merged 14 commits intomainfrom
updateImage for updating a container image via revision draft#477Conversation
updateImage for updating a container image via revision draft
84dd53d to
1880dd7
Compare
e9f8729 to
2b8aa8b
Compare
…ode-azurecontainerapps into mwf/update-container-image
e8db514 to
ce16017
Compare
| <b>Priority Range</b>: 400 - 490 | ||
|
|
||
| #### Build Image in Azure Steps | ||
| #### General Steps |
There was a problem hiding this comment.
Made an engineering issue
|
|
||
| - ContainerAppUpdateStep: 480 (Todo - investigate decoupling this command from imageSource when revision draft update support is added) | ||
| - UpdateRegistryAndSecretsStep: 480 | ||
| - UpdateImageStep: 490 (revision draft) |
There was a problem hiding this comment.
Maybe we should just call this CreateRevisionDraft internally?
|
|
||
| <!-- Todo: Add this back in when update image command is added in follow-up PR --> | ||
| <!-- - `updateContainerImage` - An ACA exclusive command that updates the container app or revision's container image through updates to a revision draft. The draft must be deployed for the changes to take effect and can be used to bundle together `Template` changes. --> | ||
| - `updateImage` - An ACA exclusive command that updates the container app or revision's container image via revision draft. The draft must be deployed for the changes to take effect and can be used to bundle together `Template` changes. |
There was a problem hiding this comment.
Had a similar comment in your other PR. #476 (comment)
| const registries: RegistryCredentials[] = containerAppSettings?.registries?.filter(r => r.server !== registry.loginServer) ?? []; | ||
| registries?.push( | ||
| { | ||
| identity: '', |
There was a problem hiding this comment.
The server populates an undefined identity as '', so when I deep copy compare in the later steps in UpdateRegistryAndSecretsStep, I need to add this here to keep them being detected as equivalent. I forgot but I should probably add a comment explaining this
| import { getContainerNameForImage } from "../imageSource/containerRegistry/getContainerNameForImage"; | ||
| import type { UpdateImageContext } from "./updateImage"; | ||
|
|
||
| export class UpdateImageStep<T extends UpdateImageContext> extends RevisionDraftUpdateBaseStep<T> { |
There was a problem hiding this comment.
I mentioned it in the execute priority markdown, but I think it makes more sense to call this CreateRevisionDraft or CreateImageDraft. Update feels like the wrong word here since it can mean remotely or locally. Update and upload also look super similar, so I feel like the brain just fills in the gaps.
Maybe we should use the word save? Save tends to mean locally, or at least in place?
There was a problem hiding this comment.
Yeah let me look through some of the other steps and I'll get back to you. Maybe we can brainstorm a naming convention that works, I was thinking something similar before but didn't have any ideas that stuck.
| containerAppEnvelope.configuration.secrets = context.secrets; | ||
| containerAppEnvelope.configuration.registries = context.registries; | ||
|
|
||
| await updateContainerApp(context, context.subscription, containerAppEnvelope); |
| template = nonNullValueAndProp(this.baseItem.revision, 'template'); | ||
| // Branching path reasoning: https://github.com/microsoft/vscode-azurecontainerapps/blob/main/src/commands/revisionDraft/README.md | ||
| // Make deep copies so we don't accidentally modify the cached values | ||
| if (ContainerAppItem.isContainerAppItem(this.baseItem) || this.baseItem.containerApp.revisionsMode === KnownActiveRevisionsMode.Single) { |
There was a problem hiding this comment.
Can you not use the getParentResourceFromItem util function here to pick between containerApp or revision?
There was a problem hiding this comment.
Oh yeah good catch, I think you should be able to
|
Just approving ahead of time to not block you |


Part 2
Partially addresses #426
This is the new
updateImagecommand implementation. It can be executed on theContainerAppItemlevel or on theRevisionItemlevel to update the container image. Any changes will be made to the revision draft instead of automatically executing a deployment like before.A few things to note:
I've also added a new thing where I append a short random hex value to the container name on draft update. This is because if you are re-deploying using the exact same image values, the extension will have no easy way to detect that there are changes to deploy. This was an easy way to fix that and get it to play nicely with our current setup.
One other noteworthy area is the new
UpdateRegistryAndSecretsStep. I've added some deep copy comparison logic to try and see if we can skip credential updates since updating the container app's secrets before deployment can trigger a bit of a wait which feels bad to always do unless we absolutely need it.Todo: In a follow-up PR I'm going to build out some sort of draft command information pop-up. Right now updating the image does get a little lost because we don't yet have the
containerssection of the tree implemented. Having a pop-up should help the results appear a bit more prominently and I think will be a nice addition.Update: Here's the demo
This PR doesn't cover the pop-up part shown in the demo