-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathgetDefaultAcrResources.ts
More file actions
38 lines (32 loc) · 1.9 KB
/
getDefaultAcrResources.ts
File metadata and controls
38 lines (32 loc) · 1.9 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 { Registry } from "@azure/arm-containerregistry";
import type { ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { ext } from "../../../extensionVariables";
import { localize } from "../../../utils/localize";
import { AcrListStep } from "../../deployImage/imageSource/containerRegistry/acr/AcrListStep";
import { DeployWorkspaceProjectSettings } from "../DeployWorkspaceProjectSettings";
interface DefaultAcrResources {
registry?: Registry;
imageName?: string;
}
export async function getDefaultAcrResources(context: ISubscriptionActionContext, settings: DeployWorkspaceProjectSettings | undefined): Promise<DefaultAcrResources> {
const noMatchingResource = { registry: undefined };
if (!settings || !settings.containerRegistryName) {
return noMatchingResource;
}
const registries: Registry[] = await AcrListStep.getRegistries(context);
const savedRegistry: Registry | undefined = registries.find(r => r.name === settings.containerRegistryName);
if (savedRegistry) {
ext.outputChannel.appendLog(localize('foundResourceMatch', 'Used saved workspace settings and found an existing container registry.'));
return {
registry: savedRegistry,
imageName: `${settings.containerAppName || savedRegistry.name}:latest`
};
} else {
ext.outputChannel.appendLog(localize('noResourceMatch', 'Used saved workspace settings to search for Azure Container Registry "{0}" but found no match.', settings.containerRegistryName));
return noMatchingResource;
}
}