Skip to content

Commit

Permalink
Change GCP credential file generator to use deterministic uuidv5() in…
Browse files Browse the repository at this point in the history
…stead of uuid4() so the credentials filename is always the same (based on the service connection name.)

Bump version to current sprint.
  • Loading branch information
root committed Feb 28, 2024
1 parent 648beac commit 325ce43
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
}
}

tr.registerMock('uuid/v4', () => '123');
tr.registerMock('uuid/v5', () => '123');
tr.setAnswers(a);

tr.run();
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
}
}

tr.registerMock('uuid/v4', () => '123');
tr.registerMock('uuid/v5', () => '123');
tr.setAnswers(a);

tr.run();
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
}
}

tr.registerMock('uuid/v4', () => '123');
tr.registerMock('uuid/v5', () => '123');
tr.setAnswers(a);

tr.run();
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers> {
}
}

tr.registerMock('uuid/v4', () => '123');
tr.registerMock('uuid/v5', () => '123');
tr.setAnswers(a);

tr.run();
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/TerraformTask/TerraformTaskV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"demands": [],
"version": {
"Major": "4",
"Minor": "228",
"Minor": "236",
"Patch": "0"
},
"instanceNameFormat": "Terraform : $(provider)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/TerraformTask/TerraformTaskV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"demands": [],
"version": {
"Major": "4",
"Minor": "228",
"Minor": "236",
"Patch": "0"
},
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down

0 comments on commit 325ce43

Please sign in to comment.