mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-09-19 09:02:41 +01:00
Test E2E resource naming
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
const crypto = require("crypto");
|
||||
|
||||
function generateUniqueName(baseName, options, environment = process.env) {
|
||||
const length = options?.length ?? 1;
|
||||
const timestamp = options?.timestampped === undefined ? true : options.timestampped;
|
||||
const prefixed = options?.prefixed === undefined ? true : options.prefixed;
|
||||
|
||||
const runId = environment.GITHUB_RUN_ID;
|
||||
const runAttempt = environment.GITHUB_RUN_ATTEMPT ?? "1";
|
||||
const runPrefix = runId ? `${runId}_${runAttempt}_` : "";
|
||||
const prefix = prefixed ? `t_${runPrefix}` : "";
|
||||
const suffix = timestamp ? `_${Date.now()}` : "";
|
||||
return `${prefix}${baseName}${crypto.randomBytes(length).toString("hex")}${suffix}`;
|
||||
}
|
||||
|
||||
module.exports = { generateUniqueName };
|
||||
Reference in New Issue
Block a user