Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an Edit Container Image... command #778

Merged
merged 20 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
"title": "%containerApps.editContainerApp%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.updateImage",
"title": "%containerApps.updateImage%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.deployImageApi",
"title": "%containerApps.deployImageApi%",
Expand Down Expand Up @@ -203,6 +198,17 @@
"title": "%containerApps.openConsoleInPortal%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.updateContainer",
"title": "%containerApps.updateContainer%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.updateContainerImage",
"title": "%containerApps.updateContainerImage.title%",
"shortTitle": "%containerApps.updateContainerImage.shortTitle%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.editScaleRange",
"title": "%containerApps.editScaleRange%",
Expand Down Expand Up @@ -373,11 +379,6 @@
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem(.*)revisionMode:single(.*)unsavedChanges:true/i",
"group": "3@2"
},
{
"command": "containerApps.updateImage",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem(.*)revisionMode:single/i",
"group": "4@1"
},
{
"command": "containerApps.editContainerApp",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem(.*)revisionMode:single/i",
Expand Down Expand Up @@ -438,11 +439,6 @@
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /revisionItem(.*)revisionState:active/i",
"group": "2@2"
},
{
"command": "containerApps.updateImage",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /revisionDraft:false(.*)revisionItem/i",
"group": "3@1"
},
{
"command": "containerApps.deployRevisionDraft",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /revisionDraftItem(.*)unsavedChanges:true/i",
Expand All @@ -463,16 +459,21 @@
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /revisionDraftItem/i",
"group": "1@2"
},
{
"command": "containerApps.updateImage",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /revisionDraftItem/i",
"group": "2@1"
},
{
"command": "containerApps.editRevisionDraft",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /revisionDraftItem/i",
"group": "3@1"
},
{
"command": "containerApps.updateContainer",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerItem/i",
"group": "1@1"
},
{
"command": "containerApps.updateContainerImage",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /imageItem/i",
"group": "1@1"
},
{
"command": "containerApps.editScaleRange",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /scaleItem/i",
Expand Down
4 changes: 3 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"containerApps.createContainerApp": "Create Container App...",
"containerApps.createContainerAppFromWorkspace": "Create Container App from Workspace...",
"containerApps.editContainerApp": "Edit Container App (Advanced)...",
"containerApps.updateImage": "Update Container Image...",
"containerApps.updateContainer": "Update Container...",
"containerApps.updateContainerImage.title": "Update Container Image...",
"containerApps.updateContainerImage.shortTitle": "Update Image...",
"containerApps.deployImageApi": "Deploy Image to Container App (API)...",
"containerApps.deployWorkspaceProject": "Deploy Project from Workspace...",
"containerApps.deployWorkspaceProjectApi": "Deploy Project from Workspace (API)...",
Expand Down
12 changes: 11 additions & 1 deletion src/commands/image/imageSource/ImageSourceListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ import { ContainerRegistryImageConfigureStep } from "./containerRegistry/Contain
import { ContainerRegistryListStep } from "./containerRegistry/ContainerRegistryListStep";
import { AcrListStep } from "./containerRegistry/acr/AcrListStep";

interface ImageSourceListStepOptions {
suppressEnvPrompt?: boolean;
}

export class ImageSourceListStep extends AzureWizardPromptStep<ImageSourceContext> {
constructor(private readonly options?: ImageSourceListStepOptions) {
super();
}

public async prompt(context: ImageSourceContext): Promise<void> {
const imageSourceLabels: string[] = [
localize('containerRegistryLabel', 'Container Registry'),
Expand Down Expand Up @@ -81,7 +89,9 @@ export class ImageSourceListStep extends AzureWizardPromptStep<ImageSourceContex
default:
}

promptSteps.push(new EnvironmentVariablesListStep());
if (!this.options?.suppressEnvPrompt) {
promptSteps.push(new EnvironmentVariablesListStep());
}

return { promptSteps, executeSteps };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils";
import { parseImageName } from "../../../../utils/imageNameUtils";
import { localize } from "../../../../utils/localize";
import { AzureWizardActivityOutputExecuteStep } from "../../../AzureWizardActivityOutputExecuteStep";
import { type ContainerRegistryImageSourceContext } from "./ContainerRegistryImageSourceContext";
import { getLoginServer } from "./getLoginServer";

export class ContainerRegistryImageConfigureStep extends AzureWizardExecuteStep<ContainerRegistryImageSourceContext> {
export class ContainerRegistryImageConfigureStep<T extends ContainerRegistryImageSourceContext> extends AzureWizardActivityOutputExecuteStep<T> {
public priority: number = 570;
public stepName: string = 'containerRegistryImageConfigureStep';
protected getSuccessString = (context: T) => localize('successOutput', 'Successfully set container app image to "{0}".', context.image);
protected getFailString = (context: T) => localize('failOutput', 'Failed to set container app image to "{0}".', context.image);
protected getTreeItemLabel = (context: T) => localize('treeItemLabel', 'Set container app image to "{0}"', context.image);

public async execute(context: ContainerRegistryImageSourceContext): Promise<void> {
public async execute(context: T): Promise<void> {
context.image = `${getLoginServer(context)}/${context.repositoryName}:${context.tag}`;

const { registryName, registryDomain } = parseImageName(context.image);
context.telemetry.properties.registryName = registryName;
context.telemetry.properties.registryDomain = registryDomain ?? 'other';
}

public shouldExecute(context: ContainerRegistryImageSourceContext): boolean {
public shouldExecute(context: T): boolean {
return !context.image;
}
}
44 changes: 0 additions & 44 deletions src/commands/image/updateImage/UpdateImageDraftStep.ts

This file was deleted.

80 changes: 0 additions & 80 deletions src/commands/image/updateImage/updateImage.ts

This file was deleted.

10 changes: 7 additions & 3 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { openGitHubRepo } from './gitHub/openGitHubRepo';
import { deployImageApi } from './image/deployImageApi/deployImageApi';
import { createAcr } from './image/imageSource/containerRegistry/acr/createAcr/createAcr';
import { openAcrBuildLogs } from './image/openAcrBuildLogs';
import { updateImage } from './image/updateImage/updateImage';
import { disableIngress } from './ingress/disableIngress/disableIngress';
import { editTargetPort } from './ingress/editTargetPort/editTargetPort';
import { enableIngress } from './ingress/enableIngress/enableIngress';
Expand All @@ -40,6 +39,8 @@ import { deleteScaleRule } from './scaling/scaleRule/deleteScaleRule/deleteScale
import { addSecret } from './secret/addSecret/addSecret';
import { deleteSecret } from './secret/deleteSecret/deleteSecret';
import { editSecretValue } from './secret/editSecret/editSecretValue';
import { updateContainer } from './updateContainer/updateContainer';
import { updateContainerImage } from './updateContainer/updateContainerImage/updateContainerImage';
import { addWorkspaceProjectWalkthrough } from './walkthrough/addWorkspaceProject';
import { azureSignInWalkthrough } from './walkthrough/azureSignIn';
import { cleanUpResourcesWalkthrough } from './walkthrough/cleanUpResources';
Expand All @@ -58,12 +59,15 @@ export function registerCommands(): void {
registerCommandWithTreeNodeUnwrapping('containerApps.deleteContainerApp', deleteContainerApp);
registerCommandWithTreeNodeUnwrapping('containerApps.editContainerApp', editContainerApp);
registerCommandWithTreeNodeUnwrapping('containerApps.openConsoleInPortal', openConsoleInPortal);
registerCommandWithTreeNodeUnwrapping('containerApps.updateImage', updateImage);
registerCommandWithTreeNodeUnwrapping('containerapps.toggleEnvironmentVariableVisibility',
registerCommandWithTreeNodeUnwrapping('containerApps.toggleEnvironmentVariableVisibility',
async (context: IActionContext, item: EnvironmentVariableItem) => {
await item.toggleValueVisibility(context);
});

// containers
registerCommandWithTreeNodeUnwrapping('containerApps.updateContainer', updateContainer);
registerCommandWithTreeNodeUnwrapping('containerApps.updateContainerImage', updateContainerImage);

// deploy
registerCommandWithTreeNodeUnwrapping('containerApps.deployImageApi', deployImageApi);
registerCommandWithTreeNodeUnwrapping('containerApps.deployRevisionDraft', deployRevisionDraft);
Expand Down
16 changes: 16 additions & 0 deletions src/commands/updateContainer/ContainerUpdateContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { type ExecuteActivityContext } from "@microsoft/vscode-azext-utils";
import { type SetTelemetryProps } from "../../telemetry/SetTelemetryProps";
import { type ContainerUpdateTelemetryProps as TelemetryProps } from "../../telemetry/commandTelemetryProps";
import { type IContainerAppContext } from "../IContainerAppContext";
import { type ImageSourceBaseContext } from "../image/imageSource/ImageSourceContext";

export interface ContainerUpdateBaseContext extends IContainerAppContext, ImageSourceBaseContext, ExecuteActivityContext {
containersIdx: number;
}

export type ContainerUpdateContext = ContainerUpdateBaseContext & SetTelemetryProps<TelemetryProps>;
Loading