From 22ec2aed0860db7420c99e4cdab70e78cc1adb35 Mon Sep 17 00:00:00 2001 From: Megan Mott Date: Tue, 6 Jun 2023 10:24:09 -0700 Subject: [PATCH 1/4] Add service connector --- package-lock.json | 64 +++++++++++++++++++ package.json | 33 +++++++++- package.nls.json | 5 +- src/commands/registerCommands.ts | 8 +++ .../serviceConnector/ContainerPickStep.ts | 26 ++++++++ .../IServiceConnectorContext.ts | 14 ++++ .../createServiceConnector.ts | 43 +++++++++++++ .../deleteServiceConnector.ts | 42 ++++++++++++ .../validateServiceConnector.ts | 41 ++++++++++++ 9 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 src/commands/serviceConnector/ContainerPickStep.ts create mode 100644 src/commands/serviceConnector/IServiceConnectorContext.ts create mode 100644 src/commands/serviceConnector/createServiceConnector.ts create mode 100644 src/commands/serviceConnector/deleteServiceConnector.ts create mode 100644 src/commands/serviceConnector/validateServiceConnector.ts diff --git a/package-lock.json b/package-lock.json index afb8b65cb..49b1980a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@azure/core-rest-pipeline": "1.10.3", "@azure/storage-blob": "^12.4.1", "@microsoft/vscode-azext-azureutils": "^1.0.1", + "@microsoft/vscode-azext-serviceconnector": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", "@microsoft/vscode-azext-utils": "^1.2.0", "@microsoft/vscode-azureresources-api": "^2.0.2", "@octokit/rest": "^18.5.2", @@ -206,6 +207,28 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, + "node_modules/@azure/arm-servicelinker": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@azure/arm-servicelinker/-/arm-servicelinker-2.1.0.tgz", + "integrity": "sha512-IENuxll0IxjnrO3B2TkZOKn3KLVD9gR09Adtzd+rk/ipe2ESTRp7Nsn5MhK89jxzb0Xd3uRy0a6uGMjI7d9E1A==", + "dependencies": { + "@azure/abort-controller": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-client": "^1.6.1", + "@azure/core-lro": "^2.2.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-rest-pipeline": "^1.8.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@azure/arm-servicelinker/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + }, "node_modules/@azure/arm-storage": { "version": "18.1.0", "resolved": "https://registry.npmjs.org/@azure/arm-storage/-/arm-storage-18.1.0.tgz", @@ -1012,6 +1035,17 @@ "node": ">=4" } }, + "node_modules/@microsoft/vscode-azext-serviceconnector": { + "version": "0.0.1", + "resolved": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", + "integrity": "sha512-BvQjBNrrn/c27w/DACVmvZ6roe2xOKm1JFNyWKM7fW3h9PFQFefCFWapkTYItv4QrqRXMCoeqJiJDajYAf0ASg==", + "license": "MIT", + "dependencies": { + "@azure/arm-servicelinker": "^2.1.0", + "@microsoft/vscode-azext-azureutils": "^1.0.0", + "@microsoft/vscode-azext-utils": "^1.1.0" + } + }, "node_modules/@microsoft/vscode-azext-utils": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.0.tgz", @@ -12378,6 +12412,27 @@ } } }, + "@azure/arm-servicelinker": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@azure/arm-servicelinker/-/arm-servicelinker-2.1.0.tgz", + "integrity": "sha512-IENuxll0IxjnrO3B2TkZOKn3KLVD9gR09Adtzd+rk/ipe2ESTRp7Nsn5MhK89jxzb0Xd3uRy0a6uGMjI7d9E1A==", + "requires": { + "@azure/abort-controller": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-client": "^1.6.1", + "@azure/core-lro": "^2.2.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-rest-pipeline": "^1.8.0", + "tslib": "^2.2.0" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + } + } + }, "@azure/arm-storage": { "version": "18.1.0", "resolved": "https://registry.npmjs.org/@azure/arm-storage/-/arm-storage-18.1.0.tgz", @@ -13100,6 +13155,15 @@ } } }, + "@microsoft/vscode-azext-serviceconnector": { + "version": "file:..\\vscode-azuretools\\serviceconnector\\microsoft-vscode-azext-serviceconnector-0.0.1.tgz", + "integrity": "sha512-BvQjBNrrn/c27w/DACVmvZ6roe2xOKm1JFNyWKM7fW3h9PFQFefCFWapkTYItv4QrqRXMCoeqJiJDajYAf0ASg==", + "requires": { + "@azure/arm-servicelinker": "^2.1.0", + "@microsoft/vscode-azext-azureutils": "^1.0.0", + "@microsoft/vscode-azext-utils": "^1.1.0" + } + }, "@microsoft/vscode-azext-utils": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.0.tgz", diff --git a/package.json b/package.json index eba711338..02c137bda 100644 --- a/package.json +++ b/package.json @@ -165,6 +165,21 @@ "command": "containerApps.stopStreamingLogs", "title": "%containerApps.stopStreamingLogs%", "category": "Azure Container Apps" + }, + { + "command": "containerApps.createServiceConnector", + "title": "%containerApps.createServiceConnector%", + "category": "Azure Container Apps" + }, + { + "command": "containerApps.deleteServiceConnector", + "title": "%containerApps.deleteServiceConnector%", + "category": "Azure Container Apps" + }, + { + "command": "containerApps.validateServiceConnector", + "title": "%containerApps.validateServiceConnector%", + "category": "Azure Container Apps" } ], "menus": { @@ -277,6 +292,21 @@ "command": "containerApps.stopStreamingLogs", "when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i", "group": "4@2" + }, + { + "command": "containerApps.createServiceConnector", + "when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i", + "group": "4@3" + }, + { + "command": "containerApps.deleteServiceConnector", + "when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i", + "group": "4@4" + }, + { + "command": "containerApps.validateServiceConnector", + "when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i", + "group": "4@4" } ], "commandPalette": [ @@ -374,9 +404,10 @@ "@azure/arm-operationalinsights": "^8.0.0", "@azure/arm-resources": "^5.0.1", "@azure/container-registry": "1.0.0-beta.5", - "@azure/storage-blob": "^12.4.1", "@azure/core-rest-pipeline": "1.10.3", + "@azure/storage-blob": "^12.4.1", "@microsoft/vscode-azext-azureutils": "^1.0.1", + "@microsoft/vscode-azext-serviceconnector": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", "@microsoft/vscode-azext-utils": "^1.2.0", "@microsoft/vscode-azureresources-api": "^2.0.2", "@octokit/rest": "^18.5.2", diff --git a/package.nls.json b/package.nls.json index 2dfb92838..35831a9c7 100644 --- a/package.nls.json +++ b/package.nls.json @@ -29,5 +29,8 @@ "containerApps.addScaleRule": "Add Scale Rule...", "containerApps.connectToGitHub": "Connect to GitHub Repository...", "containerApps.startStreamingLogs": "Start Streaming Logs...", - "containerApps.stopStreamingLogs": "Stop Streaming Logs..." + "containerApps.stopStreamingLogs": "Stop Streaming Logs...", + "containerApps.createServiceConnector": "Create Service Connector...", + "containerApps.deleteServiceConnector": "Delete Service Connector...", + "containerApps.validateServiceConnector": "Validate Service Connector..." } diff --git a/src/commands/registerCommands.ts b/src/commands/registerCommands.ts index 8dc0c5045..d7e77bacb 100644 --- a/src/commands/registerCommands.ts +++ b/src/commands/registerCommands.ts @@ -25,6 +25,9 @@ import { deactivateRevision } from './revisionCommands/deactivateRevision'; import { restartRevision } from './revisionCommands/restartRevision'; import { addScaleRule } from './scaling/addScaleRule/addScaleRule'; import { editScalingRange } from './scaling/editScalingRange'; +import { createServiceConnector } from './serviceConnector/createServiceConnector'; +import { deleteServiceConnector } from './serviceConnector/deleteServiceConnector'; +import { validateServiceConnector } from './serviceConnector/validateServiceConnector'; export function registerCommands(): void { // managed environments @@ -62,6 +65,11 @@ export function registerCommands(): void { registerCommandWithTreeNodeUnwrapping('containerApps.startStreamingLogs', startStreamingLogs); registerCommandWithTreeNodeUnwrapping('containerApps.stopStreamingLogs', stopStreamingLogs); + // service connector + registerCommandWithTreeNodeUnwrapping('containerApps.createServiceConnector', createServiceConnector); + registerCommandWithTreeNodeUnwrapping('containerApps.deleteServiceConnector', deleteServiceConnector); + registerCommandWithTreeNodeUnwrapping('containerApps.validateServiceConnector', validateServiceConnector); + // Suppress "Report an Issue" button for all errors in favor of the command registerErrorHandler(c => c.errorHandling.suppressReportIssue = true); registerReportIssueCommand('containerApps.reportIssue'); diff --git a/src/commands/serviceConnector/ContainerPickStep.ts b/src/commands/serviceConnector/ContainerPickStep.ts new file mode 100644 index 000000000..8000def03 --- /dev/null +++ b/src/commands/serviceConnector/ContainerPickStep.ts @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.md in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import { AzureWizardPromptStep, IActionContext, IAzureQuickPickItem, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { localize } from "../../utils/localize"; +import { IServiceConnectorContext } from "./IServiceConnectorContext"; + +export class ContainerPickStep extends AzureWizardPromptStep { + public async prompt(context: IServiceConnectorContext): Promise { + const placeHolder: string = localize('selectStream', 'Select a container'); + context.scope = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data; + } + + public shouldPrompt(context: IServiceConnectorContext): boolean { + return !context.scope + } + + private async getPicks(context: IServiceConnectorContext): Promise[]> { + const containers = nonNullValue(context.containerApp.template?.containers); + return containers.map(c => { + return { label: nonNullValue(c.name), data: nonNullValue(c.name) } + }) + } +} diff --git a/src/commands/serviceConnector/IServiceConnectorContext.ts b/src/commands/serviceConnector/IServiceConnectorContext.ts new file mode 100644 index 000000000..b736d9b9d --- /dev/null +++ b/src/commands/serviceConnector/IServiceConnectorContext.ts @@ -0,0 +1,14 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.md in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import { ICreateLinkerContext } from "@microsoft/vscode-azext-serviceconnector"; +import { ExecuteActivityContext } from "@microsoft/vscode-azext-utils"; +import { ContainerAppModel } from "../../tree/ContainerAppItem"; + +export interface IServiceConnectorContext extends ICreateLinkerContext { + containerApp: ContainerAppModel; +} + +export type IServiceConnectorWithActivityContext = IServiceConnectorContext & ExecuteActivityContext; diff --git a/src/commands/serviceConnector/createServiceConnector.ts b/src/commands/serviceConnector/createServiceConnector.ts new file mode 100644 index 000000000..083018b6c --- /dev/null +++ b/src/commands/serviceConnector/createServiceConnector.ts @@ -0,0 +1,43 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.md in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import { ICreateLinkerContext, createLinker } from "@microsoft/vscode-azext-serviceconnector"; +import { AzureWizard, AzureWizardPromptStep, createSubscriptionContext, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { ContainerAppItem } from "../../tree/ContainerAppItem"; +import { createActivityContext } from "../../utils/activityUtils"; +import { localize } from "../../utils/localize"; +import { pickContainerApp } from "../../utils/pickContainerApp"; +import { ContainerPickStep } from "./ContainerPickStep"; +import { IServiceConnectorWithActivityContext } from "./IServiceConnectorContext"; + +export async function createServiceConnector(context: ICreateLinkerContext, item?: ContainerAppItem): Promise { + if (!item) { + item = await pickContainerApp(context); + } + const { subscription, containerApp } = item; + + const createServiceTitle: string = localize('createServiceConnector', 'Create Service Connector'); + + const wizardContext: IServiceConnectorWithActivityContext = { + activityTitle: createServiceTitle, + ...context, + ...createSubscriptionContext(subscription), + containerApp: containerApp, + sourceResourceUri: containerApp.id, + ...(await createActivityContext()) + } + + const promptSteps: AzureWizardPromptStep[] = [ + new ContainerPickStep(), + ]; + + const wizard: AzureWizard = new AzureWizard(wizardContext, { + title: localize('createServiceConnector', 'Create Service Connector'), + promptSteps, + }); + + await wizard.prompt(); + await createLinker(wizardContext, nonNullValue(item)); +} diff --git a/src/commands/serviceConnector/deleteServiceConnector.ts b/src/commands/serviceConnector/deleteServiceConnector.ts new file mode 100644 index 000000000..8445a5b86 --- /dev/null +++ b/src/commands/serviceConnector/deleteServiceConnector.ts @@ -0,0 +1,42 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.md in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import { deleteLinker } from "@microsoft/vscode-azext-serviceconnector"; +import { AzureWizard, AzureWizardPromptStep, IActionContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; +import { ContainerAppItem } from "../../tree/ContainerAppItem"; +import { createActivityContext } from "../../utils/activityUtils"; +import { localize } from "../../utils/localize"; +import { pickContainerApp } from "../../utils/pickContainerApp"; +import { ContainerPickStep } from "./ContainerPickStep"; +import { IServiceConnectorContext } from "./IServiceConnectorContext"; + + +export async function deleteServiceConnector(context: IActionContext, item?: ContainerAppItem): Promise { + if (!item) { + item = await pickContainerApp(context); + } + + const { subscription, containerApp } = item; + + const wizardContext: IServiceConnectorContext = { + activityTitle: localize('deleteServiceConnector', 'Delete Service Connector'), + ...context, + ...createSubscriptionContext(subscription), + containerApp: containerApp, + ...(await createActivityContext()) + } + + const promptSteps: AzureWizardPromptStep[] = [ + new ContainerPickStep(), + ]; + + const wizard: AzureWizard = new AzureWizard(wizardContext, { + title: localize('deleteServiceConnector', 'Delete Service Connector'), + promptSteps, + }); + + await wizard.prompt(); + await deleteLinker(wizardContext, item); +} diff --git a/src/commands/serviceConnector/validateServiceConnector.ts b/src/commands/serviceConnector/validateServiceConnector.ts new file mode 100644 index 000000000..1b4eb2331 --- /dev/null +++ b/src/commands/serviceConnector/validateServiceConnector.ts @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.md in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import { validateLinker } from "@microsoft/vscode-azext-serviceconnector"; +import { AzureWizard, AzureWizardPromptStep, IActionContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; +import { ContainerAppItem } from "../../tree/ContainerAppItem"; +import { createActivityContext } from "../../utils/activityUtils"; +import { localize } from "../../utils/localize"; +import { pickContainerApp } from "../../utils/pickContainerApp"; +import { ContainerPickStep } from "./ContainerPickStep"; +import { IServiceConnectorWithActivityContext } from "./IServiceConnectorContext"; + +export async function validateServiceConnector(context: IActionContext, item?: ContainerAppItem): Promise { + if (!item) { + item = await pickContainerApp(context); + } + + const { subscription, containerApp } = item; + + const wizardContext: IServiceConnectorWithActivityContext = { + activityTitle: localize('createServiceConnector', 'Validate Service Connector'), + ...context, + ...createSubscriptionContext(subscription), + containerApp: containerApp, + ...(await createActivityContext()) + } + + const promptSteps: AzureWizardPromptStep[] = [ + new ContainerPickStep(), + ]; + + const wizard: AzureWizard = new AzureWizard(wizardContext, { + title: localize('deleteServiceConnector', 'Delete Service Connector'), + promptSteps, + }); + + await wizard.prompt(); + await validateLinker(wizardContext, item); +} From 2f01038c2fd0a1c0c8cbffad4d76a5775d76685d Mon Sep 17 00:00:00 2001 From: Megan Mott Date: Fri, 9 Jun 2023 15:13:52 -0700 Subject: [PATCH 2/4] Incorporate requested changes --- package-lock.json | 57 ++++++++----------- package.json | 2 +- .../serviceConnector/ContainerPickStep.ts | 18 ++++-- .../IServiceConnectorContext.ts | 3 - .../createServiceConnector.ts | 28 +++------ .../deleteServiceConnector.ts | 26 +++------ .../validateServiceConnector.ts | 30 ++++------ 7 files changed, 64 insertions(+), 100 deletions(-) diff --git a/package-lock.json b/package-lock.json index 49b1980a7..bf0487edc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -534,8 +534,7 @@ "node_modules/@azure/ms-rest-azure-env": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@azure/ms-rest-azure-env/-/ms-rest-azure-env-2.0.0.tgz", - "integrity": "sha512-dG76W7ElfLi+fbTjnZVGj+M9e0BIEJmRxU6fHaUQ12bZBe8EJKYb2GV50YWNaP2uJiVQ5+7nXEVj1VN1UQtaEw==", - "dev": true + "integrity": "sha512-dG76W7ElfLi+fbTjnZVGj+M9e0BIEJmRxU6fHaUQ12bZBe8EJKYb2GV50YWNaP2uJiVQ5+7nXEVj1VN1UQtaEw==" }, "node_modules/@azure/ms-rest-azure-js": { "version": "2.1.0", @@ -1038,29 +1037,31 @@ "node_modules/@microsoft/vscode-azext-serviceconnector": { "version": "0.0.1", "resolved": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", - "integrity": "sha512-BvQjBNrrn/c27w/DACVmvZ6roe2xOKm1JFNyWKM7fW3h9PFQFefCFWapkTYItv4QrqRXMCoeqJiJDajYAf0ASg==", + "integrity": "sha512-oapvw/eRSvnWfENwZ6uF/HT9932HNoL/mFUeuGW24Xe0AZfFufTOzAD2Y3s9cGA5U8L/M1ay9jJrT6oZMPPBvA==", "license": "MIT", "dependencies": { "@azure/arm-servicelinker": "^2.1.0", "@microsoft/vscode-azext-azureutils": "^1.0.0", - "@microsoft/vscode-azext-utils": "^1.1.0" + "@microsoft/vscode-azext-utils": "^1.2.2" } }, "node_modules/@microsoft/vscode-azext-utils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.0.tgz", - "integrity": "sha512-zD+1Efa6HSx0yqHTaFo0eICqUVEJHAfyphl+/XcdA6Bc8Wm1EXuKquKOOptt6hpF4hze8wcDo2RqxMcVaMXRLA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.2.tgz", + "integrity": "sha512-mOTcJF8IMsz+Xn8QTUP1AC3K5tPl/3f17L2xGTTtLeV/HJ2sTh/3712NFuN58tnOwdISdazId4tHwaqUta8HEA==", "dependencies": { - "@microsoft/vscode-azureresources-api": "^2.0.2", + "@microsoft/vscode-azureresources-api": "^2.0.4", "@vscode/extension-telemetry": "^0.6.2", "dayjs": "^1.11.2", "escape-string-regexp": "^2.0.0", "html-to-text": "^8.2.0", "semver": "^7.3.7", "uuid": "^9.0.0", - "vscode-nls": "^5.0.1", "vscode-tas-client": "^0.1.47", "vscode-uri": "^3.0.6" + }, + "peerDependencies": { + "@azure/ms-rest-azure-env": "^2.0.0" } }, "node_modules/@microsoft/vscode-azext-utils/node_modules/escape-string-regexp": { @@ -1079,15 +1080,10 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/@microsoft/vscode-azext-utils/node_modules/vscode-nls": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.0.1.tgz", - "integrity": "sha512-hHQV6iig+M21lTdItKPkJAaWrxALQb/nqpVffakO4knJOh3DrU2SXOMzUzNgo1eADPzu3qSsJY1weCzvR52q9A==" - }, "node_modules/@microsoft/vscode-azureresources-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azureresources-api/-/vscode-azureresources-api-2.0.2.tgz", - "integrity": "sha512-O+JlAZg+3SjnQUX9nzUh0wfzLRBqqMk9f7rtSr4CX2Yrp753ufRBopLkWtFWOpTzKkoe7cp696nxESFi1AN6Hw==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azureresources-api/-/vscode-azureresources-api-2.0.4.tgz", + "integrity": "sha512-LridV1h2rCydrBzEpwy+pUIUx61GpZNwrK04G7LdlhoxHrzuM/WAoy8jXaSC/FSKSsXD1QXuE6u/YofEfsuKeg==" }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -12714,8 +12710,7 @@ "@azure/ms-rest-azure-env": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@azure/ms-rest-azure-env/-/ms-rest-azure-env-2.0.0.tgz", - "integrity": "sha512-dG76W7ElfLi+fbTjnZVGj+M9e0BIEJmRxU6fHaUQ12bZBe8EJKYb2GV50YWNaP2uJiVQ5+7nXEVj1VN1UQtaEw==", - "dev": true + "integrity": "sha512-dG76W7ElfLi+fbTjnZVGj+M9e0BIEJmRxU6fHaUQ12bZBe8EJKYb2GV50YWNaP2uJiVQ5+7nXEVj1VN1UQtaEw==" }, "@azure/ms-rest-azure-js": { "version": "2.1.0", @@ -13157,26 +13152,25 @@ }, "@microsoft/vscode-azext-serviceconnector": { "version": "file:..\\vscode-azuretools\\serviceconnector\\microsoft-vscode-azext-serviceconnector-0.0.1.tgz", - "integrity": "sha512-BvQjBNrrn/c27w/DACVmvZ6roe2xOKm1JFNyWKM7fW3h9PFQFefCFWapkTYItv4QrqRXMCoeqJiJDajYAf0ASg==", + "integrity": "sha512-oapvw/eRSvnWfENwZ6uF/HT9932HNoL/mFUeuGW24Xe0AZfFufTOzAD2Y3s9cGA5U8L/M1ay9jJrT6oZMPPBvA==", "requires": { "@azure/arm-servicelinker": "^2.1.0", "@microsoft/vscode-azext-azureutils": "^1.0.0", - "@microsoft/vscode-azext-utils": "^1.1.0" + "@microsoft/vscode-azext-utils": "^1.2.2" } }, "@microsoft/vscode-azext-utils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.0.tgz", - "integrity": "sha512-zD+1Efa6HSx0yqHTaFo0eICqUVEJHAfyphl+/XcdA6Bc8Wm1EXuKquKOOptt6hpF4hze8wcDo2RqxMcVaMXRLA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.2.tgz", + "integrity": "sha512-mOTcJF8IMsz+Xn8QTUP1AC3K5tPl/3f17L2xGTTtLeV/HJ2sTh/3712NFuN58tnOwdISdazId4tHwaqUta8HEA==", "requires": { - "@microsoft/vscode-azureresources-api": "^2.0.2", + "@microsoft/vscode-azureresources-api": "^2.0.4", "@vscode/extension-telemetry": "^0.6.2", "dayjs": "^1.11.2", "escape-string-regexp": "^2.0.0", "html-to-text": "^8.2.0", "semver": "^7.3.7", "uuid": "^9.0.0", - "vscode-nls": "^5.0.1", "vscode-tas-client": "^0.1.47", "vscode-uri": "^3.0.6" }, @@ -13190,18 +13184,13 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" - }, - "vscode-nls": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.0.1.tgz", - "integrity": "sha512-hHQV6iig+M21lTdItKPkJAaWrxALQb/nqpVffakO4knJOh3DrU2SXOMzUzNgo1eADPzu3qSsJY1weCzvR52q9A==" } } }, "@microsoft/vscode-azureresources-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azureresources-api/-/vscode-azureresources-api-2.0.2.tgz", - "integrity": "sha512-O+JlAZg+3SjnQUX9nzUh0wfzLRBqqMk9f7rtSr4CX2Yrp753ufRBopLkWtFWOpTzKkoe7cp696nxESFi1AN6Hw==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azureresources-api/-/vscode-azureresources-api-2.0.4.tgz", + "integrity": "sha512-LridV1h2rCydrBzEpwy+pUIUx61GpZNwrK04G7LdlhoxHrzuM/WAoy8jXaSC/FSKSsXD1QXuE6u/YofEfsuKeg==" }, "@nodelib/fs.scandir": { "version": "2.1.5", diff --git a/package.json b/package.json index 02c137bda..d9f85862f 100644 --- a/package.json +++ b/package.json @@ -306,7 +306,7 @@ { "command": "containerApps.validateServiceConnector", "when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i", - "group": "4@4" + "group": "4@5" } ], "commandPalette": [ diff --git a/src/commands/serviceConnector/ContainerPickStep.ts b/src/commands/serviceConnector/ContainerPickStep.ts index 8000def03..2ff6f7c0d 100644 --- a/src/commands/serviceConnector/ContainerPickStep.ts +++ b/src/commands/serviceConnector/ContainerPickStep.ts @@ -3,24 +3,34 @@ * Licensed under the MIT License. See License.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { AzureWizardPromptStep, IActionContext, IAzureQuickPickItem, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullValue } from "@microsoft/vscode-azext-utils"; import { localize } from "../../utils/localize"; import { IServiceConnectorContext } from "./IServiceConnectorContext"; -export class ContainerPickStep extends AzureWizardPromptStep { +export class ContainerPickStep extends AzureWizardPromptStep { public async prompt(context: IServiceConnectorContext): Promise { const placeHolder: string = localize('selectStream', 'Select a container'); context.scope = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data; } public shouldPrompt(context: IServiceConnectorContext): boolean { - return !context.scope + return !context.scope; + } + + public async configureBeforePrompt(context: IServiceConnectorContext): Promise { + const picks = await this.getPicks(context); + if (picks.length === 1) { + context.scope = picks[0].data; + } } private async getPicks(context: IServiceConnectorContext): Promise[]> { const containers = nonNullValue(context.containerApp.template?.containers); return containers.map(c => { - return { label: nonNullValue(c.name), data: nonNullValue(c.name) } + return { + label: nonNullValue(c.name), + data: nonNullValue(c.name) + } }) } } diff --git a/src/commands/serviceConnector/IServiceConnectorContext.ts b/src/commands/serviceConnector/IServiceConnectorContext.ts index b736d9b9d..61108e21c 100644 --- a/src/commands/serviceConnector/IServiceConnectorContext.ts +++ b/src/commands/serviceConnector/IServiceConnectorContext.ts @@ -4,11 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { ICreateLinkerContext } from "@microsoft/vscode-azext-serviceconnector"; -import { ExecuteActivityContext } from "@microsoft/vscode-azext-utils"; import { ContainerAppModel } from "../../tree/ContainerAppItem"; export interface IServiceConnectorContext extends ICreateLinkerContext { containerApp: ContainerAppModel; } - -export type IServiceConnectorWithActivityContext = IServiceConnectorContext & ExecuteActivityContext; diff --git a/src/commands/serviceConnector/createServiceConnector.ts b/src/commands/serviceConnector/createServiceConnector.ts index 083018b6c..0e225dc15 100644 --- a/src/commands/serviceConnector/createServiceConnector.ts +++ b/src/commands/serviceConnector/createServiceConnector.ts @@ -4,40 +4,28 @@ *--------------------------------------------------------------------------------------------*/ import { ICreateLinkerContext, createLinker } from "@microsoft/vscode-azext-serviceconnector"; -import { AzureWizard, AzureWizardPromptStep, createSubscriptionContext, nonNullValue } from "@microsoft/vscode-azext-utils"; +import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils"; import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; import { pickContainerApp } from "../../utils/pickContainerApp"; import { ContainerPickStep } from "./ContainerPickStep"; -import { IServiceConnectorWithActivityContext } from "./IServiceConnectorContext"; +import { IServiceConnectorContext } from "./IServiceConnectorContext"; export async function createServiceConnector(context: ICreateLinkerContext, item?: ContainerAppItem): Promise { - if (!item) { - item = await pickContainerApp(context); - } + item ??= await pickContainerApp(context); const { subscription, containerApp } = item; - const createServiceTitle: string = localize('createServiceConnector', 'Create Service Connector'); - - const wizardContext: IServiceConnectorWithActivityContext = { - activityTitle: createServiceTitle, + const activityContext = { ...context, - ...createSubscriptionContext(subscription), + ...await createActivityContext(), containerApp: containerApp, - sourceResourceUri: containerApp.id, - ...(await createActivityContext()) + activityTitle: localize('createServiceConnector', 'Create Service Connector'), } - const promptSteps: AzureWizardPromptStep[] = [ + const promptSteps: AzureWizardPromptStep[] = [ new ContainerPickStep(), ]; - const wizard: AzureWizard = new AzureWizard(wizardContext, { - title: localize('createServiceConnector', 'Create Service Connector'), - promptSteps, - }); - - await wizard.prompt(); - await createLinker(wizardContext, nonNullValue(item)); + await createLinker(activityContext, { id: containerApp.id, subscription }, promptSteps); } diff --git a/src/commands/serviceConnector/deleteServiceConnector.ts b/src/commands/serviceConnector/deleteServiceConnector.ts index 8445a5b86..7a084beb1 100644 --- a/src/commands/serviceConnector/deleteServiceConnector.ts +++ b/src/commands/serviceConnector/deleteServiceConnector.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { deleteLinker } from "@microsoft/vscode-azext-serviceconnector"; -import { AzureWizard, AzureWizardPromptStep, IActionContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; +import { ICreateLinkerContext, deleteLinker } from "@microsoft/vscode-azext-serviceconnector"; +import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils"; import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; @@ -13,30 +13,20 @@ import { ContainerPickStep } from "./ContainerPickStep"; import { IServiceConnectorContext } from "./IServiceConnectorContext"; -export async function deleteServiceConnector(context: IActionContext, item?: ContainerAppItem): Promise { - if (!item) { - item = await pickContainerApp(context); - } - +export async function deleteServiceConnector(context: ICreateLinkerContext, item?: ContainerAppItem): Promise { + item ??= await pickContainerApp(context); const { subscription, containerApp } = item; - const wizardContext: IServiceConnectorContext = { - activityTitle: localize('deleteServiceConnector', 'Delete Service Connector'), + const activityContext = { ...context, - ...createSubscriptionContext(subscription), + ...await createActivityContext(), containerApp: containerApp, - ...(await createActivityContext()) + activityTitle: localize('deleteServiceConnector', 'Delete Service Connector'), } const promptSteps: AzureWizardPromptStep[] = [ new ContainerPickStep(), ]; - const wizard: AzureWizard = new AzureWizard(wizardContext, { - title: localize('deleteServiceConnector', 'Delete Service Connector'), - promptSteps, - }); - - await wizard.prompt(); - await deleteLinker(wizardContext, item); + await deleteLinker(activityContext, { id: containerApp.id, subscription }, promptSteps); } diff --git a/src/commands/serviceConnector/validateServiceConnector.ts b/src/commands/serviceConnector/validateServiceConnector.ts index 1b4eb2331..d5994c406 100644 --- a/src/commands/serviceConnector/validateServiceConnector.ts +++ b/src/commands/serviceConnector/validateServiceConnector.ts @@ -3,39 +3,29 @@ * Licensed under the MIT License. See License.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { validateLinker } from "@microsoft/vscode-azext-serviceconnector"; -import { AzureWizard, AzureWizardPromptStep, IActionContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; +import { ICreateLinkerContext, validateLinker } from "@microsoft/vscode-azext-serviceconnector"; +import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils"; import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; import { pickContainerApp } from "../../utils/pickContainerApp"; import { ContainerPickStep } from "./ContainerPickStep"; -import { IServiceConnectorWithActivityContext } from "./IServiceConnectorContext"; - -export async function validateServiceConnector(context: IActionContext, item?: ContainerAppItem): Promise { - if (!item) { - item = await pickContainerApp(context); - } +import { IServiceConnectorContext } from "./IServiceConnectorContext"; +export async function validateServiceConnector(context: ICreateLinkerContext, item?: ContainerAppItem): Promise { + item ??= await pickContainerApp(context); const { subscription, containerApp } = item; - const wizardContext: IServiceConnectorWithActivityContext = { - activityTitle: localize('createServiceConnector', 'Validate Service Connector'), + const activityContext = { ...context, - ...createSubscriptionContext(subscription), + ...await createActivityContext(), containerApp: containerApp, - ...(await createActivityContext()) + activityTitle: localize('validateServiceConnector', 'Validate Service Connector'), } - const promptSteps: AzureWizardPromptStep[] = [ + const promptSteps: AzureWizardPromptStep[] = [ new ContainerPickStep(), ]; - const wizard: AzureWizard = new AzureWizard(wizardContext, { - title: localize('deleteServiceConnector', 'Delete Service Connector'), - promptSteps, - }); - - await wizard.prompt(); - await validateLinker(wizardContext, item); + await validateLinker(activityContext, { id: containerApp.id, subscription }, promptSteps); } From 21430d23cfa0bdcb70a6436e3f3c3f401dde1101 Mon Sep 17 00:00:00 2001 From: Megan Mott Date: Tue, 13 Jun 2023 17:06:47 -0700 Subject: [PATCH 3/4] More changes and update utils --- package-lock.json | 79 +++++++++---------- package.json | 4 +- ...istStep.ts => ReplicaContainerListStep.ts} | 2 +- src/commands/logStream/startStreamingLogs.ts | 4 +- ...tainerPickStep.ts => ContainerListStep.ts} | 10 +-- .../IServiceConnectorContext.ts | 5 +- .../createServiceConnector.ts | 4 +- .../deleteServiceConnector.ts | 4 +- .../validateServiceConnector.ts | 4 +- src/utils/azureClients.ts | 2 - 10 files changed, 54 insertions(+), 64 deletions(-) rename src/commands/logStream/{ContainerListStep.ts => ReplicaContainerListStep.ts} (93%) rename src/commands/serviceConnector/{ContainerPickStep.ts => ContainerListStep.ts} (76%) diff --git a/package-lock.json b/package-lock.json index bf0487edc..3b9c22f70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,9 +16,9 @@ "@azure/container-registry": "1.0.0-beta.5", "@azure/core-rest-pipeline": "1.10.3", "@azure/storage-blob": "^12.4.1", - "@microsoft/vscode-azext-azureutils": "^1.0.1", + "@microsoft/vscode-azext-azureutils": "^2.0.0", "@microsoft/vscode-azext-serviceconnector": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", - "@microsoft/vscode-azext-utils": "^1.2.0", + "@microsoft/vscode-azext-utils": "^2.0.0", "@microsoft/vscode-azureresources-api": "^2.0.2", "@octokit/rest": "^18.5.2", "buffer": "^6.0.3", @@ -516,14 +516,14 @@ "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, "node_modules/@azure/logger": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz", - "integrity": "sha512-aK4s3Xxjrx3daZr3VylxejK3vG5ExXck5WOHDJ8in/k9AqlfIyFMMT1uG7u8mNjX+QRILTIn0/Xgschfh/dQ9g==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.4.tgz", + "integrity": "sha512-ustrPY8MryhloQj7OWGe+HrYx+aoiOxzbXTtgblbV3xwCqpzUK36phH3XNHQKj3EPonyFUuDTfR3qFhTEAuZEg==", "dependencies": { "tslib": "^2.2.0" }, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" } }, "node_modules/@azure/logger/node_modules/tslib": { @@ -916,9 +916,9 @@ } }, "node_modules/@microsoft/vscode-azext-azureutils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-azureutils/-/vscode-azext-azureutils-1.0.1.tgz", - "integrity": "sha512-2RzRpFNwdv3oJlimzhF0d4cPJ6G6qN+B9+r0VnBYOPNBXW4lGmk8mBLr0RssDmL7ZBjLewehjg8Vfbc3IEfTdA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-azureutils/-/vscode-azext-azureutils-2.0.0.tgz", + "integrity": "sha512-e8ZpCa/iWZN3CYb2D4pRHAE0m7JdwWTgCl3hhsAqmCUv3j5dqKSSB/wyDeDQvXiqTDrh5br60MU27ts4OUteqA==", "dependencies": { "@azure/arm-resources": "^5.0.0", "@azure/arm-resources-profile-2020-09-01-hybrid": "^2.0.0", @@ -927,10 +927,13 @@ "@azure/arm-storage-profile-2020-09-01-hybrid": "^2.0.0", "@azure/core-client": "^1.6.0", "@azure/core-rest-pipeline": "^1.9.0", - "@microsoft/vscode-azext-utils": "^1.0.0", + "@azure/logger": "^1.0.4", + "@microsoft/vscode-azext-utils": "^2.0.0", "semver": "^7.3.7", - "uuid": "^9.0.0", - "vscode-nls": "^5.0.1" + "uuid": "^9.0.0" + }, + "peerDependencies": { + "@azure/ms-rest-azure-env": "^2.0.0" } }, "node_modules/@microsoft/vscode-azext-azureutils/node_modules/uuid": { @@ -941,11 +944,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/@microsoft/vscode-azext-azureutils/node_modules/vscode-nls": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz", - "integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==" - }, "node_modules/@microsoft/vscode-azext-dev": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-dev/-/vscode-azext-dev-1.0.4.tgz", @@ -1037,18 +1035,18 @@ "node_modules/@microsoft/vscode-azext-serviceconnector": { "version": "0.0.1", "resolved": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", - "integrity": "sha512-oapvw/eRSvnWfENwZ6uF/HT9932HNoL/mFUeuGW24Xe0AZfFufTOzAD2Y3s9cGA5U8L/M1ay9jJrT6oZMPPBvA==", + "integrity": "sha512-hvhFMVDaFpSayyoAGFcdUtqI/6P1h4SFAs62ghb+EnpvT4oUxowrXXJD8HppOvnusBJVM4GF4Hg3vrp/P/aKKg==", "license": "MIT", "dependencies": { "@azure/arm-servicelinker": "^2.1.0", - "@microsoft/vscode-azext-azureutils": "^1.0.0", - "@microsoft/vscode-azext-utils": "^1.2.2" + "@microsoft/vscode-azext-azureutils": "^2.0.0", + "@microsoft/vscode-azext-utils": "^2.0.0" } }, "node_modules/@microsoft/vscode-azext-utils": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.2.tgz", - "integrity": "sha512-mOTcJF8IMsz+Xn8QTUP1AC3K5tPl/3f17L2xGTTtLeV/HJ2sTh/3712NFuN58tnOwdISdazId4tHwaqUta8HEA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-2.0.0.tgz", + "integrity": "sha512-I75IMSo1CvrF8J7S/RoHrvl4yQRWufvFGHSdlGfjBPdYFJ7O9J5hjeDCmv9/WIa8+qbSUmFPPyNZIXibbplSUQ==", "dependencies": { "@microsoft/vscode-azureresources-api": "^2.0.4", "@vscode/extension-telemetry": "^0.6.2", @@ -12693,9 +12691,9 @@ } }, "@azure/logger": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz", - "integrity": "sha512-aK4s3Xxjrx3daZr3VylxejK3vG5ExXck5WOHDJ8in/k9AqlfIyFMMT1uG7u8mNjX+QRILTIn0/Xgschfh/dQ9g==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.4.tgz", + "integrity": "sha512-ustrPY8MryhloQj7OWGe+HrYx+aoiOxzbXTtgblbV3xwCqpzUK36phH3XNHQKj3EPonyFUuDTfR3qFhTEAuZEg==", "requires": { "tslib": "^2.2.0" }, @@ -13043,9 +13041,9 @@ } }, "@microsoft/vscode-azext-azureutils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-azureutils/-/vscode-azext-azureutils-1.0.1.tgz", - "integrity": "sha512-2RzRpFNwdv3oJlimzhF0d4cPJ6G6qN+B9+r0VnBYOPNBXW4lGmk8mBLr0RssDmL7ZBjLewehjg8Vfbc3IEfTdA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-azureutils/-/vscode-azext-azureutils-2.0.0.tgz", + "integrity": "sha512-e8ZpCa/iWZN3CYb2D4pRHAE0m7JdwWTgCl3hhsAqmCUv3j5dqKSSB/wyDeDQvXiqTDrh5br60MU27ts4OUteqA==", "requires": { "@azure/arm-resources": "^5.0.0", "@azure/arm-resources-profile-2020-09-01-hybrid": "^2.0.0", @@ -13054,21 +13052,16 @@ "@azure/arm-storage-profile-2020-09-01-hybrid": "^2.0.0", "@azure/core-client": "^1.6.0", "@azure/core-rest-pipeline": "^1.9.0", - "@microsoft/vscode-azext-utils": "^1.0.0", + "@azure/logger": "^1.0.4", + "@microsoft/vscode-azext-utils": "^2.0.0", "semver": "^7.3.7", - "uuid": "^9.0.0", - "vscode-nls": "^5.0.1" + "uuid": "^9.0.0" }, "dependencies": { "uuid": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" - }, - "vscode-nls": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz", - "integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==" } } }, @@ -13152,17 +13145,17 @@ }, "@microsoft/vscode-azext-serviceconnector": { "version": "file:..\\vscode-azuretools\\serviceconnector\\microsoft-vscode-azext-serviceconnector-0.0.1.tgz", - "integrity": "sha512-oapvw/eRSvnWfENwZ6uF/HT9932HNoL/mFUeuGW24Xe0AZfFufTOzAD2Y3s9cGA5U8L/M1ay9jJrT6oZMPPBvA==", + "integrity": "sha512-hvhFMVDaFpSayyoAGFcdUtqI/6P1h4SFAs62ghb+EnpvT4oUxowrXXJD8HppOvnusBJVM4GF4Hg3vrp/P/aKKg==", "requires": { "@azure/arm-servicelinker": "^2.1.0", - "@microsoft/vscode-azext-azureutils": "^1.0.0", - "@microsoft/vscode-azext-utils": "^1.2.2" + "@microsoft/vscode-azext-azureutils": "^2.0.0", + "@microsoft/vscode-azext-utils": "^2.0.0" } }, "@microsoft/vscode-azext-utils": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-1.2.2.tgz", - "integrity": "sha512-mOTcJF8IMsz+Xn8QTUP1AC3K5tPl/3f17L2xGTTtLeV/HJ2sTh/3712NFuN58tnOwdISdazId4tHwaqUta8HEA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-2.0.0.tgz", + "integrity": "sha512-I75IMSo1CvrF8J7S/RoHrvl4yQRWufvFGHSdlGfjBPdYFJ7O9J5hjeDCmv9/WIa8+qbSUmFPPyNZIXibbplSUQ==", "requires": { "@microsoft/vscode-azureresources-api": "^2.0.4", "@vscode/extension-telemetry": "^0.6.2", diff --git a/package.json b/package.json index d9f85862f..60f5ac088 100644 --- a/package.json +++ b/package.json @@ -406,9 +406,9 @@ "@azure/container-registry": "1.0.0-beta.5", "@azure/core-rest-pipeline": "1.10.3", "@azure/storage-blob": "^12.4.1", - "@microsoft/vscode-azext-azureutils": "^1.0.1", + "@microsoft/vscode-azext-azureutils": "^2.0.0", "@microsoft/vscode-azext-serviceconnector": "file:../vscode-azuretools/serviceconnector/microsoft-vscode-azext-serviceconnector-0.0.1.tgz", - "@microsoft/vscode-azext-utils": "^1.2.0", + "@microsoft/vscode-azext-utils": "^2.0.0", "@microsoft/vscode-azureresources-api": "^2.0.2", "@octokit/rest": "^18.5.2", "buffer": "^6.0.3", diff --git a/src/commands/logStream/ContainerListStep.ts b/src/commands/logStream/ReplicaContainerListStep.ts similarity index 93% rename from src/commands/logStream/ContainerListStep.ts rename to src/commands/logStream/ReplicaContainerListStep.ts index cf3d3a1cd..ecbe59ab6 100644 --- a/src/commands/logStream/ContainerListStep.ts +++ b/src/commands/logStream/ReplicaContainerListStep.ts @@ -8,7 +8,7 @@ import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullProp, nonNullValue } import { localize } from "../../utils/localize"; import { IStreamLogsContext } from "./IStreamLogsContext"; -export class ContainerListStep extends AzureWizardPromptStep { +export class ReplicaContainerListStep extends AzureWizardPromptStep { public async prompt(context: IStreamLogsContext): Promise { const placeHolder: string = localize('selectContainer', 'Select a container'); context.container = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data; diff --git a/src/commands/logStream/startStreamingLogs.ts b/src/commands/logStream/startStreamingLogs.ts index 0e84119ea..947751d19 100644 --- a/src/commands/logStream/startStreamingLogs.ts +++ b/src/commands/logStream/startStreamingLogs.ts @@ -8,8 +8,8 @@ import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; import { pickContainerApp } from "../../utils/pickContainerApp"; -import { ContainerListStep } from "./ContainerListStep"; import { IStreamLogsContext } from "./IStreamLogsContext"; +import { ReplicaContainerListStep } from "./ReplicaContainerListStep"; import { ReplicaListStep } from "./ReplicaListStep"; import { RevisionListStep } from "./RevisionListStep"; import { logStreamRequest } from "./logStreamRequest"; @@ -35,7 +35,7 @@ export async function startStreamingLogs(context: IActionContext, item?: Pick[] = [ new RevisionListStep(), new ReplicaListStep(), - new ContainerListStep(), + new ReplicaContainerListStep(), ]; const wizard: AzureWizard = new AzureWizard(wizardContext, { diff --git a/src/commands/serviceConnector/ContainerPickStep.ts b/src/commands/serviceConnector/ContainerListStep.ts similarity index 76% rename from src/commands/serviceConnector/ContainerPickStep.ts rename to src/commands/serviceConnector/ContainerListStep.ts index 2ff6f7c0d..f6a62645f 100644 --- a/src/commands/serviceConnector/ContainerPickStep.ts +++ b/src/commands/serviceConnector/ContainerListStep.ts @@ -7,9 +7,9 @@ import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullValue } from "@micro import { localize } from "../../utils/localize"; import { IServiceConnectorContext } from "./IServiceConnectorContext"; -export class ContainerPickStep extends AzureWizardPromptStep { +export class ContainerListStep extends AzureWizardPromptStep { public async prompt(context: IServiceConnectorContext): Promise { - const placeHolder: string = localize('selectStream', 'Select a container'); + const placeHolder: string = localize('selectContainer', 'Select a container'); context.scope = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data; } @@ -18,14 +18,14 @@ export class ContainerPickStep extends AzureWizardPromptStep { - const picks = await this.getPicks(context); + const picks = this.getPicks(context); if (picks.length === 1) { context.scope = picks[0].data; } } - private async getPicks(context: IServiceConnectorContext): Promise[]> { - const containers = nonNullValue(context.containerApp.template?.containers); + private getPicks(context: IServiceConnectorContext): IAzureQuickPickItem[] { + const containers = nonNullValue(context.containerApp?.template?.containers); return containers.map(c => { return { label: nonNullValue(c.name), diff --git a/src/commands/serviceConnector/IServiceConnectorContext.ts b/src/commands/serviceConnector/IServiceConnectorContext.ts index 61108e21c..4110f6f76 100644 --- a/src/commands/serviceConnector/IServiceConnectorContext.ts +++ b/src/commands/serviceConnector/IServiceConnectorContext.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { ICreateLinkerContext } from "@microsoft/vscode-azext-serviceconnector"; -import { ContainerAppModel } from "../../tree/ContainerAppItem"; +import { IContainerAppContext } from "../createContainerApp/IContainerAppContext"; -export interface IServiceConnectorContext extends ICreateLinkerContext { - containerApp: ContainerAppModel; +export interface IServiceConnectorContext extends ICreateLinkerContext, IContainerAppContext { } diff --git a/src/commands/serviceConnector/createServiceConnector.ts b/src/commands/serviceConnector/createServiceConnector.ts index 0e225dc15..f4625ee1e 100644 --- a/src/commands/serviceConnector/createServiceConnector.ts +++ b/src/commands/serviceConnector/createServiceConnector.ts @@ -9,7 +9,7 @@ import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; import { pickContainerApp } from "../../utils/pickContainerApp"; -import { ContainerPickStep } from "./ContainerPickStep"; +import { ContainerListStep } from "./ContainerListStep"; import { IServiceConnectorContext } from "./IServiceConnectorContext"; export async function createServiceConnector(context: ICreateLinkerContext, item?: ContainerAppItem): Promise { @@ -24,7 +24,7 @@ export async function createServiceConnector(context: ICreateLinkerContext, item } const promptSteps: AzureWizardPromptStep[] = [ - new ContainerPickStep(), + new ContainerListStep(), ]; await createLinker(activityContext, { id: containerApp.id, subscription }, promptSteps); diff --git a/src/commands/serviceConnector/deleteServiceConnector.ts b/src/commands/serviceConnector/deleteServiceConnector.ts index 7a084beb1..9407b6c5d 100644 --- a/src/commands/serviceConnector/deleteServiceConnector.ts +++ b/src/commands/serviceConnector/deleteServiceConnector.ts @@ -9,7 +9,7 @@ import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; import { pickContainerApp } from "../../utils/pickContainerApp"; -import { ContainerPickStep } from "./ContainerPickStep"; +import { ContainerListStep } from "./ContainerListStep"; import { IServiceConnectorContext } from "./IServiceConnectorContext"; @@ -25,7 +25,7 @@ export async function deleteServiceConnector(context: ICreateLinkerContext, item } const promptSteps: AzureWizardPromptStep[] = [ - new ContainerPickStep(), + new ContainerListStep(), ]; await deleteLinker(activityContext, { id: containerApp.id, subscription }, promptSteps); diff --git a/src/commands/serviceConnector/validateServiceConnector.ts b/src/commands/serviceConnector/validateServiceConnector.ts index d5994c406..67c6f3d7d 100644 --- a/src/commands/serviceConnector/validateServiceConnector.ts +++ b/src/commands/serviceConnector/validateServiceConnector.ts @@ -9,7 +9,7 @@ import { ContainerAppItem } from "../../tree/ContainerAppItem"; import { createActivityContext } from "../../utils/activityUtils"; import { localize } from "../../utils/localize"; import { pickContainerApp } from "../../utils/pickContainerApp"; -import { ContainerPickStep } from "./ContainerPickStep"; +import { ContainerListStep } from "./ContainerListStep"; import { IServiceConnectorContext } from "./IServiceConnectorContext"; export async function validateServiceConnector(context: ICreateLinkerContext, item?: ContainerAppItem): Promise { @@ -24,7 +24,7 @@ export async function validateServiceConnector(context: ICreateLinkerContext, it } const promptSteps: AzureWizardPromptStep[] = [ - new ContainerPickStep(), + new ContainerListStep(), ]; await validateLinker(activityContext, { id: containerApp.id, subscription }, promptSteps); diff --git a/src/utils/azureClients.ts b/src/utils/azureClients.ts index 872ebcf1d..0f4c35d7a 100644 --- a/src/utils/azureClients.ts +++ b/src/utils/azureClients.ts @@ -30,8 +30,6 @@ export function createContainerRegistryClient(context: AzExtClientContext, regis const clientContext = parseClientContext(context); // @azure/container-registry doesn't support ADAL tokens at all. If it sees `signRequest` is defined // it errors, but we don't actually need `signRequest` because this is a T2 package - const credential = clientContext.credentials as { signRequest: unknown }; - credential.signRequest = undefined; return new ContainerRegistryClient(`https://${registry.loginServer}`, clientContext.credentials, { audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud }); From f8117b2756c4d47d9e110291ad1b80fd0d105c90 Mon Sep 17 00:00:00 2001 From: Megan Mott Date: Wed, 14 Jun 2023 09:25:16 -0700 Subject: [PATCH 4/4] Remove comment --- src/utils/azureClients.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/utils/azureClients.ts b/src/utils/azureClients.ts index 0f4c35d7a..a4b428fe7 100644 --- a/src/utils/azureClients.ts +++ b/src/utils/azureClients.ts @@ -28,9 +28,6 @@ export async function createContainerRegistryManagementClient(context: AzExtClie export function createContainerRegistryClient(context: AzExtClientContext, registry: Registry): ContainerRegistryClient { const clientContext = parseClientContext(context); - // @azure/container-registry doesn't support ADAL tokens at all. If it sees `signRequest` is defined - // it errors, but we don't actually need `signRequest` because this is a T2 package - return new ContainerRegistryClient(`https://${registry.loginServer}`, clientContext.credentials, { audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud }); }