-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcreateContainerApp.ts
More file actions
76 lines (64 loc) · 3.67 KB
/
createContainerApp.ts
File metadata and controls
76 lines (64 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { LocationListStep, VerifyProvidersStep } from "@microsoft/vscode-azext-azureutils";
import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, IActionContext, ICreateChildImplContext, createSubscriptionContext, nonNullProp } from "@microsoft/vscode-azext-utils";
import { webProvider } from "../../constants";
import { ext } from "../../extensionVariables";
import { ContainerAppItem } from "../../tree/ContainerAppItem";
import type { ManagedEnvironmentItem } from "../../tree/ManagedEnvironmentItem";
import { createActivityContext } from "../../utils/activityUtils";
import { localize } from "../../utils/localize";
import { pickEnvironment } from "../../utils/pickItem/pickEnvironment";
import { ImageSourceListStep } from "../deployImage/imageSource/ImageSourceListStep";
import { IngressPromptStep } from "../ingress/IngressPromptStep";
import { ContainerAppCreateStep } from "./ContainerAppCreateStep";
import { ContainerAppNameStep } from "./ContainerAppNameStep";
import type { ICreateContainerAppContext } from "./ICreateContainerAppContext";
import { showContainerAppCreated } from "./showContainerAppCreated";
export async function createContainerApp(context: IActionContext & Partial<ICreateChildImplContext> & Partial<ICreateContainerAppContext>, node?: ManagedEnvironmentItem): Promise<ContainerAppItem> {
node ??= await pickEnvironment(context, {
title: localize('createContainerApp', 'Create Container App'),
});
const wizardContext: ICreateContainerAppContext = {
...context,
...createSubscriptionContext(node.subscription),
...(await createActivityContext()),
subscription: node.subscription,
managedEnvironmentId: node.managedEnvironment.id,
alwaysPromptIngress: true
};
const title: string = localize('createContainerApp', 'Create Container App');
const promptSteps: AzureWizardPromptStep<ICreateContainerAppContext>[] = [
new ContainerAppNameStep(),
new ImageSourceListStep(),
new IngressPromptStep(),
];
const executeSteps: AzureWizardExecuteStep<ICreateContainerAppContext>[] = [
new VerifyProvidersStep([webProvider]),
new ContainerAppCreateStep(),
];
wizardContext.newResourceGroupName = node.resource.resourceGroup;
await LocationListStep.setLocation(wizardContext, nonNullProp(node.resource, 'location'));
const wizard: AzureWizard<ICreateContainerAppContext> = new AzureWizard(wizardContext, {
title,
promptSteps,
executeSteps,
showLoadingPrompt: true
});
// we want to add the quick start image _only_ for the create scenairo
wizardContext.showQuickStartImage = true;
await wizard.prompt();
const newContainerAppName = nonNullProp(wizardContext, 'newContainerAppName');
await ext.state.showCreatingChild(
node.managedEnvironment.id,
localize('creatingContainerApp', 'Creating Container App "{0}"...', newContainerAppName),
async () => {
wizardContext.activityTitle = localize('createNamedContainerApp', 'Create Container App "{0}"', newContainerAppName);
await wizard.execute();
});
const createdContainerApp = nonNullProp(wizardContext, 'containerApp');
void showContainerAppCreated(createdContainerApp);
return new ContainerAppItem(node.subscription, createdContainerApp);
}