Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Jan 27, 2024
1 parent 33069bd commit 99f6669
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions example/.fluentci/src/dagger/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ export const getDirectory = async (
return src instanceof Directory ? src : client.host().directory(src);
};

export const getSpinAuthToken = (client: Client, token?: string | Secret) => {
export const getSpinAuthToken = async (
client: Client,
token?: string | Secret
) => {
if (Deno.env.get("SPIN_AUTH_TOKEN")) {
return client.setSecret(
"SPIN_AUTH_TOKEN",
Deno.env.get("SPIN_AUTH_TOKEN")!
);
}
if (token && typeof token === "string") {
if (token.startsWith("core.Secret")) {
return client.loadSecretFromID(token as SecretID);
try {
const secret = client.loadSecretFromID(token as SecretID);
await secret.id();
return secret;
} catch (_) {
return client.setSecret("SPIN_AUTH_TOKEN", token);
}
return client.setSecret("SPIN_AUTH_TOKEN", token);
}
if (token && token instanceof Secret) {
return token;
Expand Down

0 comments on commit 99f6669

Please sign in to comment.