-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncDopplerEnvVars.ts
More file actions
36 lines (32 loc) · 1.28 KB
/
Copy pathsyncDopplerEnvVars.ts
File metadata and controls
36 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { syncEnvVars } from "@trigger.dev/build/extensions/core";
import { fetchSyncableDopplerSecrets, type DopplerSyncSource } from "../doppler/sync";
/**
* Options for {@link syncDopplerEnvVars}.
*
* A proof-of-concept `syncDopplerEnvVars` build extension. It is a thin wrapper
* over the built-in `syncEnvVars` extension that pulls your secrets from Doppler
* at deploy time and syncs them into Trigger.dev. This is the deploy-time way of
* syncing; the `sync-doppler-env-vars` task is the webhook-driven way, and both
* share {@link fetchSyncableDopplerSecrets}.
*/
export type SyncDopplerEnvVarsOptions = DopplerSyncSource & {
/**
* Whether to mark the synced variables as secret in Trigger.dev, so their
* values are redacted in the dashboard and API. Defaults to `true`, since they
* originate from a secrets manager.
*/
markAsSecret?: boolean;
};
export function syncDopplerEnvVars(
options: SyncDopplerEnvVarsOptions = {}
): ReturnType<typeof syncEnvVars> {
const { markAsSecret = true, ...source } = options;
return syncEnvVars(async (ctx) => {
const variables = await fetchSyncableDopplerSecrets(ctx.environment, source);
return Object.entries(variables).map(([name, value]) => ({
name,
value,
isSecret: markAsSecret,
}));
});
}