Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
fix example

fix example
  • Loading branch information
tsirysndr committed Dec 3, 2023
1 parent 65fc254 commit b459fd1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 134 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ repo(
image(
src: Directory | string,
exitCode?: number,
image?: string,
format?: string,
output?: string
): Promise<string>
Expand Down
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";
63 changes: 32 additions & 31 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> {
): Promise<File | 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,15 +107,16 @@ 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,
exitCode?: number,
repoUrl?: string,
format?: string,
output?: string
): Promise<string> {
): Promise<File | 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,15 +152,16 @@ 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,
exitCode?: number,
image?: 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_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.

6 changes: 3 additions & 3 deletions src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function fs(
exitCode?: number,
format?: string,
output?: string
): Promise<string> {
): Promise<File | string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
Expand Down Expand Up @@ -115,7 +115,7 @@ export async function repo(
repoUrl?: string,
format?: string,
output?: string
): Promise<string> {
): Promise<File | string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
Expand Down Expand Up @@ -160,7 +160,7 @@ export async function image(
image?: string,
format?: string,
output?: string
): Promise<string> {
): Promise<File | string> {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
Expand Down

0 comments on commit b459fd1

Please sign in to comment.