-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathgetDefaultContainerAppsResources.ts
More file actions
38 lines (34 loc) · 2.04 KB
/
getDefaultContainerAppsResources.ts
File metadata and controls
38 lines (34 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);
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);
}
}