Skip to content

Commit

Permalink
Fix DockerInstallerV0 for ARM agent (#13199)
Browse files Browse the repository at this point in the history
* Fix DockerInstallerV0 for ARM agent

Added case for `armhf` based docker installer
Fixes: #13198
Fix version

* TS Formatting and included missing file task.loc.json
  • Loading branch information
winromulus authored Jun 30, 2020
1 parent 0ee6c8f commit 3106c9f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
25 changes: 15 additions & 10 deletions Tasks/DockerInstallerV0/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const isWindows = os.type().match(/^Win/);
const dockerToolNameWithExtension = dockerToolName + getExecutableExtension();

export async function downloadDocker(version: string, releaseType: string): Promise<string> {

//docker does not follow strict semversion and has leading zeros in versions <10
var cleanVersion = version.replace(/(0+)([1-9]+)/,"$2");
var cleanVersion = version.replace(/(0+)([1-9]+)/, "$2");
var cachedToolpath = toolLib.findLocalTool(dockerToolName + "-" + releaseType, cleanVersion);

if (!cachedToolpath) {
try {
var dockerDownloadPath = await toolLib.downloadTool(getDockerDownloadURL(version, releaseType), dockerToolName + "-" + uuidV4() + getArchiveExtension());
Expand All @@ -26,16 +26,16 @@ export async function downloadDocker(version: string, releaseType: string): Prom
}

var unzipedDockerPath;
if(isWindows) {
unzipedDockerPath = await toolLib.extractZip(dockerDownloadPath);
if (isWindows) {
unzipedDockerPath = await toolLib.extractZip(dockerDownloadPath);
} else {
//tgz is a tar file packaged using gzip utility
unzipedDockerPath = await toolLib.extractTar(dockerDownloadPath);
}

//contents of the extracted archive are under "docker" directory. caching only "docker(.exe)" CLI
unzipedDockerPath = path.join(unzipedDockerPath, "docker", dockerToolNameWithExtension);
cachedToolpath = await toolLib.cacheFile(unzipedDockerPath, dockerToolNameWithExtension, dockerToolName+ "-" + releaseType, cleanVersion);
cachedToolpath = await toolLib.cacheFile(unzipedDockerPath, dockerToolNameWithExtension, dockerToolName + "-" + releaseType, cleanVersion);
}

var Dockerpath = findDocker(cachedToolpath);
Expand All @@ -48,7 +48,7 @@ export async function downloadDocker(version: string, releaseType: string): Prom
}

function findDocker(rootFolder: string) {
var DockerPath = path.join(rootFolder, dockerToolNameWithExtension);
var DockerPath = path.join(rootFolder, dockerToolNameWithExtension);
var allPaths = tl.find(rootFolder);
var matchingResultsFiles = tl.match(allPaths, DockerPath, rootFolder);
return matchingResultsFiles[0];
Expand All @@ -61,8 +61,13 @@ function getDockerDownloadURL(version: string, releaseType: string): string {
switch (os.type()) {
case 'Linux':
platform = "linux";
if (os.arch() === "arm64") {
architecture = "aarch64";
switch (os.arch()) {
case 'arm':
architecture = "armhf";
break;
case 'arm64':
architecture = "aarch64";
break;
}
break;

Expand All @@ -85,7 +90,7 @@ function getExecutableExtension(): string {
}

function getArchiveExtension(): string {
if(isWindows) {
if (isWindows) {
return ".zip";
}
return ".tgz";
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DockerInstallerV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 171,
"Minor": 172,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DockerInstallerV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 171,
"Minor": 172,
"Patch": 0
},
"demands": [],
Expand Down

0 comments on commit 3106c9f

Please sign in to comment.