Skip to content

Commit 6f866cf

Browse files
committed
Merge with main
2 parents 45f862c + 029df4c commit 6f866cf

23 files changed

+204
-49
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@
204204
"title": "%containerApps.addScaleRule%",
205205
"category": "Azure Container Apps"
206206
},
207+
{
208+
"command": "containerApps.deleteScaleRule",
209+
"title": "%containerApps.deleteScaleRule%",
210+
"category": "Azure Container Apps"
211+
},
207212
{
208213
"command": "containerApps.connectToGitHub",
209214
"title": "%containerApps.connectToGitHub%",
@@ -409,6 +414,11 @@
409414
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /scaleRuleGroupItem/i",
410415
"group": "1@1"
411416
},
417+
{
418+
"command": "containerApps.deleteScaleRule",
419+
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /scaleRuleItem/i",
420+
"group": "1@1"
421+
},
412422
{
413423
"command": "containerApps.enableIngress",
414424
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /ingressDisabledItem/i",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"containerApps.openConsoleInPortal": "Open Console in Portal",
3838
"containerApps.editScalingRange": "Edit Scaling Range...",
3939
"containerApps.addScaleRule": "Add Scale Rule...",
40+
"containerApps.deleteScaleRule": "Delete Scale Rule...",
4041
"containerApps.connectToGitHub": "Connect to GitHub Repository...",
4142
"containerApps.disconnectRepo": "Disconnect from Repo",
4243
"containerApps.openGitHubRepo": "Open Repo in GitHub",

src/commands/deployImage/imageSource/buildImageInAzure/IBuildImageInAzureContext.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55

66
import type { Run as AcrRun, ContainerRegistryManagementClient } from '@azure/arm-containerregistry';
77
import * as vscode from 'vscode';
8-
import { IContainerRegistryImageContext } from '../containerRegistry/IContainerRegistryImageContext';
9-
import { AcrBuildSupportedOS } from './OSPickStep';
8+
import type { IContainerRegistryImageContext } from '../containerRegistry/IContainerRegistryImageContext';
9+
import type { AcrBuildSupportedOS } from './OSPickStep';
1010

1111
export interface IBuildImageInAzureContext extends IContainerRegistryImageContext {
1212
rootFolder: vscode.WorkspaceFolder;
1313
dockerfilePath: string;
1414
imageName: string;
15-
os: typeof AcrBuildSupportedOS[keyof typeof AcrBuildSupportedOS];
15+
os: AcrBuildSupportedOS;
1616

1717
uploadedSourceLocation: string;
1818
tarFilePath: string;
1919

2020
client: ContainerRegistryManagementClient;
2121
resourceGroupName: string;
2222
registryName: string;
23-
run: AcrRun
23+
run: AcrRun;
2424
}

src/commands/deployImage/imageSource/buildImageInAzure/OSPickStep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export enum AcrBuildSupportedOS {
1515
export class OSPickStep extends AzureWizardPromptStep<IBuildImageInAzureContext> {
1616
public async prompt(context: IBuildImageInAzureContext): Promise<void> {
1717
const placeHolder: string = localize('imageOSPrompt', 'Select image base OS');
18-
const picks: IAzureQuickPickItem<typeof AcrBuildSupportedOS[keyof typeof AcrBuildSupportedOS]>[] = [
18+
const picks: IAzureQuickPickItem<AcrBuildSupportedOS>[] = [
1919
{ label: AcrBuildSupportedOS.Linux, data: AcrBuildSupportedOS.Linux, suppressPersistence: true },
2020
{ label: AcrBuildSupportedOS.Windows, data: AcrBuildSupportedOS.Windows, suppressPersistence: true },
2121
];

src/commands/deployImage/imageSource/containerRegistry/acr/AcrListStep.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import type { ContainerRegistryManagementClient, Registry } from "@azure/arm-containerregistry";
77
import type { ResourceGroup } from "@azure/arm-resources";
8-
import { LocationListStep, ResourceGroupListStep, uiUtils } from "@microsoft/vscode-azext-azureutils";
8+
import { LocationListStep, ResourceGroupListStep, getResourceGroupFromId, uiUtils } from "@microsoft/vscode-azext-azureutils";
99
import { AzureWizardExecuteStep, AzureWizardPromptStep, IAzureQuickPickItem, ISubscriptionActionContext, IWizardOptions, nonNullProp } from "@microsoft/vscode-azext-utils";
1010
import { ImageSource, acrDomain, currentlyDeployed, quickStartImageName } from "../../../../../constants";
1111
import { createContainerRegistryManagementClient } from "../../../../../utils/azureClients";
@@ -88,6 +88,7 @@ export class AcrListStep extends AzureWizardPromptStep<IContainerRegistryImageCo
8888

8989
const picks: IAzureQuickPickItem<Registry | undefined>[] = [];
9090

91+
// The why of `suppressCreate` in a nutshell: https://github.com/microsoft/vscode-azurecontainerapps/issues/78#issuecomment-1090686282
9192
const suppressCreate: boolean = context.imageSource !== ImageSource.RemoteAcrBuild;
9293
if (!suppressCreate) {
9394
picks.push({
@@ -122,8 +123,9 @@ async function tryConfigureResourceGroupForRegistry(
122123
return;
123124
}
124125

125-
// Try to leverage an existing resource group (managed environment name is a fallback here because our create flow has the resource group name mirror the environment name)
126-
const resourceGroupName: string | undefined = resourceCreationContext.containerApp?.resourceGroup || resourceCreationContext.managedEnvironment?.name;
126+
// Try to check for an existing container app or managed environment resource group
127+
const resourceGroupName: string | undefined = resourceCreationContext.containerApp?.resourceGroup ||
128+
(resourceCreationContext.managedEnvironment?.id ? getResourceGroupFromId(resourceCreationContext.managedEnvironment.id) : undefined);
127129
const resourceGroups: ResourceGroup[] = await ResourceGroupListStep.getResourceGroups(resourceCreationContext);
128130

129131
resourceCreationContext.resourceGroup = resourceGroups.find(rg => resourceGroupName && rg.name === resourceGroupName);

src/commands/deployWorkspaceProject/deployWorkspaceProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function deployWorkspaceProject(context: IActionContext): Promise<v
4848
...subscriptionContext,
4949
...await createActivityContext(),
5050
...defaultContextValues,
51-
activityChildren: [],
51+
// activityChildren: [],
5252
subscription,
5353
};
5454

src/commands/deployWorkspaceProject/getDefaultValues/getWorkspaceProjectPaths.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IActionContext, UserCancelledError, nonNullValue } from "@microsoft/vscode-azext-utils";
7-
import { Uri, WorkspaceFolder, commands, workspace } from "vscode";
7+
import { WorkspaceFolder, commands } from "vscode";
88
import { DOCKERFILE_GLOB_PATTERN, browseItem } from "../../../constants";
99
import { localize } from "../../../utils/localize";
10-
import { getRootWorkspaceFolder } from "../../../utils/workspaceUtils";
10+
import { getRootWorkspaceFolder, selectWorkspaceFile } from "../../../utils/workspaceUtils";
1111

1212
export async function getWorkspaceProjectPaths(context: IActionContext): Promise<{ rootFolder: WorkspaceFolder, dockerfilePath: string }> {
1313
const prompt: string = localize('selectRootWorkspace', 'Select a project with a Dockerfile');
@@ -21,16 +21,8 @@ export async function getWorkspaceProjectPaths(context: IActionContext): Promise
2121
throw new UserCancelledError();
2222
}
2323

24-
// Todo: Add logic allowing users to choose their workspace Dockerfile
25-
const dockerfileUris: Uri[] = await workspace.findFiles(DOCKERFILE_GLOB_PATTERN);
26-
if (!dockerfileUris.length) {
27-
throw new Error(localize('noDockerfileError', 'Unable to locate a Dockerfile in your project\'s root.'));
28-
} else if (dockerfileUris.length > 1) {
29-
throw new Error(localize('multipleDockerfileError', 'Multiple Dockerfiles found. Unable to determine the correct Dockerfile to use in your project\'s root.'));
30-
}
31-
3224
return {
3325
rootFolder: nonNullValue(rootFolder),
34-
dockerfilePath: dockerfileUris[0].path
26+
dockerfilePath: nonNullValue(await selectWorkspaceFile(context, localize('dockerFilePick', 'Select a Dockerfile'), { filters: {}, autoSelectIfOne: true }, `**/${DOCKERFILE_GLOB_PATTERN}`))
3527
};
3628
}

src/commands/registerCommands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ import { createRevisionDraft } from './revisionDraft/createRevisionDraft';
3232
import { deployRevisionDraft } from './revisionDraft/deployRevisionDraft/deployRevisionDraft';
3333
import { discardRevisionDraft } from './revisionDraft/discardRevisionDraft';
3434
import { editRevisionDraft } from './revisionDraft/editRevisionDraft';
35-
import { addScaleRule } from './scaling/addScaleRule/addScaleRule';
3635
import { editScalingRange } from './scaling/editScalingRange';
36+
import { addScaleRule } from './scaling/scaleRule/addScaleRule/addScaleRule';
37+
import { deleteScaleRule } from './scaling/scaleRule/deleteScaleRule/deleteScaleRule';
3738
import { addSecret } from './secret/addSecret/addSecret';
3839
import { deleteSecret } from './secret/deleteSecret/deleteSecret';
3940
import { editSecretName } from './secret/editSecret/editSecretName';
@@ -88,6 +89,7 @@ export function registerCommands(): void {
8889
// scaling
8990
registerCommandWithTreeNodeUnwrapping('containerApps.editScalingRange', editScalingRange);
9091
registerCommandWithTreeNodeUnwrapping('containerApps.addScaleRule', addScaleRule);
92+
registerCommandWithTreeNodeUnwrapping('containerApps.deleteScaleRule', deleteScaleRule);
9193

9294
//log streaming
9395
registerCommandWithTreeNodeUnwrapping('containerApps.startStreamingLogs', startStreamingLogs);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.md in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import type { ScaleRule } from "@azure/arm-appcontainers";
7+
import type { ExecuteActivityContext } from "@microsoft/vscode-azext-utils";
8+
import type { IContainerAppContext } from "../../IContainerAppContext";
9+
10+
export interface ScaleRuleContext extends IContainerAppContext, ExecuteActivityContext {
11+
scaleRule?: ScaleRule;
12+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.md in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import type { ScaleRule } from "@azure/arm-appcontainers";
7+
import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullProp, nonNullValue } from "@microsoft/vscode-azext-utils";
8+
import { localize } from "../../../utils/localize";
9+
import type { ScaleRuleContext } from "./ScaleRuleContext";
10+
11+
export class ScaleRuleListStep extends AzureWizardPromptStep<ScaleRuleContext> {
12+
public async prompt(context: ScaleRuleContext): Promise<void> {
13+
context.scaleRule = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder: localize('scaleRule', 'Select a scale rule') })).data;
14+
}
15+
16+
public shouldPrompt(context: ScaleRuleContext): boolean {
17+
return !context.scaleRule;
18+
}
19+
20+
private async getPicks(context: ScaleRuleContext): Promise<IAzureQuickPickItem<ScaleRule>[] | undefined> {
21+
const scaleRules = context.containerApp?.template?.scale?.rules;
22+
if (!scaleRules?.length) {
23+
throw new Error(localize('noScaleRules', 'No scale rules found'));
24+
}
25+
else {
26+
return scaleRules?.map(r => {
27+
return {
28+
label: nonNullProp(r, 'name'),
29+
data: nonNullValue(r)
30+
}
31+
})
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)