From 325ce43690feb7b196a51aad9875ffafaf8263ca Mon Sep 17 00:00:00 2001 From: root Date: Thu, 14 Dec 2023 14:39:02 -0600 Subject: [PATCH] Change GCP credential file generator to use deterministic uuidv5() instead of uuid4() so the credentials filename is always the same (based on the service connection name.) Bump version to current sprint. --- .../Tests/InitTests/GCP/GCPInitFailInvalidWorkingDirectory.ts | 2 +- .../Tests/InitTests/GCP/GCPInitSuccessAdditionalArgs.ts | 2 +- .../Tests/InitTests/GCP/GCPInitSuccessEmptyWorkingDir.ts | 2 +- .../Tests/InitTests/GCP/GCPInitSuccessNoAdditionalArgs.ts | 2 +- .../TerraformTaskV4/src/gcp-terraform-command-handler.ts | 4 ++-- Tasks/TerraformTask/TerraformTaskV4/task.json | 2 +- Tasks/TerraformTask/TerraformTaskV4/task.loc.json | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitFailInvalidWorkingDirectory.ts b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitFailInvalidWorkingDirectory.ts index 1ee7e7f..c70fc7b 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitFailInvalidWorkingDirectory.ts +++ b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitFailInvalidWorkingDirectory.ts @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = { } } -tr.registerMock('uuid/v4', () => '123'); +tr.registerMock('uuid/v5', () => '123'); tr.setAnswers(a); tr.run(); \ No newline at end of file diff --git a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessAdditionalArgs.ts b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessAdditionalArgs.ts index c1d6363..981e71b 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessAdditionalArgs.ts +++ b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessAdditionalArgs.ts @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = { } } -tr.registerMock('uuid/v4', () => '123'); +tr.registerMock('uuid/v5', () => '123'); tr.setAnswers(a); tr.run(); \ No newline at end of file diff --git a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessEmptyWorkingDir.ts b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessEmptyWorkingDir.ts index 3963052..30c69d7 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessEmptyWorkingDir.ts +++ b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessEmptyWorkingDir.ts @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = { } } -tr.registerMock('uuid/v4', () => '123'); +tr.registerMock('uuid/v5', () => '123'); tr.setAnswers(a); tr.run(); \ No newline at end of file diff --git a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessNoAdditionalArgs.ts b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessNoAdditionalArgs.ts index 1084b72..6a49018 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessNoAdditionalArgs.ts +++ b/Tasks/TerraformTask/TerraformTaskV4/Tests/InitTests/GCP/GCPInitSuccessNoAdditionalArgs.ts @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = { } } -tr.registerMock('uuid/v4', () => '123'); +tr.registerMock('uuid/v5', () => '123'); tr.setAnswers(a); tr.run(); \ No newline at end of file diff --git a/Tasks/TerraformTask/TerraformTaskV4/src/gcp-terraform-command-handler.ts b/Tasks/TerraformTask/TerraformTaskV4/src/gcp-terraform-command-handler.ts index eb110fd..9e02caf 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/src/gcp-terraform-command-handler.ts +++ b/Tasks/TerraformTask/TerraformTaskV4/src/gcp-terraform-command-handler.ts @@ -3,7 +3,7 @@ import {ToolRunner} from 'azure-pipelines-task-lib/toolrunner'; import {TerraformAuthorizationCommandInitializer} from './terraform-commands'; import {BaseTerraformCommandHandler} from './base-terraform-command-handler'; import path = require('path'); -import * as uuidV4 from 'uuid/v4'; +import * as uuidV5 from 'uuid/v5'; export class TerraformCommandHandlerGCP extends BaseTerraformCommandHandler { constructor() { @@ -13,7 +13,7 @@ export class TerraformCommandHandlerGCP extends BaseTerraformCommandHandler { private getJsonKeyFilePath(serviceName: string) { // Get credentials for json file - const jsonKeyFilePath = path.resolve(`credentials-${uuidV4()}.json`); + const jsonKeyFilePath = path.resolve(`credentials-${uuidV5(serviceName, uuidV5.URL)}.json`); let clientEmail = tasks.getEndpointAuthorizationParameter(serviceName, "Issuer", false); let tokenUri = tasks.getEndpointAuthorizationParameter(serviceName, "Audience", false); diff --git a/Tasks/TerraformTask/TerraformTaskV4/task.json b/Tasks/TerraformTask/TerraformTaskV4/task.json index 919c071..b622dc9 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/task.json +++ b/Tasks/TerraformTask/TerraformTaskV4/task.json @@ -14,7 +14,7 @@ "demands": [], "version": { "Major": "4", - "Minor": "228", + "Minor": "236", "Patch": "0" }, "instanceNameFormat": "Terraform : $(provider)", diff --git a/Tasks/TerraformTask/TerraformTaskV4/task.loc.json b/Tasks/TerraformTask/TerraformTaskV4/task.loc.json index 4bd74ce..e344f65 100644 --- a/Tasks/TerraformTask/TerraformTaskV4/task.loc.json +++ b/Tasks/TerraformTask/TerraformTaskV4/task.loc.json @@ -13,7 +13,7 @@ "demands": [], "version": { "Major": "4", - "Minor": "228", + "Minor": "236", "Patch": "0" }, "instanceNameFormat": "ms-resource:loc.instanceNameFormat",