-
Notifications
You must be signed in to change notification settings - Fork 17
Add an API entry-point to the deployWorkspaceProject command
#578
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
Changes from 49 commits
3f97bf8
63327a8
c141c41
4d4d245
9a2ac95
dcfb0e0
0535237
9bca1f4
d5f09fc
cc614bf
6238290
3617d8e
a4941db
5aaa76e
63bc92a
dd588b9
8b57bae
4c98107
976aadb
6cb885a
c8d93c3
5b04b68
dffdff2
99c8007
9928198
fb52b44
b3ba7b6
f45ff07
645863c
ca46995
72f5bdc
1b4c909
64d237a
1da6c7a
b889b70
4d2afd2
6436c7b
1fd1c21
bdcdb92
27e2fa2
fa02fd4
3521e6f
19bee17
17dd935
cdd88f6
e22058d
ce947c3
8518640
283c86a
e0d9e70
a1915da
db57811
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Change Log | ||
|
|
||
| ## 0.0.1 | ||
|
|
||
| * Initial release | ||
|
|
||
| ### Added | ||
|
|
||
| * Added an API entry-point to the `deployWorkspaceProject` command [#578](https://github.com/microsoft/vscode-azurecontainerapps/pull/578) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { type ResourceGroup } from "@azure/arm-resources"; | ||
| import { ResourceGroupListStep, parseAzureResourceGroupId } from "@microsoft/vscode-azext-azureutils"; | ||
| import { createSubscriptionContext, subscriptionExperience, type IActionContext, type ISubscriptionActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils"; | ||
| import { type AzureSubscription } from "@microsoft/vscode-azureresources-api"; | ||
| import { Uri, type WorkspaceFolder } from "vscode"; | ||
| import { ext } from "../../extensionVariables"; | ||
| import { getWorkspaceFolderFromPath } from "../../utils/workspaceUtils"; | ||
| import { deployWorkspaceProjectInternal, type DeployWorkspaceProjectInternalContext } from "../deployWorkspaceProject/deployWorkspaceProjectInternal"; | ||
| import { getDeployWorkspaceProjectResults, type DeployWorkspaceProjectResults } from "../deployWorkspaceProject/getDeployWorkspaceProjectResults"; | ||
| import type * as api from "./vscode-azurecontainerapps.api"; | ||
|
|
||
| export async function deployWorkspaceProjectApi(context: IActionContext, deployWorkspaceProjectOptions: api.DeployWorkspaceProjectOptionsContract): Promise<DeployWorkspaceProjectResults> { | ||
| const { resourceGroupId, rootPath, dockerfilePath, srcPath, suppressConfirmation, suppressContainerAppCreation, ignoreExistingDeploySettings, shouldSaveDeploySettings } = deployWorkspaceProjectOptions; | ||
|
|
||
| const subscription: AzureSubscription = await subscriptionExperience(context, ext.rgApiV2.resources.azureResourceTreeDataProvider, { | ||
| selectBySubscriptionId: getSubscriptionIdFromOptions(deployWorkspaceProjectOptions), | ||
| showLoadingPrompt: false | ||
| }); | ||
| const subscriptionContext: ISubscriptionContext = createSubscriptionContext(subscription); | ||
|
|
||
| const rootFolder: WorkspaceFolder | undefined = rootPath ? getWorkspaceFolderFromPath(rootPath) : undefined; | ||
| const resourceGroup: ResourceGroup | undefined = resourceGroupId ? await getResourceGroupFromId({ ...context, ...subscriptionContext }, resourceGroupId) : undefined; | ||
|
|
||
| const deployWorkspaceProjectInternalContext: DeployWorkspaceProjectInternalContext = Object.assign(context, { | ||
| ...subscriptionContext, | ||
| subscription, | ||
| resourceGroup, | ||
| rootFolder, | ||
| srcPath: srcPath ? Uri.file(srcPath).fsPath : undefined, | ||
|
nturinski marked this conversation as resolved.
Outdated
|
||
| dockerfilePath: dockerfilePath ? Uri.file(dockerfilePath).fsPath : undefined, | ||
| ignoreExistingDeploySettings, | ||
| shouldSaveDeploySettings: !!shouldSaveDeploySettings, | ||
| }); | ||
|
|
||
| const deployWorkspaceProjectResultContext = await deployWorkspaceProjectInternal(deployWorkspaceProjectInternalContext, undefined, { | ||
| // Don't show activity log updates in ACA when another client extension calls into this API. | ||
| // Let each client decide how it wants to show its own activity log updates. | ||
| suppressActivity: true, | ||
| suppressConfirmation, | ||
| suppressContainerAppCreation, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me know if you think it would be a good idea to default some of these values
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this comment still make sense? A lot of this seems defaulted already. |
||
| suppressProgress: true, | ||
| suppressWizardTitle: true, | ||
| }); | ||
|
|
||
| return await getDeployWorkspaceProjectResults(deployWorkspaceProjectResultContext); | ||
| } | ||
|
|
||
| function getSubscriptionIdFromOptions(deployWorkspaceProjectOptions: api.DeployWorkspaceProjectOptionsContract): string | undefined { | ||
| if (deployWorkspaceProjectOptions.subscriptionId) { | ||
| return deployWorkspaceProjectOptions.subscriptionId; | ||
| } else if (deployWorkspaceProjectOptions.resourceGroupId) { | ||
| return parseAzureResourceGroupId(deployWorkspaceProjectOptions.resourceGroupId).subscriptionId as string; | ||
| } else { | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| async function getResourceGroupFromId(context: ISubscriptionActionContext, resourceGroupId: string): Promise<ResourceGroup | undefined> { | ||
| const resourceGroups: ResourceGroup[] = await ResourceGroupListStep.getResourceGroups(context); | ||
| return resourceGroups.find(rg => rg.id === resourceGroupId); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { callWithTelemetryAndErrorHandling, createApiProvider, type IActionContext, type apiUtils } from "@microsoft/vscode-azext-utils"; | ||
| import { deployWorkspaceProjectApi } from "./deployWorkspaceProjectApi"; | ||
| import type * as api from "./vscode-azurecontainerapps.api"; | ||
|
|
||
| export function getAzureContainerAppsApiProvider(): apiUtils.AzureExtensionApiProvider { | ||
| return createApiProvider([<api.AzureContainerAppsExtensionApi>{ | ||
| apiVersion: '0.0.1', | ||
|
|
||
| deployWorkspaceProject: async (options: api.DeployWorkspaceProjectOptionsContract) => await callWithTelemetryAndErrorHandling('containerApps.api.deployWorkspaceProject', async (context: IActionContext) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I prefer that we keep the apiProvider looking clean like so:
And then in |
||
| return await deployWorkspaceProjectApi(context, options); | ||
| }) | ||
| }]); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * 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; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.