-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathgetDefaultContainerAppsResources.ts
More file actions
44 lines (38 loc) · 2.38 KB
/
getDefaultContainerAppsResources.ts
File metadata and controls
44 lines (38 loc) · 2.38 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
39
40
41
42
43
44
/*---------------------------------------------------------------------------------------------
* 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 { type ContainerAppItem, type ContainerAppModel } from "../../../../tree/ContainerAppItem";
import { type ManagedEnvironmentItem } from "../../../../tree/ManagedEnvironmentItem";
import { type DeployWorkspaceProjectContext } from "../../DeployWorkspaceProjectContext";
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 & Partial<DeployWorkspaceProjectContext>,
settings: DeployWorkspaceProjectSettings,
item?: ContainerAppItem | ManagedEnvironmentItem
): Promise<DefaultContainerAppsResources> {
context.telemetry.properties.promptedForEnvironment = 'false'; // Initialize the default value
// If a tree item is provided that can be used to deduce default context values, try to use those first
if (item) {
return await getContainerAppResourcesFromItem(context, item);
}
// Otherwise try to obtain container app resources using any saved workspace settings
if (!context.ignoreExistingDeploySettings) {
const { resourceGroup, managedEnvironment, containerApp } = await getContainerAppResourcesFromSettings(context, settings);
if (resourceGroup && managedEnvironment && containerApp) {
return { resourceGroup, managedEnvironment, containerApp };
}
}
// Otherwise prompt the user for managed environment resources to use
return await promptForEnvironmentResources(context);
}