Add Azure Container Apps API type definition and util (#3934)

This commit is contained in:
Matthew Fisher 2024-02-12 11:14:41 -08:00 коммит произвёл GitHub
Родитель 37e277af3f
Коммит b367786246
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 63 добавлений и 1 удалений

Просмотреть файл

@ -3,9 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { apiUtils } from "@microsoft/vscode-azext-utils";
import { UserCancelledError, apiUtils, type IActionContext } from "@microsoft/vscode-azext-utils";
import { type AzureHostExtensionApi } from "@microsoft/vscode-azext-utils/hostapi";
import { commands } from "vscode";
import { localize } from "./localize";
import type * as acaApi from "./vscode-azurecontainerapps.api";
export async function getResourceGroupsApi(): Promise<AzureHostExtensionApi> {
const rgApiProvider = await apiUtils.getExtensionExports<apiUtils.AzureExtensionApiProvider>('ms-azuretools.vscode-azureresourcegroups');
@ -15,3 +17,23 @@ export async function getResourceGroupsApi(): Promise<AzureHostExtensionApi> {
throw new Error(localize('noResourceGroupExt', 'Could not find the Azure Resource Groups extension'));
}
}
/**
* @param installMessage Override default message shown if extension is not installed.
*/
export async function getAzureContainerAppsApi(context: IActionContext, installMessage?: string): Promise<acaApi.AzureContainerAppsExtensionApi> {
const acaExtensionId: string = 'ms-azuretools.vscode-azurecontainerapps';
const acaExtension: apiUtils.AzureExtensionApiProvider | undefined = await apiUtils.getExtensionExports(acaExtensionId);
if (acaExtension) {
return acaExtension.getApi<acaApi.AzureContainerAppsExtensionApi>('^0.0.1');
}
await context.ui.showWarningMessage(installMessage ??
localize('acaInstall', 'You must have the "Azure Container Apps" extension installed to perform this operation.'), { title: 'Install', stepName: 'installContainerApps' });
void commands.executeCommand('extension.open', acaExtensionId);
// We still need to throw an error even if the user installs
throw new UserCancelledError('postInstallContainerApps');
}

40
src/vscode-azurecontainerapps.api.d.ts поставляемый Normal file
Просмотреть файл

@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export interface AzureContainerAppsExtensionApi {
apiVersion: string;
deployWorkspaceProject(options: DeployWorkspaceProjectOptionsContract): Promise<DeployWorkspaceProjectResults>;
}
export interface DeployWorkspaceProjectOptionsContract {
// Existing resources
subscriptionId?: string;
resourceGroupId?: string;
// Workspace deployment paths (absolute fs path)
rootPath?: string;
srcPath?: string;
dockerfilePath?: string;
// Options
suppressConfirmation?: boolean; // Suppress any [resource] confirmation prompts
suppressContainerAppCreation?: boolean;
ignoreExistingDeploySettings?: boolean;
shouldSaveDeploySettings?: boolean;
}
export interface DeployWorkspaceProjectResults {
resourceGroupId?: string;
logAnalyticsWorkspaceId?: string;
managedEnvironmentId?: string;
containerAppId?: string;
// ACR
registryId?: string;
registryLoginServer?: string;
registryUsername?: string;
registryPassword?: string;
imageName?: string;
}