Skip to content

Commit

Permalink
Revert "Added Microsoft Go tool support (#19000)" (#19012)
Browse files Browse the repository at this point in the history
* Revert "Added Microsoft Go tool support (#19000)"

This reverts commit 3d8da00.

* Update GoToolV0 to 0.229.1

* Update GoToolV0 to 0.229.1 in task.loc.json

---------

Co-authored-by: Mohith <[email protected]>
  • Loading branch information
dagood and v-mohithgc authored Sep 29, 2023
1 parent 37d7678 commit 3cac0cb
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
"loc.input.help.goPath": "A custom value for the GOPATH environment variable.",
"loc.input.label.goBin": "GOBIN",
"loc.input.help.goBin": "A custom value for the GOBIN environment variable.",
"loc.input.label.goSource": "Go source",
"loc.input.help.goSource": "Go distribution to install",
"loc.messages.FailedToDownload": "Failed to download Go version %s. Verify that the version is valid and resolve any other issues. Error: %s",
"loc.messages.TempDirNotSet": "The 'Agent.TempDirectory' environment variable was expected to be set."
}
54 changes: 12 additions & 42 deletions Tasks/GoToolV0/gotool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,26 @@ import * as telemetry from 'azure-pipelines-tasks-utility-common/telemetry';

let osPlat: string = os.platform();
let osArch: string = os.arch();
let defaultSource: string = 'https://storage.googleapis.com/golang/'
let microsoftSource: string = 'https://aka.ms/golang/release/latest/'

async function run() {
try {
let version = tl.getInput('version', true).trim();
let goSourceInput = tl.getInput('goSource', false)
tl.debug("goSourceInput:"+goSourceInput);
if(goSourceInput == "downloadFromDefaultSource")
{
goSourceInput = defaultSource;
tl.debug("goSourceInput:"+goSourceInput);
}
else if(goSourceInput == "downloadFromMicrosoftSource")
{
goSourceInput = microsoftSource;
tl.debug("goSourceInput:"+goSourceInput);
}
if (!goSourceInput) {
goSourceInput = defaultSource
} else {
goSourceInput = goSourceInput.trim()
}
// Is there a safe way to allow fully custom URLs? How would we create the cache key?
if (goSourceInput != defaultSource && goSourceInput != microsoftSource) {
throw new Error('Only google and Microsoft sources are allowed')
}
await getGo(goSourceInput, version);
telemetry.emitTelemetry('TaskHub', 'GoToolV0', { version, goSourceInput });
await getGo(version);
telemetry.emitTelemetry('TaskHub', 'GoToolV0', { version });
}
catch (error) {
tl.setResult(tl.TaskResult.Failed, error);
}
}

