-
Notifications
You must be signed in to change notification settings - Fork 17
Add additional entry-points for deployWorkspaceProject
#482
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 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5b259b4
Impl
MicroFish91 ec4a1bb
Impl
MicroFish91 5852598
Merge with main:
MicroFish91 1b4f0d6
Updates
MicroFish91 560aa54
Updates
MicroFish91 212c086
Import type
MicroFish91 5211e65
Update ca position
MicroFish91 24d04c5
Update nls
MicroFish91 1063dc9
Merge with main
MicroFish91 4cf94c1
Update
MicroFish91 fabae7a
Update
MicroFish91 16269e8
Feedback
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
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 was deleted.
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
104 changes: 0 additions & 104 deletions
104
src/commands/deployWorkspaceProject/getDefaultValues/getDefaultContainerAppsResources.ts
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...ect/getDefaultValues/getDefaultContainerAppsResources/getDefaultContainerAppsResources.ts
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,38 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import type { ManagedEnvironment } from "@azure/arm-appcontainers"; | ||
| import type { ResourceGroup } from "@azure/arm-resources"; | ||
| import { type ISubscriptionActionContext } from "@microsoft/vscode-azext-utils"; | ||
| import { ContainerAppItem, ContainerAppModel } from "../../../../tree/ContainerAppItem"; | ||
| import { ManagedEnvironmentItem } from "../../../../tree/ManagedEnvironmentItem"; | ||
| import type { DeployWorkspaceProjectSettings } from "../../deployWorkspaceProjectSettings"; | ||
| import { getContainerAppResourcesFromItem, getContainerAppResourcesFromSettings } from "./getDefaultResourcesFrom"; | ||
| import { promptForEnvironmentResources } from "./promptForEnvironmentResources"; | ||
|
|
||
| export interface DefaultContainerAppsResources { | ||
| resourceGroup?: ResourceGroup; | ||
| managedEnvironment?: ManagedEnvironment; | ||
| containerApp?: ContainerAppModel; | ||
| } | ||
|
|
||
| export async function getDefaultContainerAppsResources( | ||
| context: ISubscriptionActionContext, | ||
| settings: DeployWorkspaceProjectSettings | undefined, | ||
| item?: ContainerAppItem | ManagedEnvironmentItem | ||
| ): Promise<DefaultContainerAppsResources> { | ||
| // Try to obtain container app resources using any saved workspace settings | ||
| const { resourceGroup, managedEnvironment, containerApp } = await getContainerAppResourcesFromSettings(context, settings); | ||
|
MicroFish91 marked this conversation as resolved.
|
||
| if (resourceGroup && managedEnvironment && containerApp) { | ||
| return { resourceGroup, managedEnvironment, containerApp }; | ||
| } | ||
|
|
||
| // If a tree item is provided that can be used to deduce default context values, use those, otherwise prompt for an environment | ||
| if (item) { | ||
| return await getContainerAppResourcesFromItem(context, item); | ||
| } else { | ||
| return await promptForEnvironmentResources(context); | ||
| } | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
...spaceProject/getDefaultValues/getDefaultContainerAppsResources/getDefaultResourcesFrom.ts
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,58 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { ContainerApp, ContainerAppsAPIClient } from "@azure/arm-appcontainers"; | ||
| import type { ISubscriptionActionContext } from "@microsoft/vscode-azext-utils"; | ||
| import { ext } from "../../../../extensionVariables"; | ||
| import { ContainerAppItem, ContainerAppModel } from "../../../../tree/ContainerAppItem"; | ||
| import { ManagedEnvironmentItem } from "../../../../tree/ManagedEnvironmentItem"; | ||
| import { createContainerAppsAPIClient } from "../../../../utils/azureClients"; | ||
| import { localize } from "../../../../utils/localize"; | ||
| import type { DeployWorkspaceProjectSettings } from "../../deployWorkspaceProjectSettings"; | ||
| import type { DefaultContainerAppsResources } from "./getDefaultContainerAppsResources"; | ||
| import { getResourcesFromContainerAppHelper, getResourcesFromManagedEnvironmentHelper } from "./getResourceHelpers"; | ||
|
|
||
| const noMatchingResources = { | ||
| resourceGroup: undefined, | ||
| managedEnvironment: undefined, | ||
| containerApp: undefined | ||
| }; | ||
|
|
||
| export async function getContainerAppResourcesFromSettings(context: ISubscriptionActionContext, settings: DeployWorkspaceProjectSettings | undefined): Promise<DefaultContainerAppsResources> { | ||
| if (!settings || !settings.containerAppResourceGroupName || !settings.containerAppName) { | ||
|
MicroFish91 marked this conversation as resolved.
|
||
| return noMatchingResources; | ||
| } | ||
|
|
||
| const resourceGroupName: string = settings.containerAppResourceGroupName; | ||
| const containerAppName: string = settings.containerAppName; | ||
|
|
||
| try { | ||
| const client: ContainerAppsAPIClient = await createContainerAppsAPIClient(context); | ||
| const containerApp: ContainerApp = await client.containerApps.get(resourceGroupName, containerAppName); | ||
| const containerAppModel: ContainerAppModel = ContainerAppItem.CreateContainerAppModel(containerApp); | ||
|
|
||
| const resources: DefaultContainerAppsResources = await getResourcesFromContainerAppHelper(context, containerAppModel); | ||
| ext.outputChannel.appendLog(localize('foundResourceMatch', 'Used saved workspace settings and found existing container app resources.')); | ||
|
|
||
| return resources; | ||
| } catch { | ||
| ext.outputChannel.appendLog(localize('noResourceMatch', 'Used saved workspace settings to search for container app "{0}" in resource group "{1}" but found no match.', settings.containerAppName, settings.containerAppResourceGroupName)); | ||
| return noMatchingResources; | ||
| } | ||
| } | ||
|
|
||
| export async function getContainerAppResourcesFromItem(context: ISubscriptionActionContext, item: ContainerAppItem | ManagedEnvironmentItem): Promise<DefaultContainerAppsResources> { | ||
|
MicroFish91 marked this conversation as resolved.
|
||
| if (!ContainerAppItem.isContainerAppItem(item) && !ManagedEnvironmentItem.isManagedEnvironmentItem(item)) { | ||
| const incompatibleMessage: string = localize('incompatibleTreeItem', 'An incompatible Azure Container Apps tree item was provided for project deployment.'); | ||
| ext.outputChannel.appendLog(localize('incompatibleMessageLog', 'Error: {0}', incompatibleMessage)); | ||
| throw new Error(incompatibleMessage); | ||
| } | ||
|
|
||
| if (ContainerAppItem.isContainerAppItem(item)) { | ||
|
MicroFish91 marked this conversation as resolved.
|
||
| return await getResourcesFromContainerAppHelper(context, item.containerApp); | ||
| } else { | ||
| return await getResourcesFromManagedEnvironmentHelper(context, item.managedEnvironment); | ||
| } | ||
| } | ||
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.