-
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
Showing
46 changed files
with
1,295 additions
and
304 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"tsaVersion": "TsaV2", | ||
"codeBase": "NewOrUpdate", | ||
"codeBaseName": "vscode-azurecontainerapps", | ||
"tsaStamp": "DevDiv", | ||
"notificationAliases": [ | ||
"[email protected]" | ||
], | ||
"codebaseAdmins": [ | ||
"REDMOND\\jinglou", | ||
"REDMOND\\AzCode" | ||
], | ||
"instanceUrl": "https://devdiv.visualstudio.com", | ||
"projectName": "DevDiv", | ||
"areaPath": "DevDiv\\VS Azure Tools\\AzCode Extensions", | ||
"iterationPath": "DevDiv", | ||
"allTools": 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
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
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,16 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 SetTelemetryProps } from "../../telemetry/SetTelemetryProps"; | ||
import { type ContainerUpdateTelemetryProps as TelemetryProps } from "../../telemetry/commandTelemetryProps"; | ||
import { type IContainerAppContext } from "../IContainerAppContext"; | ||
import { type ImageSourceBaseContext } from "../image/imageSource/ImageSourceContext"; | ||
|
||
export interface ContainerEditBaseContext extends IContainerAppContext, ImageSourceBaseContext, ExecuteActivityContext { | ||
containersIdx: number; | ||
} | ||
|
||
export type ContainerEditContext = ContainerEditBaseContext & SetTelemetryProps<TelemetryProps>; |
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,74 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { type Container, type Revision } from "@azure/arm-appcontainers"; | ||
import { activityFailContext, activityFailIcon, activityProgressContext, activityProgressIcon, activitySuccessContext, activitySuccessIcon, createUniversallyUniqueContextValue, GenericParentTreeItem, GenericTreeItem, nonNullProp, type ExecuteActivityOutput } from "@microsoft/vscode-azext-utils"; | ||
import { type Progress } from "vscode"; | ||
import { type ContainerAppItem, type ContainerAppModel } from "../../tree/ContainerAppItem"; | ||
import { type RevisionsItemModel } from "../../tree/revisionManagement/RevisionItem"; | ||
import { localize } from "../../utils/localize"; | ||
import { getParentResourceFromItem } from "../../utils/revisionDraftUtils"; | ||
import { getContainerNameForImage } from "../image/imageSource/containerRegistry/getContainerNameForImage"; | ||
import { RevisionDraftUpdateBaseStep } from "../revisionDraft/RevisionDraftUpdateBaseStep"; | ||
import { type ContainerEditContext } from "./ContainerEditContext"; | ||
|
||
export class ContainerEditDraftStep<T extends ContainerEditContext> extends RevisionDraftUpdateBaseStep<T> { | ||
public priority: number = 590; | ||
|
||
constructor(baseItem: ContainerAppItem | RevisionsItemModel) { | ||
super(baseItem); | ||
} | ||
|
||
public async execute(context: T, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> { | ||
progress.report({ message: localize('editingContainer', 'Editing container (draft)...') }); | ||
this.revisionDraftTemplate.containers ??= []; | ||
|
||
const container: Container = this.revisionDraftTemplate.containers[context.containersIdx] ?? {}; | ||
container.name = getContainerNameForImage(nonNullProp(context, 'image')); | ||
container.image = context.image; | ||
container.env = context.environmentVariables; | ||
|
||
await this.updateRevisionDraftWithTemplate(context); | ||
} | ||
|
||
public shouldExecute(context: T): boolean { | ||
return context.containersIdx !== undefined && !!context.image; | ||
} | ||
|
||
public createSuccessOutput(): ExecuteActivityOutput { | ||
const parentResource: ContainerAppModel | Revision = getParentResourceFromItem(this.baseItem); | ||
return { | ||
item: new GenericTreeItem(undefined, { | ||
contextValue: createUniversallyUniqueContextValue(['containerEditDraftStepSuccessItem', activitySuccessContext]), | ||
label: localize('editContainer', 'Edit container profile for container app "{0}" (draft)', parentResource.name), | ||
iconPath: activitySuccessIcon, | ||
}), | ||
message: localize('editContainerSuccess', 'Successfully edited container profile for container app "{0}" (draft).', parentResource.name), | ||
}; | ||
} | ||
|
||
public createProgressOutput(): ExecuteActivityOutput { | ||
const parentResource: ContainerAppModel | Revision = getParentResourceFromItem(this.baseItem); | ||
return { | ||
item: new GenericTreeItem(undefined, { | ||
contextValue: createUniversallyUniqueContextValue(['containerEditDraftStepProgressItem', activityProgressContext]), | ||
label: localize('editContainer', 'Edit container profile for container app "{0}" (draft)', parentResource.name), | ||
iconPath: activityProgressIcon, | ||
}), | ||
}; | ||
} | ||
|
||
public createFailOutput(): ExecuteActivityOutput { | ||
const parentResource: ContainerAppModel | Revision = getParentResourceFromItem(this.baseItem); | ||
return { | ||
item: new GenericParentTreeItem(undefined, { | ||
contextValue: createUniversallyUniqueContextValue(['containerEditDraftStepFailItem', activityFailContext]), | ||
label: localize('editContainer', 'Edit container profile for container app "{0}" (draft)', parentResource.name), | ||
iconPath: activityFailIcon, | ||
}), | ||
message: localize('editContainerFail', 'Failed to edit container profile for container app "{0}" (draft).', parentResource.name), | ||
}; | ||
} | ||
} |
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,70 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { type Revision } from "@azure/arm-appcontainers"; | ||
import { AzureWizard, createSubscriptionContext, type IActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils"; | ||
import { type ContainerAppModel } from "../../tree/ContainerAppItem"; | ||
import { type ContainerItem } from "../../tree/containers/ContainerItem"; | ||
import { ContainersItem } from "../../tree/containers/ContainersItem"; | ||
import { createActivityContext } from "../../utils/activityUtils"; | ||
import { getManagedEnvironmentFromContainerApp } from "../../utils/getResourceUtils"; | ||
import { getVerifyProvidersStep } from "../../utils/getVerifyProvidersStep"; | ||
import { localize } from "../../utils/localize"; | ||
import { pickContainer } from "../../utils/pickItem/pickContainer"; | ||
import { getParentResourceFromItem, isTemplateItemEditable, TemplateItemNotEditableError } from "../../utils/revisionDraftUtils"; | ||
import { ImageSourceListStep } from "../image/imageSource/ImageSourceListStep"; | ||
import { RevisionDraftDeployPromptStep } from "../revisionDraft/RevisionDraftDeployPromptStep"; | ||
import { type ContainerEditContext } from "./ContainerEditContext"; | ||
import { ContainerEditDraftStep } from "./ContainerEditDraftStep"; | ||
import { RegistryAndSecretsUpdateStep } from "./RegistryAndSecretsUpdateStep"; | ||
|
||
// Edits both the 'image' and 'environmentVariables' portion of the container profile (draft) | ||
export async function editContainer(context: IActionContext, node?: ContainersItem | ContainerItem): Promise<void> { | ||
const item: ContainerItem | ContainersItem = node ?? await pickContainer(context, { autoSelectDraft: true }); | ||
const { containerApp, subscription } = item; | ||
|
||
if (!isTemplateItemEditable(item)) { | ||
throw new TemplateItemNotEditableError(item); | ||
} | ||
|
||
const subscriptionContext: ISubscriptionContext = createSubscriptionContext(subscription); | ||
const parentResource: ContainerAppModel | Revision = getParentResourceFromItem(item); | ||
|
||
let containersIdx: number; | ||
if (ContainersItem.isContainersItem(item)) { | ||
// The 'editContainer' command should only show up on a 'ContainersItem' when it only has one container, else the command would show up on the 'ContainerItem' | ||
containersIdx = 0; | ||
} else { | ||
containersIdx = item.containersIdx; | ||
} | ||
|
||
const wizardContext: ContainerEditContext = { | ||
...context, | ||
...subscriptionContext, | ||
...await createActivityContext(true), | ||
subscription, | ||
managedEnvironment: await getManagedEnvironmentFromContainerApp({ ...context, ...subscriptionContext }, containerApp), | ||
containerApp, | ||
containersIdx, | ||
}; | ||
wizardContext.telemetry.properties.revisionMode = containerApp.revisionsMode; | ||
|
||
const wizard: AzureWizard<ContainerEditContext> = new AzureWizard(wizardContext, { | ||
title: localize('editContainer', 'Edit container profile for "{0}" (draft)', parentResource.name), | ||
promptSteps: [ | ||
new ImageSourceListStep(), | ||
new RevisionDraftDeployPromptStep(), | ||
], | ||
executeSteps: [ | ||
getVerifyProvidersStep<ContainerEditContext>(), | ||
new RegistryAndSecretsUpdateStep(), | ||
new ContainerEditDraftStep(item), | ||
], | ||
showLoadingPrompt: true, | ||
}); | ||
|
||
await wizard.prompt(); | ||
await wizard.execute(); | ||
} |
Oops, something went wrong.