async function getGo(source: string, version: string) {
async function getGo(version: string) {
// check cache
let toolPath: string = undefined;
let toolName: string
if (source === defaultSource) {
toolName = 'go'
} else if (source === microsoftSource) {
toolName = 'microsoftgo'
}
if (toolName) {
// no caching of unknown sources
toolPath = toolLib.findLocalTool(toolName, fixVersion(version));
}
let toolPath: string;
toolPath = toolLib.findLocalTool('go', fixVersion(version));

if (!toolPath) {
// download, extract, cache
toolPath = await acquireGo(source, version, toolName);
toolPath = await acquireGo(version);
tl.debug("Go tool is cached under " + toolPath);
}

Expand All @@ -70,12 +40,12 @@ async function getGo(source: string, version: string) {
}


async function acquireGo(source:string, version: string, toolName: string): Promise<string> {
async function acquireGo(version: string): Promise<string> {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
let fileName: string = getFileName(version);
let downloadUrl: string = getDownloadUrl(source, fileName);
let downloadUrl: string = getDownloadUrl(fileName);
let downloadPath: string = null;
try {
downloadPath = await toolLib.downloadTool(downloadUrl);
Expand Down Expand Up @@ -123,8 +93,8 @@ function getFileName(version: string): string {
return filename;
}

function getDownloadUrl(source: string, filename: string): string {
return util.format("%s%s", source, filename);
function getDownloadUrl(filename: string): string {
return util.format("https://storage.googleapis.com/golang/%s", filename);
}

function setGoEnvironmentVariables(goRoot: string) {
Expand Down
6 changes: 3 additions & 3 deletions Tasks/GoToolV0/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 64 additions & 76 deletions Tasks/GoToolV0/task.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,69 @@
{
"id": "334727F4-9495-4F9D-A391-FC621D671474",
"name": "GoTool",
"friendlyName": "Go tool installer",
"description": "Find in cache or download a specific version of Go and add it to the PATH",
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/go-tool",
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=867581) or [see the Go documentation](https://golang.org/doc/)",
"category": "Tool",
"runsOn": [
"Agent",
"DeploymentGroup"
],
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 229,
"Patch": 0
},
"satisfies": [
"GO"
],
"demands": [],
"instanceNameFormat": "Use Go $(version)",
"groups": [
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": false
}
],
"inputs": [
{
"name": "version",
"type": "string",
"label": "Version",
"defaultValue": "1.19",
"required": true,
"helpMarkDown": "The Go version to download (if necessary) and use. Example: 1.9.3"
},
{
"name": "goPath",
"type": "string",
"label": "GOPATH",
"helpMarkDown": "A custom value for the GOPATH environment variable.",
"groupName": "advanced"
"id": "334727F4-9495-4F9D-A391-FC621D671474",
"name": "GoTool",
"friendlyName": "Go tool installer",
"description": "Find in cache or download a specific version of Go and add it to the PATH",
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/go-tool",
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=867581) or [see the Go documentation](https://golang.org/doc/)",
"category": "Tool",
"runsOn": [
"Agent",
"DeploymentGroup"
],
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 229,
"Patch": 1
},
{
"name": "goBin",
"type": "string",
"label": "GOBIN",
"helpMarkDown": "A custom value for the GOBIN environment variable.",
"groupName": "advanced"
},
{
"name": "goSource",
"type": "pickList",
"label": "Go source",
"required": false,
"defaultValue": "downloadFromDefaultSource",
"options": {
"downloadFromDefaultSource": "Go Tools",
"downloadFromMicrosoftSource": "MS Go Tools"
},
"helpMarkDown": "Go distribution to install"
}
],
"execution": {
"Node10": {
"target": "gotool.js",
"argumentFormat": ""
"satisfies": [
"GO"
],
"demands": [],
"instanceNameFormat": "Use Go $(version)",
"groups": [
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": false
}
],
"inputs": [
{
"name": "version",
"type": "string",
"label": "Version",
"defaultValue": "1.10",
"required": true,
"helpMarkDown": "The Go version to download (if necessary) and use. Example: 1.9.3"
},
{
"name": "goPath",
"type": "string",
"label": "GOPATH",
"helpMarkDown": "A custom value for the GOPATH environment variable.",
"groupName": "advanced"
},
{
"name": "goBin",
"type": "string",
"label": "GOBIN",
"helpMarkDown": "A custom value for the GOBIN environment variable.",
"groupName": "advanced"
}
],
"execution": {
"Node10": {
"target": "gotool.js",
"argumentFormat": ""
},
"Node16": {
"target": "gotool.js",
"argumentFormat": ""
}
},
"Node16": {
"target": "gotool.js",
"argumentFormat": ""
"messages": {
"FailedToDownload": "Failed to download Go version %s. Verify that the version is valid and resolve any other issues. Error: %s",
"TempDirNotSet": "The 'Agent.TempDirectory' environment variable was expected to be set."
}
},
"messages": {
"FailedToDownload": "Failed to download Go version %s. Verify that the version is valid and resolve any other issues. Error: %s",
"TempDirNotSet": "The 'Agent.TempDirectory' environment variable was expected to be set."
}
}
16 changes: 2 additions & 14 deletions Tasks/GoToolV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 229,
"Patch": 0
"Patch": 1
},
"satisfies": [
"GO"
Expand All @@ -33,7 +33,7 @@
"name": "version",
"type": "string",
"label": "ms-resource:loc.input.label.version",
"defaultValue": "1.19",
"defaultValue": "1.10",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.version"
},
Expand All @@ -50,18 +50,6 @@
"label": "ms-resource:loc.input.label.goBin",
"helpMarkDown": "ms-resource:loc.input.help.goBin",
"groupName": "advanced"
},
{
"name": "goSource",
"type": "pickList",
"label": "ms-resource:loc.input.label.goSource",
"required": false,
"defaultValue": "downloadFromDefaultSource",
"options": {
"downloadFromDefaultSource": "Go Tools",
"downloadFromMicrosoftSource": "MS Go Tools"
},
"helpMarkDown": "ms-resource:loc.input.help.goSource"
}
],
"execution": {
Expand Down

0 comments on commit 3cac0cb

Please sign in to comment.