Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra guard clauses to deployment commands #815

Merged
merged 35 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
87841ca
Initial scaffold for deployContainerApp
MicroFish91 Dec 18, 2024
1088867
Improve wizard title
MicroFish91 Dec 18, 2024
3e85ad6
Add retries for failed updates
MicroFish91 Dec 18, 2024
e0a7003
Update throw condition
MicroFish91 Dec 18, 2024
c35bd08
Improve activity children and output logs
MicroFish91 Dec 19, 2024
ef87f0f
Add todo
MicroFish91 Dec 19, 2024
631be79
Add resource output logs
MicroFish91 Dec 19, 2024
b537741
Add comment
MicroFish91 Dec 19, 2024
146661f
Merge branch 'mwf/adorable-plum' of https://github.com/microsoft/vsco…
MicroFish91 Dec 19, 2024
e4ede57
Fix a log message
MicroFish91 Dec 19, 2024
7906366
Always prompt registry
MicroFish91 Dec 19, 2024
7c8d543
Improvements to finding recommended pick
MicroFish91 Dec 19, 2024
b8a81fb
Impl
MicroFish91 Dec 20, 2024
a5db872
Add fix for imageSourceListStep
MicroFish91 Dec 20, 2024
c9292be
Merge branch 'mwf/homely-emerald' of https://github.com/microsoft/vsc…
MicroFish91 Dec 20, 2024
1feaddd
Improve placeHolder prompt
MicroFish91 Dec 20, 2024
a139430
Fix deployImage
MicroFish91 Dec 20, 2024
f2cd6a7
Merge branch 'mwf/homely-emerald' of https://github.com/microsoft/vsc…
MicroFish91 Dec 20, 2024
300a5da
Merge with main
MicroFish91 Dec 21, 2024
2d05935
Improve acr pick recommendations
MicroFish91 Dec 24, 2024
209d1ac
Only sort if sr exists
MicroFish91 Dec 24, 2024
e2c87c6
Add draft boolean to context and register more children for editConta…
MicroFish91 Dec 24, 2024
7a8787c
Update editContainerImage
MicroFish91 Dec 24, 2024
eff6574
Improve comment
MicroFish91 Dec 24, 2024
5b22cc9
Improve comment again
MicroFish91 Dec 24, 2024
bd3e538
Add guard clauses to key commands
MicroFish91 Dec 24, 2024
57661f6
Small improvements
MicroFish91 Dec 24, 2024
d2eddbb
Make pick description search case insensitive
MicroFish91 Dec 24, 2024
4ec09bb
Change to pickUtils
MicroFish91 Dec 24, 2024
85eba7d
Consolidate with pickUtils
MicroFish91 Dec 26, 2024
85d8d1c
Merge branch 'mwf/fiscal-beige' of https://github.com/microsoft/vscod…
MicroFish91 Dec 26, 2024
ac5b4dc
Merge branch 'mwf/obliged-gold' of https://github.com/microsoft/vscod…
MicroFish91 Dec 26, 2024
6a98700
Feedback
MicroFish91 Dec 27, 2024
08428a0
Remove container app name
MicroFish91 Dec 27, 2024
1c709a0
Merge with main
MicroFish91 Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
},
{
"command": "containerApps.deployContainerApp",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem/i",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem(.*)revisionMode:single/i",
"group": "2@1"
},
{
Expand Down
11 changes: 11 additions & 0 deletions src/commands/deployContainerApp/deployContainerApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { KnownActiveRevisionsMode } from "@azure/arm-appcontainers";
import { type ResourceGroup } from "@azure/arm-resources";
import { LocationListStep, ResourceGroupListStep } from "@microsoft/vscode-azext-azureutils";
import { activityInfoIcon, activitySuccessContext, AzureWizard, createSubscriptionContext, createUniversallyUniqueContextValue, GenericTreeItem, nonNullProp, nonNullValue, type IActionContext, type ISubscriptionActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
Expand All @@ -16,15 +17,25 @@ import { getVerifyProvidersStep } from "../../utils/getVerifyProvidersStep";
import { localize } from "../../utils/localize";
import { pickContainerApp } from "../../utils/pickItem/pickContainerApp";
import { deployWorkspaceProject } from "../deployWorkspaceProject/deployWorkspaceProject";
import { editContainerCommandName } from "../editContainer/editContainer";
import { ContainerAppUpdateStep } from "../image/imageSource/ContainerAppUpdateStep";
import { ImageSourceListStep } from "../image/imageSource/ImageSourceListStep";
import { type ContainerAppDeployContext } from "./ContainerAppDeployContext";

const deployContainerAppCommandName: string = localize('deployContainerApp', 'Deploy to Container App...');

export async function deployContainerApp(context: IActionContext, node?: ContainerAppItem): Promise<void> {
const item: ContainerAppItem = node ?? await pickContainerApp(context);
const subscriptionContext: ISubscriptionContext = createSubscriptionContext(item.subscription);
const subscriptionActionContext: ISubscriptionActionContext = { ...context, ...subscriptionContext };

if (item.containerApp.revisionsMode === KnownActiveRevisionsMode.Multiple) {
throw new Error(localize('multipleRevisionsNotSupported', 'The container app cannot be updated using "{0}" while in multiple revisions mode. Navigate to the revision\'s container and execute "{1}" instead.', deployContainerAppCommandName, editContainerCommandName));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add these error strings to the const file.

}
if ((item.containerApp.template?.containers?.length ?? 0) > 1) {
throw new Error(localize('multipleContainersNotSupported', 'The container app cannot be updated using "{0}" while having more than one active container. Navigate to the specific container instance and execute "{1}" instead.', deployContainerAppCommandName, editContainerCommandName));
}

// Prompt for image source before initializing the wizard in case we need to redirect the call to 'deployWorkspaceProject' instead
const imageSource: ImageSource = await promptImageSource(subscriptionActionContext);
if (imageSource === ImageSource.RemoteAcrBuild) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { type DeployWorkspaceProjectInternalContext } from "./internal/DeployWor
import { deployWorkspaceProjectInternal } from "./internal/deployWorkspaceProjectInternal";
import { convertV1ToV2SettingsSchema } from "./settings/convertSettings/convertV1ToV2SettingsSchema";

export const deployWorkspaceProjectCommandName: string = localize('deployWorkspaceProject', 'Deploy Project from Workspace...');

export async function deployWorkspaceProject(context: IActionContext & Partial<DeployWorkspaceProjectContext>, item?: ContainerAppItem | ManagedEnvironmentItem): Promise<DeployWorkspaceProjectResults> {
// If an incompatible tree item is passed, treat it as if no item was passed
if (item && !ContainerAppItem.isContainerAppItem(item) && !ManagedEnvironmentItem.isManagedEnvironmentItem(item)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { KnownActiveRevisionsMode } from "@azure/arm-appcontainers";
import { LocationListStep, ResourceGroupCreateStep } from "@microsoft/vscode-azext-azureutils";
import { AzureWizard, GenericTreeItem, activityInfoIcon, activitySuccessContext, createUniversallyUniqueContextValue, nonNullValueAndProp, type AzureWizardExecuteStep, type AzureWizardPromptStep, type ExecuteActivityContext } from "@microsoft/vscode-azext-utils";
import { ProgressLocation, window } from "vscode";
Expand All @@ -14,9 +15,11 @@ import { localize } from "../../../utils/localize";
import { ContainerAppCreateStep } from "../../createContainerApp/ContainerAppCreateStep";
import { LogAnalyticsCreateStep } from "../../createManagedEnvironment/LogAnalyticsCreateStep";
import { ManagedEnvironmentCreateStep } from "../../createManagedEnvironment/ManagedEnvironmentCreateStep";
import { editContainerCommandName } from "../../editContainer/editContainer";
import { ContainerAppUpdateStep } from "../../image/imageSource/ContainerAppUpdateStep";
import { ImageSourceListStep } from "../../image/imageSource/ImageSourceListStep";
import { IngressPromptStep } from "../../ingress/IngressPromptStep";
import { deployWorkspaceProjectCommandName } from "../deployWorkspaceProject";
import { formatSectionHeader } from "../formatSectionHeader";
import { AppResourcesNameStep } from "./AppResourcesNameStep";
import { DeployWorkspaceProjectConfirmStep } from "./DeployWorkspaceProjectConfirmStep";
Expand Down Expand Up @@ -78,6 +81,13 @@ export async function deployWorkspaceProjectInternal(
startingConfiguration = await getStartingConfiguration({ ...context });
});

if (startingConfiguration?.containerApp?.revisionsMode === KnownActiveRevisionsMode.Multiple) {
throw new Error(localize('multipleRevisionsNotSupported', 'The container app cannot be updated using "{0}" while in multiple revisions mode. Navigate to the revision\'s container and execute "{1}" instead.', deployWorkspaceProjectCommandName, editContainerCommandName));
}
if ((startingConfiguration?.containerApp?.template?.containers?.length ?? 0) > 1) {
throw new Error(localize('multipleContainersNotSupported', 'The container app cannot be updated using "{0}" while having more than one active container. Navigate to the specific container instance and execute "{1}" instead.', deployWorkspaceProjectCommandName, editContainerCommandName));
}

const wizardContext: DeployWorkspaceProjectInternalContext = {
...context,
...activityContext,
Expand Down
2 changes: 2 additions & 0 deletions src/commands/editContainer/editContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { ContainerEditDraftStep } from "./ContainerEditDraftStep";
import { ContainerEditStartingResourcesLogStep } from "./ContainerEditStartingResourcesLogStep";
import { RegistryAndSecretsUpdateStep } from "./RegistryAndSecretsUpdateStep";

export const editContainerCommandName: string = localize('editContainer', 'Edit Container...');

// 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 });
Expand Down
Loading