-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdeployWorkspaceProjectSettings.ts
More file actions
41 lines (33 loc) · 2.12 KB
/
deployWorkspaceProjectSettings.ts
File metadata and controls
41 lines (33 loc) · 2.12 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ConfigurationTarget, type WorkspaceFolder } from "vscode";
import { settingUtils } from "../../utils/settingUtils";
export interface DeployWorkspaceProjectSettings {
// Container app names are unique to a resource group
containerAppResourceGroupName?: string;
containerAppName?: string;
containerRegistryName?: string;
}
export const deployWorkspaceProjectPrefix: string = 'deployWorkspaceProject';
export async function getDeployWorkspaceProjectSettings(rootFolder: WorkspaceFolder): Promise<DeployWorkspaceProjectSettings> {
const settingsPath: string = settingUtils.getDefaultRootWorkspaceSettingsPath(rootFolder);
const containerAppName: string | undefined = settingUtils.getWorkspaceSetting(`${deployWorkspaceProjectPrefix}.containerAppName`, settingsPath);
const containerAppResourceGroupName: string | undefined = settingUtils.getWorkspaceSetting(`${deployWorkspaceProjectPrefix}.containerAppResourceGroupName`, settingsPath);
const containerRegistryName: string | undefined = settingUtils.getWorkspaceSetting(`${deployWorkspaceProjectPrefix}.containerRegistryName`, settingsPath);
return {
containerAppName,
containerAppResourceGroupName,
containerRegistryName
};
}
/**
* @throws Throws an error if the workspace configuration cannot be found in the default settings path
*/
export async function setDeployWorkspaceProjectSettings(rootFolder: WorkspaceFolder, settings: DeployWorkspaceProjectSettings): Promise<void> {
const settingsPath: string = settingUtils.getDefaultRootWorkspaceSettingsPath(rootFolder);
for (const key of Object.keys(settings)) {
await settingUtils.updateWorkspaceSetting(`${deployWorkspaceProjectPrefix}.${key}`, settings[key], settingsPath, ConfigurationTarget.WorkspaceFolder);
}
}