Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1,115 changes: 365 additions & 750 deletions package-lock.json

Large diffs are not rendered by default.

70 changes: 13 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,17 @@
"multi-root ready"
],
"preview": true,
"activationEvents": [
Comment thread
alexweininger marked this conversation as resolved.
"onCommand:containerApps.viewProperties",
"onCommand:containerApps.openInPortal",
"onCommand:containerApps.reportIssue",
"onCommand:containerApps.createContainerApp",
"onCommand:containerApps.deployImage",
"onCommand:containerApps.deleteManagedEnvironment",
"onCommand:containerApps.deleteContainerApp",
"onCommand:containerApps.disableIngress",
"onCommand:containerApps.enableIngress",
"onCommand:containerApps.toggleVisibility",
"onCommand:containerApps.editTargetPort",
"onCommand:containerApps.chooseRevisionMode",
"onCommand:containerApps.activateRevision",
"onCommand:containerApps.deactivateRevision",
"onCommand:containerApps.restartRevision",
"onCommand:containerApps.createManagedEnvironment",
"onCommand:containerApps.browse",
"onCommand:containerApps.openConsoleInPortal",
"onCommand:containerApps.editScalingRange",
"onCommand:containerApps.addScaleRule"
],
"activationEvents": [],
"main": "./main.js",
"contributes": {
"x-azResources": {
"azure": {
"branches": [
{
"type": "ContainerAppsEnvironment"
}
]
},
"activation": {
"onResolve": [
"microsoft.app/managedenvironments"
Expand All @@ -67,16 +53,6 @@
]
},
"commands": [
{
"command": "containerApps.viewProperties",
"title": "%containerApps.viewProperties%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.openInPortal",
"title": "%containerApps.openInPortal%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.reportIssue",
"title": "%containerApps.reportIssue%",
Expand Down Expand Up @@ -171,16 +147,6 @@
],
"menus": {
"view/item/context": [
{
"command": "containerApps.viewProperties",
"when": "view == azureResourceGroups && viewItem =~ /azResource/i && viewItem =~ /^(?!.*containerEnvironment).*/i",
"group": "z@1"
},
{
"command": "containerApps.openInPortal",
"when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i",
"group": "z@2"
},
{
"command": "containerApps.createManagedEnvironment",
"when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup/i && viewItem =~ /containerAppsEnvironment/i",
Expand Down Expand Up @@ -266,16 +232,6 @@
"when": "view == azureResourceGroups && viewItem =~ /scaleRules/i",
"group": "1@1"
}
],
"commandPalette": [
{
"command": "containerApps.viewProperties",
"when": "never"
},
{
"command": "containerApps.openInPortal",
"when": "never"
}
]
},
"configuration": [
Expand Down Expand Up @@ -327,7 +283,7 @@
},
"devDependencies": {
"@microsoft/eslint-config-azuretools": "^0.1.0",
"@microsoft/vscode-azext-dev": "^0.1.2",
"@microsoft/vscode-azext-dev": "^0.1.5",
"@types/fs-extra": "^8.1.1",
"@types/git-url-parse": "^9.0.0",
"@types/gulp": "^4.0.6",
Expand All @@ -345,8 +301,8 @@
"mocha": "^10.1.0",
"mocha-junit-reporter": "^2.0.0",
"mocha-multi-reporters": "^1.1.7",
"ts-node": "^7.0.1",
"typescript": "^4.3.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"vsce": "^1.87.1",
"vscode-test": "^1.5.2",
"webpack": "^5.28.0",
Expand All @@ -359,8 +315,8 @@
"@azure/arm-resources": "^4.2.2",
"@azure/container-registry": "1.0.0-beta.5",
"@azure/ms-rest-js": "^2.2.1",
"@microsoft/vscode-azext-azureutils": "^0.3.4",
"@microsoft/vscode-azext-utils": "^0.3.14",
"@microsoft/vscode-azext-azureutils": "^0.3.7",
"@microsoft/vscode-azext-utils": "^0.4.0",
"dayjs": "^1.11.3",
"dotenv": "^16.0.0",
"open": "^8.0.4",
Expand Down
33 changes: 33 additions & 0 deletions resources/managedEnvironment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 0 additions & 27 deletions src/ContainerAppsResolver.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/commands/api/revealTreeItem.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/commands/browse.ts

This file was deleted.

24 changes: 24 additions & 0 deletions src/commands/browseContainerApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ContainerApp } from '@azure/arm-appcontainers';
import { IActionContext } from '@microsoft/vscode-azext-utils';
import { ContainerAppItem, isIngressEnabled } from '../tree/ContainerAppItem';
import { localize } from '../utils/localize';
import { openUrl } from '../utils/openUrl';
import { pickContainerApp } from '../utils/pickContainerApp';

export async function browseContainerAppNode(context: IActionContext, node?: ContainerAppItem): Promise<void> {
node ??= await pickContainerApp(context)
await browseContainerApp(node.containerApp);
}

export async function browseContainerApp(containerApp: ContainerApp): Promise<void> {
if (isIngressEnabled(containerApp)) {
return await openUrl(`https://${containerApp.configuration.ingress.fqdn}`);
}

throw new Error(localize('enableIngress', 'Enable ingress to perform this action.'));
}
77 changes: 44 additions & 33 deletions src/commands/chooseRevisionMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,62 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { KnownActiveRevisionsMode } from "@azure/arm-appcontainers";
import { IActionContext, IAzureQuickPickItem } from "@microsoft/vscode-azext-utils";
import { ProgressLocation, window } from "vscode";
import { RevisionConstants, rootFilter } from "../constants";
import { ext } from "../extensionVariables";
import { ContainerAppTreeItem } from "../tree/ContainerAppTreeItem";
import { RevisionsTreeItem } from "../tree/RevisionsTreeItem";
import { ContainerAppModel } from "../tree/ContainerAppItem";
import { ContainerAppsItem } from "../tree/ContainerAppsBranchDataProvider";
import { localize } from "../utils/localize";
import { nonNullValue } from "../utils/nonNull";
import { pickContainerApp } from "../utils/pickContainerApp";
import { updateContainerApp } from "./updateContainerApp";

export async function chooseRevisionMode(context: IActionContext, node?: ContainerAppTreeItem | RevisionsTreeItem): Promise<void> {
if (!node) {
node = await ext.rgApi.pickAppResource<ContainerAppTreeItem>(context, {
filter: rootFilter,
expectedChildContextValue: ContainerAppTreeItem.contextValueRegExp
});
}
export async function chooseRevisionMode(context: IActionContext, node?: ContainerAppsItem): Promise<void> {
const { subscription, containerApp } = node ?? await pickContainerApp(context);

if (node instanceof RevisionsTreeItem) {
node = node.parent;
}
const pickedRevisionMode = await pickRevisionsMode(context, containerApp);
// only update it if it's actually different
if (containerApp.revisionsMode !== pickedRevisionMode) {
const updating = localize('updatingRevision', 'Updating revision mode of "{0}" to "{1}"...', containerApp.name, pickedRevisionMode);
ext.outputChannel.appendLog(updating);

const picks: IAzureQuickPickItem<string>[] = [RevisionConstants.single, RevisionConstants.multiple];
const placeHolder = localize('chooseRevision', 'Choose revision mode');
await window.withProgress({ location: ProgressLocation.Notification, title: updating }, async (): Promise<void> => {
await updateContainerApp(context, subscription, containerApp, { configuration: { activeRevisionsMode: pickedRevisionMode } });
// TODO: scoped container app refresh
ext.state.notifyChildrenChanged(containerApp.managedEnvironmentId);
});

for (const pick of picks) {
pick.description = pick.data === node.getRevisionMode() ? localize('current', ' current') : undefined;
const updated = localize('updatedRevision', 'Updated revision mode of "{0}" to "{1}".', containerApp.name, pickedRevisionMode);
void window.showInformationMessage(updated);
ext.outputChannel.appendLog(updated);
}
}

const result = await context.ui.showQuickPick(picks, { placeHolder, suppressPersistence: true });

// only update it if it's actually different
if (node.getRevisionMode() !== result.data) {
const updating = localize('updatingRevision', 'Updating revision mode of "{0}" to "{1}"...', node.name, result.data);
const updated = localize('updatedRevision', 'Updated revision mode of "{0}" to "{1}".', node.name, result.data);
function getRevisionsModePicks(containerApp: ContainerAppModel): IAzureQuickPickItem<KnownActiveRevisionsMode>[] {

await window.withProgress({ location: ProgressLocation.Notification, title: updating }, async (): Promise<void> => {
const pNode = nonNullValue(node) as ContainerAppTreeItem;
ext.outputChannel.appendLog(updating);
function appendCurrent(description: string, revisionsMode: KnownActiveRevisionsMode): string {
return revisionsMode === containerApp.revisionsMode ? `${description} (current)` : description;
}

await updateContainerApp(context, pNode, { configuration: { activeRevisionsMode: result.data } });
await node?.parent?.refresh(context);
return [
{
label: localize('multiple', 'Multiple'),
description: appendCurrent(localize('multipleDesc', 'Several revisions active simultaneously'), KnownActiveRevisionsMode.Multiple),
data: KnownActiveRevisionsMode.Multiple,
},
{
label: localize('single', 'Single'),
description: appendCurrent(localize('singleDesc', 'One active revision at a time'), KnownActiveRevisionsMode.Single),
data: KnownActiveRevisionsMode.Multiple,
},
];
}

void window.showInformationMessage(updated);
ext.outputChannel.appendLog(updated);
});
}
async function pickRevisionsMode(context: IActionContext, containerApp: ContainerAppModel): Promise<KnownActiveRevisionsMode> {
const placeHolder = localize('chooseRevision', 'Choose revision mode');
const result = await context.ui.showQuickPick(getRevisionsModePicks(containerApp), {
placeHolder,
suppressPersistence: true,
});
return result.data;
}
11 changes: 6 additions & 5 deletions src/commands/createContainerApp/ContainerAppCreateStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ContainerAppsAPIClient, Ingress, RegistryCredentials, Secret } from "@azure/arm-appcontainers";
import { ContainerAppsAPIClient, Ingress, KnownActiveRevisionsMode, RegistryCredentials, Secret } from "@azure/arm-appcontainers";
import { LocationListStep } from "@microsoft/vscode-azext-azureutils";
import { AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils";
import { Progress } from "vscode";
import { containerAppsWebProvider, RevisionConstants } from "../../constants";
import { containerAppsWebProvider } from "../../constants";
import { ext } from "../../extensionVariables";
import { ContainerAppItem } from "../../tree/ContainerAppItem";
import { createContainerAppsAPIClient } from "../../utils/azureClients";
import { localize } from "../../utils/localize";
import { nonNullProp } from "../../utils/nonNull";
Expand Down Expand Up @@ -67,14 +68,14 @@ export class ContainerAppCreateStep extends AzureWizardExecuteStep<IContainerApp
context.image ||= `${getLoginServer(context)}/${context.repositoryName}:${context.tag}`;
const name = getContainerNameForImage(context.image);

context.containerApp = await appClient.containerApps.beginCreateOrUpdateAndWait(nonNullProp(context, 'newResourceGroupName'), nonNullProp(context, 'newContainerAppName'), {
context.containerApp = ContainerAppItem.CreateContainerAppModel(await appClient.containerApps.beginCreateOrUpdateAndWait(nonNullProp(context, 'newResourceGroupName'), nonNullProp(context, 'newContainerAppName'), {
location: (await LocationListStep.getLocation(context, containerAppsWebProvider)).name,
managedEnvironmentId: context.managedEnvironmentId,
configuration: {
ingress,
secrets,
registries,
activeRevisionsMode: RevisionConstants.single.data
activeRevisionsMode: KnownActiveRevisionsMode.Multiple,
},
template: {
containers: [
Expand All @@ -83,7 +84,7 @@ export class ContainerAppCreateStep extends AzureWizardExecuteStep<IContainerApp
}
]
}
});
}));
}

public shouldExecute(_wizardContext: IContainerAppContext): boolean {
Expand Down
Loading