Skip to content

Commit 60d08b2

Browse files
authored
Create and extend from new IContainerAppContext (#370)
1 parent b16bd42 commit 60d08b2

25 files changed

+99
-96
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
7+
import { AzureSubscription } from "@microsoft/vscode-azureresources-api";
8+
import { ContainerAppModel } from "../tree/ContainerAppItem";
9+
10+
// Todo: Investigate consolidating 'ISubscriptionActionContext' and 'AzureSubscription'
11+
export interface IContainerAppContext extends ISubscriptionActionContext {
12+
subscription: AzureSubscription;
13+
containerApp?: ContainerAppModel;
14+
}

src/commands/createContainerApp/ContainerAppCreateStep.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { ContainerAppItem } from "../../tree/ContainerAppItem";
1313
import { createContainerAppsAPIClient } from "../../utils/azureClients";
1414
import { localize } from "../../utils/localize";
1515
import { getContainerNameForImage } from "../imageSource/containerRegistry/getContainerNameForImage";
16-
import { IContainerAppContext } from "./IContainerAppContext";
16+
import { ICreateContainerAppContext } from "./ICreateContainerAppContext";
1717

18-
export class ContainerAppCreateStep extends AzureWizardExecuteStep<IContainerAppContext> {
18+
export class ContainerAppCreateStep extends AzureWizardExecuteStep<ICreateContainerAppContext> {
1919
public priority: number = 250;
2020

21-
public async execute(context: IContainerAppContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
21+
public async execute(context: ICreateContainerAppContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
2222
const appClient: ContainerAppsAPIClient = await createContainerAppsAPIClient(context);
2323

2424
const ingress: Ingress | undefined = context.enableIngress ? {

src/commands/createContainerApp/ContainerAppNameStep.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { getResourceGroupFromId } from "@microsoft/vscode-azext-azureutils";
88
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
99
import { createContainerAppsAPIClient } from '../../utils/azureClients';
1010
import { localize } from "../../utils/localize";
11-
import { IContainerAppContext } from './IContainerAppContext';
11+
import { ICreateContainerAppContext } from './ICreateContainerAppContext';
1212

13-
export class ContainerAppNameStep extends AzureWizardPromptStep<IContainerAppContext> {
13+
export class ContainerAppNameStep extends AzureWizardPromptStep<ICreateContainerAppContext> {
1414
public hideStepCount: boolean = true;
1515

16-
public async prompt(context: IContainerAppContext): Promise<void> {
16+
public async prompt(context: ICreateContainerAppContext): Promise<void> {
1717
const prompt: string = localize('containerAppNamePrompt', 'Enter a name for the new container app.');
1818
context.newContainerAppName = (await context.ui.showInputBox({
1919
prompt,
@@ -23,11 +23,11 @@ export class ContainerAppNameStep extends AzureWizardPromptStep<IContainerAppCon
2323
context.valuesToMask.push(context.newContainerAppName);
2424
}
2525

26-
public shouldPrompt(context: IContainerAppContext): boolean {
26+
public shouldPrompt(context: ICreateContainerAppContext): boolean {
2727
return !context.newContainerAppName;
2828
}
2929

30-
private async validateInput(context: IContainerAppContext, name: string | undefined): Promise<string | undefined> {
30+
private async validateInput(context: ICreateContainerAppContext, name: string | undefined): Promise<string | undefined> {
3131
name = name ? name.trim() : '';
3232
// to prevent showing an error when the character types the first letter
3333

src/commands/createContainerApp/EnableIngressStep.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55

66
import { AzureWizardPromptStep, IWizardOptions } from "@microsoft/vscode-azext-utils";
77
import { localize } from "../../utils/localize";
8-
import { IContainerAppContext } from "./IContainerAppContext";
8+
import { ICreateContainerAppContext } from "./ICreateContainerAppContext";
99
import { IngressVisibilityStep } from "./IngressVisibilityStep";
1010
import { TargetPortStep } from "./TargetPortStep";
1111

12-
export class EnableIngressStep extends AzureWizardPromptStep<IContainerAppContext> {
13-
public async prompt(context: IContainerAppContext): Promise<void> {
12+
export class EnableIngressStep extends AzureWizardPromptStep<ICreateContainerAppContext> {
13+
public async prompt(context: ICreateContainerAppContext): Promise<void> {
1414
context.enableIngress = (await context.ui.showQuickPick([{ label: localize('enable', 'Enable'), data: true }, { label: localize('disable', 'Disable'), data: false }],
1515
{ placeHolder: localize('enableIngress', 'Enable ingress for applications that need an HTTP endpoint.') })).data;
1616

1717
}
1818

19-
public shouldPrompt(context: IContainerAppContext): boolean {
19+
public shouldPrompt(context: ICreateContainerAppContext): boolean {
2020
return context.enableIngress === undefined
2121
}
2222

23-
public async getSubWizard(context: IContainerAppContext): Promise<IWizardOptions<IContainerAppContext> | undefined> {
23+
public async getSubWizard(context: ICreateContainerAppContext): Promise<IWizardOptions<ICreateContainerAppContext> | undefined> {
2424
if (context.enableIngress) {
2525
return {
2626
promptSteps: [new IngressVisibilityStep(), new TargetPortStep()]

src/commands/createContainerApp/IContainerAppContext.ts renamed to src/commands/createContainerApp/ICreateContainerAppContext.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IResourceGroupWizardContext } from '@microsoft/vscode-azext-azureutils';
7-
import { ExecuteActivityContext } from "@microsoft/vscode-azext-utils";
8-
import { ContainerAppModel } from "../../tree/ContainerAppItem";
9-
import { IImageSourceBaseContext } from '../imageSource/IImageSourceBaseContext';
7+
import { IContainerAppContext } from '../IContainerAppContext';
8+
import { ImageSourceBaseContext } from '../imageSource/ImageSourceBaseContext';
109

11-
export interface IContainerAppContext extends IResourceGroupWizardContext, IImageSourceBaseContext {
10+
export interface ICreateContainerAppContext extends IResourceGroupWizardContext, ImageSourceBaseContext, IContainerAppContext {
1211
managedEnvironmentId: string;
1312
newContainerAppName?: string;
1413

@@ -17,9 +16,4 @@ export interface IContainerAppContext extends IResourceGroupWizardContext, IImag
1716

1817
defaultPort?: number;
1918
targetPort?: number;
20-
21-
// created when the wizard is done executing
22-
containerApp?: ContainerAppModel;
2319
}
24-
25-
export type IContainerAppWithActivityContext = IContainerAppContext & ExecuteActivityContext;

src/commands/createContainerApp/IngressVisibilityStep.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
77
import { IngressConstants } from "../../constants";
88
import { localize } from "../../utils/localize";
9-
import { IContainerAppContext } from "./IContainerAppContext";
9+
import { ICreateContainerAppContext } from "./ICreateContainerAppContext";
1010

11-
export class IngressVisibilityStep extends AzureWizardPromptStep<IContainerAppContext> {
12-
public async prompt(context: IContainerAppContext): Promise<void> {
11+
export class IngressVisibilityStep extends AzureWizardPromptStep<ICreateContainerAppContext> {
12+
public async prompt(context: ICreateContainerAppContext): Promise<void> {
1313
context.enableExternal = (await context.ui.showQuickPick([
1414
{ label: IngressConstants.external, description: IngressConstants.externalDesc, data: true },
1515
{ label: localize('internal', 'Internal'), description: IngressConstants.internalDesc, data: false }],
1616
{ placeHolder: localize('ingressVisibility', 'Select the HTTP traffic that the endpoint will accept.') })).data;
1717
}
1818

19-
public shouldPrompt(context: IContainerAppContext): boolean {
19+
public shouldPrompt(context: ICreateContainerAppContext): boolean {
2020
return context.enableIngress === true && context.enableExternal === undefined;
2121
}
2222
}

src/commands/createContainerApp/TargetPortStep.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
77
import { localize } from "../../utils/localize";
8-
import { IContainerAppContext } from "./IContainerAppContext";
8+
import { ICreateContainerAppContext } from "./ICreateContainerAppContext";
99

10-
export class TargetPortStep extends AzureWizardPromptStep<IContainerAppContext> {
11-
public async prompt(context: IContainerAppContext): Promise<void> {
10+
export class TargetPortStep extends AzureWizardPromptStep<ICreateContainerAppContext> {
11+
public async prompt(context: ICreateContainerAppContext): Promise<void> {
1212
context.targetPort = Number(await context.ui.showInputBox({
1313
prompt: localize('targetPort', 'This is the port your container is listening on that will receive traffic. Set this value to the port number that your container uses.'),
1414
value: String(context.defaultPort ?? 80),
1515
validateInput: this.validateInput
1616
}));
1717
}
1818

19-
public shouldPrompt(context: IContainerAppContext): boolean {
19+
public shouldPrompt(context: ICreateContainerAppContext): boolean {
2020
return !context.targetPort;
2121
}
2222

src/commands/createContainerApp/createContainerApp.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,45 @@ import { webProvider } from "../../constants";
99
import { ext } from "../../extensionVariables";
1010
import { ContainerAppItem } from "../../tree/ContainerAppItem";
1111
import { ManagedEnvironmentItem } from "../../tree/ManagedEnvironmentItem";
12-
import { createActivityContext } from "../../utils/activityUtils";
1312
import { localize } from "../../utils/localize";
1413
import { containerAppEnvironmentExperience } from "../../utils/pickContainerApp";
1514
import { ImageSourceListStep } from "../imageSource/ImageSourceListStep";
1615
import { ContainerAppCreateStep } from "./ContainerAppCreateStep";
1716
import { ContainerAppNameStep } from "./ContainerAppNameStep";
1817
import { EnableIngressStep } from "./EnableIngressStep";
19-
import { IContainerAppContext, IContainerAppWithActivityContext } from "./IContainerAppContext";
18+
import { ICreateContainerAppContext } from "./ICreateContainerAppContext";
2019
import { showContainerAppCreated } from "./showContainerAppCreated";
2120

22-
export async function createContainerApp(context: IActionContext & Partial<ICreateChildImplContext> & Partial<IContainerAppContext>, node?: ManagedEnvironmentItem): Promise<ContainerAppItem> {
21+
export async function createContainerApp(context: IActionContext & Partial<ICreateChildImplContext> & Partial<ICreateContainerAppContext>, node?: ManagedEnvironmentItem): Promise<ContainerAppItem> {
2322
node ??= await containerAppEnvironmentExperience(context, ext.rgApiV2.resources.azureResourceTreeDataProvider, {
2423
title: localize('createContainerApp', 'Create Container App'),
2524
});
2625

27-
const wizardContext: IContainerAppWithActivityContext = {
26+
const wizardContext: ICreateContainerAppContext = {
2827
...context,
2928
...createSubscriptionContext(node.subscription),
3029
subscription: node.subscription,
3130
managedEnvironmentId: node.managedEnvironment.id,
32-
...(await createActivityContext())
31+
// ...(await createActivityContext())
3332
};
3433

3534
const title: string = localize('createContainerApp', 'Create Container App');
3635

37-
const promptSteps: AzureWizardPromptStep<IContainerAppWithActivityContext>[] = [
36+
const promptSteps: AzureWizardPromptStep<ICreateContainerAppContext>[] = [
3837
new ContainerAppNameStep(),
3938
new ImageSourceListStep(),
4039
new EnableIngressStep(),
4140
];
4241

43-
const executeSteps: AzureWizardExecuteStep<IContainerAppWithActivityContext>[] = [
42+
const executeSteps: AzureWizardExecuteStep<ICreateContainerAppContext>[] = [
4443
new VerifyProvidersStep([webProvider]),
4544
new ContainerAppCreateStep(),
4645
];
4746

4847
wizardContext.newResourceGroupName = node.resource.resourceGroup;
4948
await LocationListStep.setLocation(wizardContext, nonNullProp(node.resource, 'location'));
5049

51-
const wizard: AzureWizard<IContainerAppWithActivityContext> = new AzureWizard(wizardContext, {
50+
const wizard: AzureWizard<ICreateContainerAppContext> = new AzureWizard(wizardContext, {
5251
title,
5352
promptSteps,
5453
executeSteps,
@@ -65,7 +64,7 @@ export async function createContainerApp(context: IActionContext & Partial<ICrea
6564
node.managedEnvironment.id,
6665
localize('creatingContainerApp', 'Creating Container App "{0}"...', newContainerAppName),
6766
async () => {
68-
wizardContext.activityTitle = localize('createNamedContainerApp', 'Create Container App "{0}"', newContainerAppName);
67+
// wizardContext.activityTitle = localize('createNamedContainerApp', 'Create Container App "{0}"', newContainerAppName);
6968
await wizard.execute();
7069
});
7170

src/commands/createContainerApp/setQuickStartImage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { quickStartImageName } from "../../constants";
7-
import { IContainerAppContext } from "./IContainerAppContext";
7+
import { ICreateContainerAppContext } from "./ICreateContainerAppContext";
88

9-
export function setQuickStartImage(context: Partial<IContainerAppContext>): void {
9+
export function setQuickStartImage(context: Partial<ICreateContainerAppContext>): void {
1010
context.image = quickStartImageName;
1111
context.enableIngress = true;
1212
context.enableExternal = true;

src/commands/deployContainerApp/ContainerAppOverwriteConfirmStep.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class ContainerAppOverwriteConfirmStep extends AzureWizardPromptStep<IDep
1414
public hideStepCount: boolean = true;
1515

1616
public async prompt(context: IDeployContainerAppContext): Promise<void> {
17-
const containerApp: ContainerAppModel = nonNullProp(context, 'targetContainer');
17+
const containerApp: ContainerAppModel = nonNullProp(context, 'containerApp');
1818
const warning: string = containerApp.revisionsMode === KnownActiveRevisionsMode.Single ?
1919
localize('confirmDeploySingle', 'Are you sure you want to deploy to "{0}"? This will overwrite the active revision and unsupported features in VS Code will be lost.', containerApp.name) :
2020
localize('confirmDeployMultiple', 'Are you sure you want to deploy to "{0}"? Unsupported features in VS Code will be lost in the new revision.', containerApp.name);
@@ -24,12 +24,12 @@ export class ContainerAppOverwriteConfirmStep extends AzureWizardPromptStep<IDep
2424
}
2525

2626
public shouldPrompt(context: IDeployContainerAppContext): boolean {
27-
return !!context.targetContainer && this.hasUnsupportedFeatures(context);
27+
return !!context.containerApp && this.hasUnsupportedFeatures(context);
2828
}
2929

3030
// Check for any portal features that VS Code doesn't currently support
3131
private hasUnsupportedFeatures(context: IDeployContainerAppContext): boolean {
32-
const containerApp: ContainerAppModel = nonNullProp(context, 'targetContainer');
32+
const containerApp: ContainerAppModel = nonNullProp(context, 'containerApp');
3333
if (containerApp.template?.volumes) {
3434
return true;
3535
} else if (containerApp.template?.containers) {

0 commit comments

Comments
 (0)