From 2f03226563e0a8f81d3487d75514c57dd863d0af Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Fri, 1 Mar 2024 06:11:23 +0000 Subject: [PATCH] use global dag client --- src/dagger/jobs.ts | 4 ++-- src/dagger/lib.ts | 28 ++++++++++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/dagger/jobs.ts b/src/dagger/jobs.ts index 821c518..a8f3a0c 100644 --- a/src/dagger/jobs.ts +++ b/src/dagger/jobs.ts @@ -23,8 +23,8 @@ export async function upload( src: string | Directory, token: string | Secret ): Promise { - const context = await getDirectory(dag, src); - const secret = await getCodecovToken(dag, token); + const context = await getDirectory(src); + const secret = await getCodecovToken(token); if (!secret) { console.error("CODECOV_TOKEN is not set. Skipping code coverage upload."); Deno.exit(1); diff --git a/src/dagger/lib.ts b/src/dagger/lib.ts index 9302a00..05f7c19 100644 --- a/src/dagger/lib.ts +++ b/src/dagger/lib.ts @@ -1,8 +1,7 @@ import { Directory, DirectoryID, Secret, SecretID } from "../../deps.ts"; -import { Client } from "../../sdk/client.gen.ts"; +import { dag } from "../../sdk/client.gen.ts"; export const getDirectory = async ( - client: Client, src: string | Directory | undefined = "." ) => { if (src instanceof Directory) { @@ -10,34 +9,31 @@ export const getDirectory = async ( } if (typeof src === "string") { try { - const directory = client.loadDirectoryFromID(src as DirectoryID); + const directory = dag.loadDirectoryFromID(src as DirectoryID); await directory.id(); return directory; } catch (_) { - return client.host - ? client.host().directory(src) - : client.currentModule().source().directory(src); + return dag.host + ? dag.host().directory(src) + : dag.currentModule().source().directory(src); } } - return client.host - ? client.host().directory(src) - : client.currentModule().source().directory(src); + return dag.host + ? dag.host().directory(src) + : dag.currentModule().source().directory(src); }; -export const getCodecovToken = async ( - client: Client, - token?: string | Secret -) => { +export const getCodecovToken = async (token?: string | Secret) => { if (Deno.env.get("CODECOV_TOKEN")) { - return client.setSecret("CODECOV_TOKEN", Deno.env.get("CODECOV_TOKEN")!); + return dag.setSecret("CODECOV_TOKEN", Deno.env.get("CODECOV_TOKEN")!); } if (token && typeof token === "string") { try { - const secret = client.loadSecretFromID(token as SecretID); + const secret = dag.loadSecretFromID(token as SecretID); await secret.id(); return secret; } catch (_) { - return client.setSecret("CODECOV_TOKEN", token); + return dag.setSecret("CODECOV_TOKEN", token); } } if (token && token instanceof Secret) {