-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRunStep.ts
More file actions
43 lines (36 loc) · 2.08 KB
/
RunStep.ts
File metadata and controls
43 lines (36 loc) · 2.08 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { DockerBuildRequest as AcrDockerBuildRequest } from "@azure/arm-containerregistry";
import { AzExtFsExtra, AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils";
import * as path from 'path';
import type { Progress } from "vscode";
import { localize } from "../../../../utils/localize";
import type { IBuildImageInAzureContext } from "./IBuildImageInAzureContext";
export class RunStep extends AzureWizardExecuteStep<IBuildImageInAzureContext> {
public priority: number = 200;
public async execute(context: IBuildImageInAzureContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
try {
const rootUri = context.rootFolder.uri;
const runRequest: AcrDockerBuildRequest = {
type: 'DockerBuildRequest',
imageNames: [context.imageName],
isPushEnabled: true,
sourceLocation: context.uploadedSourceLocation,
platform: { os: context.os },
dockerFilePath: path.relative(rootUri.path, context.dockerfilePath)
};
const building: string = localize('buildingImage', 'Building image "{0}" in registry "{1}"...', context.imageName, context.registryName);
progress.report({ message: building });
context.run = await context.client.registries.beginScheduleRunAndWait(context.resourceGroupName, context.registryName, runRequest);
} finally {
if (await AzExtFsExtra.pathExists(context.tarFilePath)) {
await AzExtFsExtra.deleteResource(context.tarFilePath);
}
}
}
public shouldExecute(context: IBuildImageInAzureContext): boolean {
return !context.run
}
}