Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
prebansa authored and leantk committed Dec 23, 2019
1 parent 92ec883 commit b9d2f35
Show file tree
Hide file tree
Showing 24 changed files with 308 additions and 280 deletions.
10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/de-de/resources.resjson

This file was deleted.

17 changes: 0 additions & 17 deletions Tasks/BuildctlV0/Strings/resources.resjson/en-US/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/es-es/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/fr-fr/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/it-IT/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/ja-jp/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/ko-KR/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/ru-RU/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/zh-CN/resources.resjson

This file was deleted.

10 changes: 0 additions & 10 deletions Tasks/BuildctlV0/Strings/resources.resjson/zh-TW/resources.resjson

This file was deleted.

61 changes: 0 additions & 61 deletions Tasks/BuildctlV0/task.json

This file was deleted.

61 changes: 0 additions & 61 deletions Tasks/BuildctlV0/task.loc.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"loc.friendlyName": "Container Build",
"loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
"loc.description": "Build Task",
"loc.instanceNameFormat": "Container Build Task",
"loc.group.displayName.containerRepository": "Container Repository",
"loc.group.displayName.commands": "Commands",
"loc.input.label.dockerRegistryServiceConnection": "Docker registry service connection",
"loc.input.help.dockerRegistryServiceConnection": "Select a Docker registry service connection. Required for commands that need to authenticate with a registry.",
"loc.input.label.repository": "Container repository",
"loc.input.help.repository": "Name of the repository.",
"loc.input.label.Dockerfile": "Dockerfile",
"loc.input.help.Dockerfile": "Path to the Dockerfile.",
"loc.input.label.buildContext": "Build context",
"loc.input.help.buildContext": "Path to the Build context.",
"loc.input.label.tags": "Tags",
"loc.input.help.tags": "A list of tags in separate lines. These tags are used in build, push and buildAndPush commands. Ex:<br><br>beta1.1<br>latest",
"loc.input.label.arguments": "Arguments",
"loc.input.help.arguments": "Docker command options. Ex:<br> For build command,<br>--build-arg HTTP_PROXY=http://10.20.30.2:1234 --quiet",
"loc.input.label.addPipelineData": "Add Pipeline metadata to image(s)",
"loc.input.help.addPipelineData": "By default pipeline data like source branch name, build id are added which helps with traceability. For example you can inspect an image to find out which pipeline built the image. You can opt out of this default behavior by using this input.",
"loc.messages.NotAValidSemverVersion": "Version not specified in correct format. E.g: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
"loc.messages.VerifyBuildctlInstallation": "Verifying Buildctl installation...",
"loc.messages.BuildctlLatestNotKnown": "Cannot get the latest Buildctl info from %s. Error %s. Using default Buildctl version %s.",
"loc.messages.BuildctlDownloadFailed": "Failed to download Buildctl from location %s. Error %s",
"loc.messages.BuildctlNotFoundInFolder": "Buildctl executable not found in path %s"
}
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import path = require('path');
import * as toolLib from 'azure-pipelines-tool-lib/tool';
import utils = require("./utils");


tl.setResourcePath(path.join(__dirname, '..', 'task.json'));

async function configureBuildctl() {
var stableBuildKitVersion = await utils.getBuildctlVersion();
var stableBuildKitVersion = await utils.getStableBuildctlVersion();
var buildctlPath = await utils.downloadBuildctl(stableBuildKitVersion);

// prepend the tools path. instructs the agent to prepend for future tasks
Expand All @@ -20,53 +19,58 @@ async function configureBuildctl() {

async function verifyBuildctl() {
tl.debug(tl.loc("VerifyBuildctlInstallation"));

var buildctlToolPath = tl.which("buildctl", true);
var buildctlTool = tl.tool(buildctlToolPath);

buildctlTool.arg("--help");
buildctlTool.exec();
}

async function buildContainer() {
if(process.env["RUNNING_AS_K8_POOLPROVIDER"] == "1") {
if(process.env["RUNNING_ON"] == "KUBERNETES") {

tl.debug("Container building using buildctl");
return buildUsingBuildctl();

}
else {

tl.debug("Container building using docker frontend");
return buildUsingDocker();
}

}
}

async function buildUsingBuildctl() {

await verifyBuildctl();
const dockerfilepath = tl.getInput("dockerFile", true);
const contextpath = tl.getInput("localContext", true);
var podname = await utils.getBuildKitPod();
tl.debug("Podname " +podname);
process.env["BUILDKIT_HOST"] = "kube-pod://"+podname+"?namespace=azuredevops";

await utils.getBuildKitPod();

var contextarg = "--local=context="+tl.getInput("buildContext", true);
var dockerfilearg = "--local=dockerfile="+tl.getInput("dockerFile", true);
var buildctlToolPath = tl.which("buildctl", true);
var buildctlTool = tl.tool(buildctlToolPath);

buildctlTool.arg("build");
buildctlTool.arg('--frontend=dockerfile.v0');

var contextarg = "--local=context="+contextpath;
var dockerfilearg = "--local=dockerfile="+dockerfilepath;
buildctlTool.arg(contextarg);
buildctlTool.arg(dockerfilearg);

return buildctlTool.exec();
}

async function buildUsingDocker() {

const dockerfilepath = tl.getInput("dockerFile", true);
const contextpath = tl.getInput("localContext", true);

var dockerToolPath = tl.which("docker", true);
var command = tl.tool(dockerToolPath);

command.arg("build");
command.arg(["-f", dockerfilepath]);

command.arg(contextpath);

// setup variable to store the command output
Expand Down
Loading

0 comments on commit b9d2f35

Please sign in to comment.