diff --git a/libraries/deno-commons-mod.ts b/libraries/deno-commons-mod.ts index f36bd2c..125053f 100644 --- a/libraries/deno-commons-mod.ts +++ b/libraries/deno-commons-mod.ts @@ -1434,17 +1434,34 @@ export async function getSecretValueViaHatterCli(key: string): Promise { export type SecretValueRunEnv = "ALIBABA_CLOUD" | "HATTER_CLI"; +export interface GetSecretValueOptions { + runEnv?: SecretValueRunEnv; +} + export function getRunEnv(): stirng | null { return getEnv("RUN_ENV"); } +function toGetSecretValueOptions( + runEnvOrOptions?: SecretValueRunEnv | GetSecretValueOptions, +): GetSecretValueOptions | undefined { + if (!runEnvOrOptions) { + return runEnvOrOptions as GetSecretValueOptions; + } + if (runEnvOrOptions == "ALIBABA_CLOUD" || runEnvOrOptions == "HATTER_CLI") { + return { + runEnv: runEnvOrOptions as SecretValueRunEnv, + } as GetSecretValueOptions; + } + return runEnvOrOptions as GetSecretValueOptions; +} + export async function getSecretValue( key: string, - runEnv?: SecretValueRunEnv, + runEnvOrOptions?: SecretValueRunEnv | GetSecretValueOptions, ): Promise { - if (!runEnv) { - runEnv = getRunEnv(); - } + const options = toGetSecretValueOptions(runEnvOrOptions); + const runEnv = options?.runEnv ?? getRunEnv(); if (runEnv == "ALIBABA_CLOUD") { return await getSecretValueViaAlibabaCloudInstanceIdentity(key); } diff --git a/single-scripts/get-rfc.ts b/single-scripts/get-rfc.ts index b9b3842..a12ae4e 100755 --- a/single-scripts/get-rfc.ts +++ b/single-scripts/get-rfc.ts @@ -6,7 +6,7 @@ import { exit, fetchFileWithCache, readFileToString, -} from "https://global.hatter.ink/script/get/@62/deno-commons-mod.ts"; +} from "https://global.hatter.ink/script/get/@63/deno-commons-mod.ts"; const flags = parseArgs(args(), { boolean: ["help"], diff --git a/single-scripts/get-secret.ts b/single-scripts/get-secret.ts index 7334440..f3e98a6 100755 --- a/single-scripts/get-secret.ts +++ b/single-scripts/get-secret.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run -A -import {args, exit, getSecretValue,} from "https://script.hatter.ink/@61/deno-commons-mod.ts"; +import {args, exit, getSecretValue,} from "https://script.hatter.ink/@62/deno-commons-mod.ts"; import {parseArgs} from "jsr:@std/cli/parse-args"; const flags = parseArgs(args(), {