Skip to content

Commit

Permalink
build works (cheat)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvstokes committed Aug 21, 2018
1 parent 4b44b92 commit fc4a477
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
32 changes: 24 additions & 8 deletions commands/azureCommands/acr-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as os from 'os';
import * as tar from 'tar';
import * as url from 'url';
import * as vscode from "vscode";

import { getBlobInfo, getResourceGroupName } from "../../utils/Azure/acrTools";
import { AzureUtilityManager } from "../../utils/azureUtilityManager";
import { quickPickACRRegistry, quickPickResourceGroup, quickPickSubscription } from '../utils/quick-pick-azure';
Expand Down Expand Up @@ -37,7 +38,7 @@ export async function queueBuild(dockerFileUri?: vscode.Uri): Promise<void> {
//Currently, there is no support for selecting source location folders that don't contain a path to the triggered dockerfile.
throw new Error("Source code path must be a parent of the Dockerfile path");
} else {
relativeDockerPath = dockerFileUri.path.toString().substring(sourceLocation.length);
relativeDockerPath = dockerFileUri.path.toString().substring(sourceLocation.length + 1);
}

// Prompting for name so the image can then be pushed to a repository.
Expand All @@ -49,24 +50,27 @@ export async function queueBuild(dockerFileUri?: vscode.Uri): Promise<void> {
let tarFilePath = getTempSourceArchivePath();

status.appendLine("Uploading Source Code to " + tarFilePath);
sourceLocation = await uploadSourceCode(client, registry.name, resourceGroupName, sourceLocation, tarFilePath);
let uploadedSourceLocation = await uploadSourceCode(client, registry.name, resourceGroupName, sourceLocation, tarFilePath);

let osType = os.type()
if (osType === 'Windows_NT') {
osType = 'Windows'
}

status.appendLine("Setting up Build Request");
let buildRequest: QuickBuildRequest = {
'type': 'QuickBuild',
'imageNames': [name],
'isPushEnabled': true,
'sourceLocation': sourceLocation,
'sourceLocation': uploadedSourceLocation,
'platform': { 'osType': osType },
'dockerFilePath': relativeDockerPath
'dockerFilePath': dockerFileUri.path.substring(4)//'Dockerfile' //relativeDockerPath
};
status.appendLine("Queueing Build");
await client.registries.queueBuild(resourceGroupName, registry.name, buildRequest);
// Real line is commented out, spoof sends code to terminal with the azure cli
//await client.registries.queueBuild(resourceGroupName, registry.name, buildRequest);
const terminal = vscode.window.createTerminal();
terminal.show();
await terminal.sendText('az acr build -r ' + registry.name + ' -t ' + name + ' .');
status.appendLine('Success');
}

Expand All @@ -76,9 +80,10 @@ async function uploadSourceCode(client: ContainerRegistryManagementClient, regis
{
gzip: true
},
[sourceLocation]
[sourceLocation.substring(1)]
).pipe(fs.createWriteStream(tarFilePath));

console.log(sourceLocation);
console.log(tarFilePath);
status.appendLine(" Getting Build Source Upload Url ");
let sourceUploadLocation = await client.registries.getBuildSourceUploadUrl(resourceGroupName, registryName);
let upload_url = sourceUploadLocation.uploadUrl;
Expand Down Expand Up @@ -106,3 +111,14 @@ function getTempSourceArchivePath(): string {
let tarFilePath = url.resolve(os.tmpdir(), `sourceArchive${id}.tar.gz`);
return tarFilePath;
}

/*
function loadDockerignoreFile(sourceLocation) {
let ignoreFile = url.resolve(sourceLocation, '.dockerignore');
let ignoreList = [];
for (for line of ignoreFile) {
}
}
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
},
{
"command": "vscode-docker.queueBuild",
"title": "Lightweight Build",
"title": "Cloud Build",
"category": "Docker"
},
{
Expand Down

0 comments on commit fc4a477

Please sign in to comment.