-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathImageSourceListStep.ts
More file actions
65 lines (55 loc) · 3.35 KB
/
ImageSourceListStep.ts
File metadata and controls
65 lines (55 loc) · 3.35 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardExecuteStep, AzureWizardPromptStep, IAzureQuickPickItem, IWizardOptions } from "@microsoft/vscode-azext-utils";
import { ImageSource, ImageSourceValues } from "../../constants";
import { localize } from "../../utils/localize";
import { setQuickStartImage } from "../createContainerApp/setQuickStartImage";
import { EnvironmentVariablesListStep } from "./EnvironmentVariablesListStep";
import { IDeployBaseContext } from "./IDeployBaseContext";
import { BuildFromProjectListStep } from "./buildImageInAzure/BuildFromProjectListStep";
import { ContainerRegistryListStep } from "./deployFromRegistry/ContainerRegistryListStep";
import { DeployFromRegistryConfigureStep } from "./deployFromRegistry/DeployFromRegistryConfigureStep";
export class ImageSourceListStep extends AzureWizardPromptStep<IDeployBaseContext> {
public async prompt(context: IDeployBaseContext): Promise<void> {
const imageSourceLabels: string[] = [
localize('externalRegistry', 'Use existing image'),
localize('quickStartImage', 'Use quickstart image'),
localize('buildFromProject', 'Build from project remotely using Azure Container Registry'),
];
const placeHolder: string = localize('imageBuildSourcePrompt', 'Select an image source for the container app');
const picks: IAzureQuickPickItem<ImageSourceValues | undefined>[] = [
{ label: imageSourceLabels[0], data: ImageSource.ExternalRegistry, suppressPersistence: true },
{ label: imageSourceLabels[2], data: ImageSource.RemoteAcrBuild, suppressPersistence: true },
];
if (context.showQuickStartImage) {
picks.unshift({ label: imageSourceLabels[1], data: ImageSource.QuickStartImage, suppressPersistence: true });
}
context.imageSource = (await context.ui.showQuickPick(picks, { placeHolder })).data;
}
public shouldPrompt(context: IDeployBaseContext): boolean {
return !context.imageSource;
}
public async getSubWizard(context: IDeployBaseContext): Promise<IWizardOptions<IDeployBaseContext> | undefined> {
const promptSteps: AzureWizardPromptStep<IDeployBaseContext>[] = [];
const executeSteps: AzureWizardExecuteStep<IDeployBaseContext>[] = [];
switch (context.imageSource) {
case ImageSource.QuickStartImage:
setQuickStartImage(context);
break;
case ImageSource.ExternalRegistry:
promptSteps.push(new ContainerRegistryListStep());
executeSteps.push(new DeployFromRegistryConfigureStep());
break;
case ImageSource.RemoteAcrBuild:
promptSteps.push(new BuildFromProjectListStep());
executeSteps.push(new DeployFromRegistryConfigureStep());
break;
default:
// Todo: Steps that lead to additional 'Build from project' options
}
promptSteps.push(new EnvironmentVariablesListStep());
return { promptSteps, executeSteps };
}
}