-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy patheditTargetPort.ts
More file actions
41 lines (35 loc) · 2.28 KB
/
editTargetPort.ts
File metadata and controls
41 lines (35 loc) · 2.28 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizard, AzureWizardPromptStep, createSubscriptionContext, IActionContext, nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils";
import { ContainerAppItem } from "../../tree/ContainerAppItem";
import { IngressItem } from "../../tree/IngressItem";
import { localize } from "../../utils/localize";
import { pickContainerApp } from "../../utils/pickContainerApp";
import { ICreateContainerAppContext } from "../createContainerApp/ICreateContainerAppContext";
import { TargetPortStep } from "../createContainerApp/TargetPortStep";
import { updateIngressSettings } from "./updateIngressSettings";
export async function editTargetPort(context: IActionContext, node?: IngressItem): Promise<void> {
const { subscription, containerApp }: ContainerAppItem | IngressItem = node ?? await pickContainerApp(context);
const title: string = localize('updateTargetPort', 'Update Target Port');
const promptSteps: AzureWizardPromptStep<ICreateContainerAppContext>[] = [new TargetPortStep()];
const wizardContext: ICreateContainerAppContext = {
...context,
...createSubscriptionContext(subscription),
subscription,
managedEnvironmentId: nonNullProp(containerApp, 'managedEnvironmentId'),
defaultPort: containerApp.configuration?.ingress?.targetPort
};
const wizard: AzureWizard<ICreateContainerAppContext> = new AzureWizard(wizardContext, {
title,
promptSteps,
executeSteps: []
});
await wizard.prompt();
const ingress = nonNullValueAndProp(containerApp.configuration, 'ingress');
ingress.targetPort = wizardContext.targetPort;
const working: string = localize('updatingTargetPort', 'Updating target port to {0}...', ingress.targetPort);
const workCompleted: string = localize('updatedTargetPort', 'Updated target port to {0}', ingress.targetPort);
await updateIngressSettings(context, { ingress, subscription, containerApp, working, workCompleted });
}