mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 04:15:30 +00:00
feedback
This commit is contained in:
parent
83164f4cfe
commit
3bd6b6e1de
1 changed files with 13 additions and 9 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Token } from "@sourcebot/schemas/v3/shared.type";
|
||||
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
|
||||
import { Token } from "@sourcebot/schemas/v3/shared.type";
|
||||
|
||||
export const getTokenFromConfig = async (token: Token): Promise<string> => {
|
||||
if ('env' in token) {
|
||||
|
|
@ -10,6 +10,7 @@ export const getTokenFromConfig = async (token: Token): Promise<string> => {
|
|||
|
||||
return envToken;
|
||||
} else if ('googleCloudSecret' in token) {
|
||||
try {
|
||||
const client = new SecretManagerServiceClient();
|
||||
const [response] = await client.accessSecretVersion({
|
||||
name: token.googleCloudSecret,
|
||||
|
|
@ -20,6 +21,9 @@ export const getTokenFromConfig = async (token: Token): Promise<string> => {
|
|||
}
|
||||
|
||||
return response.payload.data.toString();
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to access Google Cloud secret ${token.googleCloudSecret}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
} else {
|
||||
throw new Error('Invalid token configuration');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue