-
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
Merged
Merged
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
3f97bf8
Wip
MicroFish91 63327a8
Wip
MicroFish91 c141c41
Wip
MicroFish91 4d4d245
Update verbiage
MicroFish91 9a2ac95
Remove activity context for api
MicroFish91 dcfb0e0
Clean up misc
MicroFish91 0535237
Revert
MicroFish91 9bca1f4
Hide api command from palette
MicroFish91 d5f09fc
Api context
MicroFish91 cc614bf
Misc
MicroFish91 6238290
Skip checking workspace settings from api entry point
MicroFish91 3617d8e
Change to fsPath
MicroFish91 a4941db
invokedFromApi
MicroFish91 5aaa76e
Add api.d.ts
MicroFish91 63bc92a
Remove api loading prompt
MicroFish91 dd588b9
Add subscription ID support
MicroFish91 8b57bae
Update option name
MicroFish91 4c98107
Update deployWorkspaceProjectResults
MicroFish91 976aadb
Misc
MicroFish91 6cb885a
Updates with shared tools changes
MicroFish91 c8d93c3
Merge branch 'main' of https://github.com/microsoft/vscode-azureconta…
MicroFish91 5b04b68
Reset package deps
MicroFish91 dffdff2
Upgrade deps
MicroFish91 99c8007
Update comment
MicroFish91 9928198
Update comments
MicroFish91 fb52b44
Update comment
MicroFish91 b3ba7b6
Microsoft header
MicroFish91 f45ff07
suppressConfirmation
MicroFish91 645863c
No skip create message
MicroFish91 ca46995
Merge with main
MicroFish91 72f5bdc
Simplify output messages
MicroFish91 1b4c909
Misc
MicroFish91 64d237a
Add ignoreExistingDeploySettings
MicroFish91 1da6c7a
Decouple API from deployWorkspaceProject
MicroFish91 b889b70
Add promptForEnvironmentResources comments
MicroFish91 4d2afd2
Expose a proper API interface using api provider
MicroFish91 6436c7b
Update changelog
MicroFish91 1fd1c21
Remove comment
MicroFish91 bdcdb92
Change type
MicroFish91 27e2fa2
Add dwp internal
MicroFish91 fa02fd4
Revert
MicroFish91 3521e6f
Merge with internal branch
MicroFish91 19bee17
centralize getDeployWorkspaceProjectResults
MicroFish91 17dd935
Remove unused values
MicroFish91 cdd88f6
Remove unused values
MicroFish91 e22058d
Merge branch 'mwf/dwp-internal' of https://github.com/microsoft/vscod…
MicroFish91 ce947c3
Merge branch 'main' of https://github.com/microsoft/vscode-azureconta…
MicroFish91 8518640
Merge branch 'mwf/dwp-internal' of https://github.com/microsoft/vscod…
MicroFish91 283c86a
Merge with main
MicroFish91 e0d9e70
Feedback
MicroFish91 a1915da
Formatting
MicroFish91 db57811
newline
MicroFish91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { callWithTelemetryAndErrorHandling, 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(deployWorkspaceProjectOptions: api.DeployWorkspaceProjectOptionsContract): Promise<DeployWorkspaceProjectResults> { | ||
| return await callWithTelemetryAndErrorHandling('containerApps.api.deployWorkspaceProject', async (context: IActionContext): 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, | ||
| dockerfilePath: dockerfilePath ? Uri.file(dockerfilePath).fsPath : undefined, | ||
| ignoreExistingDeploySettings, | ||
| shouldSaveDeploySettings: !!shouldSaveDeploySettings, | ||
| }); | ||
|
|
||
| const deployWorkspaceProjectResultContext = await deployWorkspaceProjectInternal(deployWorkspaceProjectInternalContext, undefined, { | ||
| suppressActivity: true, | ||
| suppressConfirmation, | ||
| suppressContainerAppCreation, | ||
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { createApiProvider, 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: deployWorkspaceProjectApi | ||
| }]); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.