-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdeployImageApi.ts
More file actions
48 lines (41 loc) · 2.31 KB
/
deployImageApi.ts
File metadata and controls
48 lines (41 loc) · 2.31 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
45
46
47
48
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { callWithMaskHandling, createSubscriptionContext, ISubscriptionActionContext, ITreeItemPickerContext } from "@microsoft/vscode-azext-utils";
import { acrDomain } from "../../constants";
import { detectRegistryDomain, getRegistryFromAcrName } from "../../utils/imageNameUtils";
import { pickContainerApp } from "../../utils/pickContainerApp";
import { deployImage } from "./deployImage";
import { IDeployImageContext } from "./IDeployImageContext";
// The interface of the command options passed to the Azure Container Apps extension's deployImageToAca command
// This interface is shared with the Docker extension (https://github.com/microsoft/vscode-docker)
interface DeployImageToAcaOptionsContract {
image: string;
registryName: string;
username?: string;
secret?: string;
}
export async function deployImageApi(context: ITreeItemPickerContext & Partial<IDeployImageContext>, deployImageOptions: DeployImageToAcaOptionsContract): Promise<void> {
context.suppressCreatePick = true;
const node = await pickContainerApp(context);
const { subscription } = node;
Object.assign(context, {...createSubscriptionContext(subscription) }, deployImageOptions);
context.registryDomain = detectRegistryDomain(deployImageOptions.registryName);
if (context.registryDomain === acrDomain) {
context.registry = await getRegistryFromAcrName(<ISubscriptionActionContext>context, deployImageOptions.registryName);
}
// Mask sensitive data
if (deployImageOptions.secret) {
context.valuesToMask.push(deployImageOptions.secret);
}
if (deployImageOptions.username) {
context.valuesToMask.push(deployImageOptions.username);
}
context.valuesToMask.push(deployImageOptions.image);
if (deployImageOptions.secret) {
return callWithMaskHandling<void>(() => deployImage(context, node), deployImageOptions.secret);
} else {
return deployImage(context, node);
}
}