-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdeployImage.ts
More file actions
62 lines (53 loc) · 3.21 KB
/
deployImage.ts
File metadata and controls
62 lines (53 loc) · 3.21 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizard, createSubscriptionContext, type AzureWizardPromptStep, type IActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
import { type ContainerAppItem } from "../../../tree/ContainerAppItem";
import { createActivityContext } from "../../../utils/activityUtils";
import { getManagedEnvironmentFromContainerApp } from "../../../utils/getResourceUtils";
import { getVerifyProvidersStep } from "../../../utils/getVerifyProvidersStep";
import { getImageNameWithoutTag } from "../../../utils/imageNameUtils";
import { localize } from "../../../utils/localize";
import { ContainerAppOverwriteConfirmStep } from "../../ContainerAppOverwriteConfirmStep";
import { showContainerAppNotification } from "../../createContainerApp/showContainerAppNotification";
import { IngressPromptStep } from "../../ingress/IngressPromptStep";
import { ContainerAppUpdateStep } from "../imageSource/ContainerAppUpdateStep";
import { ImageSourceListStep } from "../imageSource/ImageSourceListStep";
import { type ContainerRegistryImageSourceContext } from "../imageSource/containerRegistry/ContainerRegistryImageSourceContext";
import { type DeployImageApiContext } from "./deployImageApi";
export async function deployImage(context: IActionContext & Partial<ContainerRegistryImageSourceContext>, node: ContainerAppItem): Promise<void> {
const { subscription, containerApp } = node;
const subscriptionContext: ISubscriptionContext = createSubscriptionContext(subscription);
const wizardContext: DeployImageApiContext = {
...context,
...subscriptionContext,
...await createActivityContext(),
subscription,
managedEnvironment: await getManagedEnvironmentFromContainerApp({ ...context, ...subscriptionContext }, containerApp),
containerApp,
};
wizardContext.telemetry.properties.revisionMode = containerApp.revisionsMode;
const promptSteps: AzureWizardPromptStep<DeployImageApiContext>[] = [
new ImageSourceListStep(),
];
// If more than the image tag changed, prompt for ingress again
if (getImageNameWithoutTag(wizardContext.containerApp?.template?.containers?.[0].image ?? '') !== getImageNameWithoutTag(wizardContext.image ?? '')) {
promptSteps.push(new IngressPromptStep());
}
promptSteps.push(new ContainerAppOverwriteConfirmStep());
const wizard: AzureWizard<DeployImageApiContext> = new AzureWizard(wizardContext, {
title: localize('deploy', 'Deploy image to container app "{0}"', containerApp.name),
promptSteps,
executeSteps: [
getVerifyProvidersStep<DeployImageApiContext>(),
new ContainerAppUpdateStep(),
],
showLoadingPrompt: true
});
await wizard.prompt();
await wizard.execute();
if (!wizardContext.suppressNotification) {
void showContainerAppNotification(containerApp, true /** isUpdate */);
}
}