🔄 Refactor getSecretValue logic and update dependency versions in scripts

This commit is contained in:
2026-04-06 10:35:25 +08:00
parent 2df31a718e
commit 539b0a927f
3 changed files with 23 additions and 6 deletions

View File

@@ -1434,17 +1434,34 @@ export async function getSecretValueViaHatterCli(key: string): Promise<string> {
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<string> {
if (!runEnv) {
runEnv = getRunEnv();
}
const options = toGetSecretValueOptions(runEnvOrOptions);
const runEnv = options?.runEnv ?? getRunEnv();
if (runEnv == "ALIBABA_CLOUD") {
return await getSecretValueViaAlibabaCloudInstanceIdentity(key);
}