-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtoggleIngressVisibility.ts
More file actions
47 lines (39 loc) · 2.41 KB
/
toggleIngressVisibility.ts
File metadata and controls
47 lines (39 loc) · 2.41 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { type Ingress } from "@azure/arm-appcontainers";
import { AzureWizard, createSubscriptionContext, nonNullValueAndProp, type AzureWizardExecuteStep, type IActionContext } from "@microsoft/vscode-azext-utils";
import { IngressConstants } from "../../../constants";
import { ext } from "../../../extensionVariables";
import { type ContainerAppItem } from "../../../tree/ContainerAppItem";
import { type IngressEnabledItem } from "../../../tree/configurations/IngressItem";
import { createActivityContext } from "../../../utils/activityUtils";
import { localize } from "../../../utils/localize";
import { pickContainerApp } from "../../../utils/pickItem/pickContainerApp";
import { type IngressBaseContext } from "../IngressContext";
import { ToggleIngressVisibilityStep } from "./ToggleIngressVisibilityStep";
export async function toggleIngressVisibility(context: IActionContext, node?: IngressEnabledItem | ContainerAppItem): Promise<void> {
const { subscription, containerApp } = node ?? await pickContainerApp(context);
const wizardContext: IngressBaseContext = {
...context,
...createSubscriptionContext(subscription),
...(await createActivityContext()),
subscription,
containerApp
};
const ingress: Ingress = nonNullValueAndProp(containerApp.configuration, 'ingress');
const title: string = localize('toggleIngressVisibility', 'Switch ingress visibility to "{0}" for container app "{1}"', ingress.external ? IngressConstants.internal : IngressConstants.external, containerApp.name);
const executeSteps: AzureWizardExecuteStep<IngressBaseContext>[] = [
new ToggleIngressVisibilityStep()
];
const wizard: AzureWizard<IngressBaseContext> = new AzureWizard(wizardContext, {
title,
executeSteps,
showLoadingPrompt: true
});
// Title normally gets set during prompt phase... since no prompt steps are provided we must set the 'activityTitle' manually
wizardContext.activityTitle = title;
await wizard.execute();
ext.state.notifyChildrenChanged(containerApp.managedEnvironmentId);
}