-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60d08b2
commit 5ac8f07
Showing
9 changed files
with
142 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { ExecuteActivityContext } from "@microsoft/vscode-azext-utils"; | ||
import type { IContainerAppContext } from "../IContainerAppContext"; | ||
|
||
export interface IngressContext extends IContainerAppContext, ExecuteActivityContext { | ||
enableIngress?: boolean; | ||
enableExternal?: boolean; | ||
|
||
targetPort?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { AzureWizardExecuteStep, nonNullProp } from "@microsoft/vscode-azext-utils"; | ||
import type { Progress } from "vscode"; | ||
import { ext } from "../../extensionVariables"; | ||
import type { IContainerAppContext } from "../IContainerAppContext"; | ||
import { updateContainerApp } from "../deployContainerApp/updateContainerApp"; | ||
|
||
type IngressOptions = { | ||
ingress: Ingress | null, | ||
working: string, | ||
workCompleted: string | ||
} | ||
|
||
export abstract class IngressUpdateBaseStep<T extends IContainerAppContext> extends AzureWizardExecuteStep<T> { | ||
protected async updateIngressSettings(context: T, progress: Progress<{ message?: string | undefined}>, options: IngressOptions): Promise<void> { | ||
const containerApp = nonNullProp(context, 'containerApp'); | ||
const { ingress, working, workCompleted } = options; | ||
|
||
progress.report({ message: working }); | ||
await updateContainerApp(context, context.subscription, containerApp, { configuration: { ingress: ingress as Ingress | undefined } }); | ||
|
||
ext.outputChannel.appendLog(workCompleted); | ||
ext.state.notifyChildrenChanged(containerApp.managedEnvironmentId); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/commands/ingress/editTargetPort/TargetPortUpdateStep.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { localize } from "../../../utils/localize"; | ||
import type { IngressContext } from "../IngressContext"; | ||
import { IngressUpdateBaseStep } from "../IngressUpdateBaseStep"; | ||
|
||
export class TargetPortUpdateStep extends IngressUpdateBaseStep<IngressContext> { | ||
public priority: number = 280; | ||
|
||
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'); | ||
ingress.targetPort = context.targetPort; | ||
|
||
const working: string = localize('updatingTargetPort', 'Updating target port...'); | ||
const workCompleted: string = localize('updatedTargetPort', 'Updated target port to {0} for container app "{1}"', context.targetPort, containerApp.name); | ||
|
||
context.activityTitle = localize('updateTargetPort', 'Update target port to {0} for container app "{1}"', context.targetPort, containerApp.name); | ||
await this.updateIngressSettings(context, progress, { ingress, working, workCompleted }); | ||
} | ||
|
||
public shouldExecute(): boolean { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, createSubscriptionContext, IActionContext } from "@microsoft/vscode-azext-utils"; | ||
import type { ContainerAppItem } from "../../../tree/ContainerAppItem"; | ||
import { IngressItem } from "../../../tree/IngressItem"; | ||
import { createActivityContext } from "../../../utils/activityUtils"; | ||
import { localize } from "../../../utils/localize"; | ||
import { pickContainerApp } from "../../../utils/pickContainerApp"; | ||
import type { IngressContext } from "../IngressContext"; | ||
import { TargetPortInputStep } from "./TargetPortInputStep"; | ||
import { TargetPortUpdateStep } from "./TargetPortUpdateStep"; | ||
|
||
export async function editTargetPort(context: IActionContext, node?: IngressItem): Promise<void> { | ||
const { subscription, containerApp }: ContainerAppItem | IngressItem = node ?? await pickContainerApp(context); | ||
|
||
const wizardContext: IngressContext = { | ||
...context, | ||
...createSubscriptionContext(subscription), | ||
...(await createActivityContext()), | ||
subscription, | ||
containerApp | ||
}; | ||
|
||
const title: string = localize('updateTargetPort', 'Update target port for container app "{0}"', containerApp.name); | ||
|
||
const promptSteps: AzureWizardPromptStep<IngressContext>[] = [ | ||
new TargetPortInputStep() | ||
]; | ||
|
||
const executeSteps: AzureWizardExecuteStep<IngressContext>[] = [ | ||
new TargetPortUpdateStep() | ||
]; | ||
|
||
const wizard: AzureWizard<IngressContext> = new AzureWizard(wizardContext, { | ||
title, | ||
promptSteps, | ||
executeSteps, | ||
showLoadingPrompt: true | ||
}); | ||
|
||
await wizard.prompt(); | ||
await wizard.execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { IngressContext } from "../IngressContext"; | ||
|
||
export function getDefaultPort(context: IngressContext, fallbackPort: number = 80): number { | ||
return context.containerApp?.configuration?.ingress?.targetPort || fallbackPort; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters