Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
fix example
  • Loading branch information
tsirysndr committed Dec 3, 2023
1 parent 65fc254 commit 2bedaf8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 128 deletions.
2 changes: 0 additions & 2 deletions example/.fluentci/mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from "./src/dagger/index.ts";
export * as queries from "./src/dagger/queries.ts";
export { schema } from "./src/dagger/schema.ts";
57 changes: 29 additions & 28 deletions example/.fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Client, { Directory } from "../../deps.ts";
import Client, { Directory, File } from "../../deps.ts";
import { connect } from "../../sdk/connect.ts";
import { getDirectory } from "./lib.ts";

Expand All @@ -19,14 +19,15 @@ export const exclude = [".fluentci"];
* @param {number} exitCode
* @param {string} format
* @param {string} output
* @returns {Promise<string>}
* @returns {Promise<File | string>}
*/
export async function config(
src: Directory | string,
exitCode?: number,
format?: string,
output?: string
): Promise<string> {
): Promise<File | string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const args = ["config", "."];
Expand All @@ -48,11 +49,10 @@ export async function config(
.withWorkdir("/app")
.withExec(args);

const result = await ctr.stdout();

console.log(result);
await ctr.stdout();
id = await ctr.file(`/app/${output}`).id();
});
return "Done";
return id;
}

/**
Expand All @@ -62,14 +62,15 @@ export async function config(
* @param {number} exitCode
* @param {string} format
* @param {string} output
* @returns {Promise<string>}
* @returns {Promise<File | string>}
*/
export async function fs(
src: Directory | string,
exitCode?: number,
format?: string,
output?: string
): Promise<string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const args = ["fs", "."];
Expand All @@ -91,11 +92,11 @@ export async function fs(
.withWorkdir("/app")
.withExec(args);

const result = await ctr.stdout();
await ctr.stdout();

console.log(result);
id = await ctr.file(`/app/${output}`).id();
});
return "Done";
return id;
}

/**
Expand All @@ -106,7 +107,7 @@ export async function fs(
* @param {string} repoUrl
* @param {string} format
* @param {string} output
* @returns {Promise<string>}
* @returns {Promise<File | string>}
*/
export async function repo(
src: Directory | string,
Expand All @@ -115,6 +116,7 @@ export async function repo(
format?: string,
output?: string
): Promise<string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const args = ["repo", Deno.env.get("TRIVY_REPO_URL") || repoUrl || "."];
Expand All @@ -135,12 +137,11 @@ export async function repo(
.withDirectory("/app", context, { exclude })
.withWorkdir("/app")
.withExec(args);
await ctr.stdout();

const result = await ctr.stdout();

console.log(result);
id = await ctr.file(`/app/${output}`).id();
});
return "Done";
return id;
}

/**
Expand All @@ -151,7 +152,7 @@ export async function repo(
* @param {string} image
* @param {string} format
* @param {string} output
* @returns {Promise<string>}
* @returns {Promise<File | string>}
*/
export async function image(
src: Directory | string,
Expand All @@ -160,6 +161,7 @@ export async function image(
format?: string,
output?: string
): Promise<string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
if (!Deno.env.has("TRIVY_IMAGE") && !image) {
Expand Down Expand Up @@ -187,11 +189,10 @@ export async function image(
.withWorkdir("/app")
.withExec(args);

const result = await ctr.stdout();

console.log(result);
await ctr.stdout();
id = await ctr.file(`/app/${output}`).id();
});
return "Done";
return id;
}

/**
Expand All @@ -202,15 +203,16 @@ export async function image(
* @param {string} path
* @param {string} format
* @param {string} output
* @returns {Promise<string>}
* @returns {Promise<File | string>}
*/
export async function sbom(
src: Directory | string,
exitCode?: number,
path?: string,
format?: string,
output?: string
): Promise<string> {
): Promise<File | string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
if (!Deno.env.has("TRIVY_SBOM_PATH") && !path) {
Expand All @@ -237,11 +239,10 @@ export async function sbom(
.withWorkdir("/app")
.withExec(args);

const result = await ctr.stdout();

console.log(result);
await ctr.stdout();
id = await ctr.file(`/app/${output}`).id();
});
return "Done";
return id;
}

export type JobExec = (
Expand All @@ -250,7 +251,7 @@ export type JobExec = (
path?: string,
format?: string,
output?: string
) => Promise<string>;
) => Promise<File | string>;

export const runnableJobs: Record<Job, JobExec> = {
[Job.config]: config,
Expand Down
31 changes: 0 additions & 31 deletions example/.fluentci/src/dagger/queries.ts

This file was deleted.

67 changes: 0 additions & 67 deletions example/.fluentci/src/dagger/schema.ts

This file was deleted.

0 comments on commit 2bedaf8

Please sign in to comment.