-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathToggleIngressVisibilityStep.ts
More file actions
33 lines (26 loc) · 2.02 KB
/
ToggleIngressVisibilityStep.ts
File metadata and controls
33 lines (26 loc) · 2.02 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils";
import type { Progress } from "vscode";
import { IngressConstants } from "../../../constants";
import { localize } from "../../../utils/localize";
import type { IngressContext } from "../IngressContext";
import { IngressUpdateStepBase } from "../IngressUpdateStepBase";
export class ToggleIngressVisibilityStep extends IngressUpdateStepBase<IngressContext> {
public priority: number = 750;
public async execute(context: IngressContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
const containerApp = nonNullProp(context, 'containerApp');
const ingress = nonNullValueAndProp(containerApp.configuration, 'ingress');
const warningPrompt = localize('visibilityWarning', 'This will change the ingress visibility from "{0}" to "{1}".', ingress.external ? IngressConstants.external : IngressConstants.internal, !ingress.external ? IngressConstants.external : IngressConstants.internal)
await context.ui.showWarningMessage(warningPrompt, { modal: true }, { title: localize('continue', 'Continue') });
ingress.external = !ingress.external;
const working: string = localize('updatingVisibility', 'Updating ingress visibility...');
const workCompleted: string = localize('updatedVisibility', 'Updated container app "{0}" ingress visibility to "{1}"', containerApp.name, ingress.external ? IngressConstants.external : IngressConstants.internal);
await this.updateIngressSettings(context, progress, { ingress, working, workCompleted });
}
public shouldExecute(): boolean {
return true;
}
}