diff --git a/Tasks/GoToolV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/GoToolV0/Strings/resources.resjson/en-US/resources.resjson index fd68c6787e76..634ea9b5e49d 100644 --- a/Tasks/GoToolV0/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/GoToolV0/Strings/resources.resjson/en-US/resources.resjson @@ -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." } \ No newline at end of file diff --git a/Tasks/GoToolV0/gotool.ts b/Tasks/GoToolV0/gotool.ts index a56ff1c7b61d..36819d97f277 100644 --- a/Tasks/GoToolV0/gotool.ts +++ b/Tasks/GoToolV0/gotool.ts @@ -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); } @@ -70,12 +40,12 @@ async function getGo(source: string, version: string) { } -async function acquireGo(source:string, version: string, toolName: string): Promise { +async function acquireGo(version: string): Promise { // // 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); @@ -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) { diff --git a/Tasks/GoToolV0/package-lock.json b/Tasks/GoToolV0/package-lock.json index 1d026de51fc2..ab8fe04e0bdc 100644 --- a/Tasks/GoToolV0/package-lock.json +++ b/Tasks/GoToolV0/package-lock.json @@ -431,9 +431,9 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==" + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" }, "semver-compare": { "version": "1.0.0", diff --git a/Tasks/GoToolV0/task.json b/Tasks/GoToolV0/task.json index b4d9028b0bae..d5a701f99b70 100644 --- a/Tasks/GoToolV0/task.json +++ b/Tasks/GoToolV0/task.json @@ -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." - } } \ No newline at end of file diff --git a/Tasks/GoToolV0/task.loc.json b/Tasks/GoToolV0/task.loc.json index 7fd314f91537..ac87fecaa248 100644 --- a/Tasks/GoToolV0/task.loc.json +++ b/Tasks/GoToolV0/task.loc.json @@ -14,7 +14,7 @@ "version": { "Major": 0, "Minor": 229, - "Patch": 0 + "Patch": 1 }, "satisfies": [ "GO" @@ -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" }, @@ -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": {