|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | +* Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +* Licensed under the MIT License. See License.md in the project root for license information. |
| 4 | +*--------------------------------------------------------------------------------------------*/ |
| 5 | +import { VerifyProvidersStep } from "@microsoft/vscode-azext-azureutils"; |
| 6 | +import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, ITreeItemPickerContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; |
| 7 | +import { webProvider } from "../../constants"; |
| 8 | +import { ContainerAppItem } from "../../tree/ContainerAppItem"; |
| 9 | +import { localize } from "../../utils/localize"; |
| 10 | +import { pickContainerApp } from "../../utils/pickContainerApp"; |
| 11 | +import { ContainerAppOverwriteConfirmStep } from "./ContainerAppOverwriteConfirmStep"; |
| 12 | +import { ContainerAppUpdateStep } from "./ContainerAppUpdateStep"; |
| 13 | +import { IDeployBaseContext } from "./IDeployBaseContext"; |
| 14 | +import { ImageSourceListStep } from "./ImageSourceListStep"; |
| 15 | + |
| 16 | +export async function deploy(context: ITreeItemPickerContext & Partial<IDeployBaseContext>, node?: ContainerAppItem): Promise<void> { |
| 17 | + if (!node) { |
| 18 | + context.suppressCreatePick = true; |
| 19 | + node = await pickContainerApp(context); |
| 20 | + } |
| 21 | + |
| 22 | + const { subscription, containerApp } = node; |
| 23 | + |
| 24 | + const wizardContext: IDeployBaseContext = { |
| 25 | + ...context, |
| 26 | + ...createSubscriptionContext(subscription), |
| 27 | + subscription, |
| 28 | + targetContainer: containerApp |
| 29 | + }; |
| 30 | + |
| 31 | + const promptSteps: AzureWizardPromptStep<IDeployBaseContext>[] = [ |
| 32 | + new ContainerAppOverwriteConfirmStep(), |
| 33 | + new ImageSourceListStep() |
| 34 | + ]; |
| 35 | + |
| 36 | + const executeSteps: AzureWizardExecuteStep<IDeployBaseContext>[] = [ |
| 37 | + new VerifyProvidersStep([webProvider]), |
| 38 | + new ContainerAppUpdateStep() |
| 39 | + ]; |
| 40 | + |
| 41 | + const wizard: AzureWizard<IDeployBaseContext> = new AzureWizard(wizardContext, { |
| 42 | + title: localize('deploy', 'Deploying to "{0}"', containerApp.name), |
| 43 | + promptSteps, |
| 44 | + executeSteps, |
| 45 | + showLoadingPrompt: true |
| 46 | + }); |
| 47 | + |
| 48 | + await wizard.prompt(); |
| 49 | + await wizard.execute(); |
| 50 | +} |
0 commit comments