Skip to content

Commit

Permalink
make token argument required
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Dec 1, 2023
1 parent de9a5b9 commit 6130313
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
21 changes: 12 additions & 9 deletions example/.fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const exclude = ["target", ".git", ".fluentci"];
* @returns {string}
*/
export async function build(
src: string | Directory = "."
src: string | Directory
): Promise<Directory | string> {
let id = "";
await connect(async (client: Client) => {
Expand Down Expand Up @@ -66,10 +66,10 @@ export async function build(
* @returns {string}
*/
export async function deploy(
src: string | Directory | undefined = ".",
src: string | Directory,
authToken: string | Secret,
cachePath = "/app/target",
cacheKey = "spin-target-cache",
authToken?: string | Secret
cacheKey = "spin-target-cache"
): Promise<string> {
const cache = [
{
Expand Down Expand Up @@ -122,11 +122,14 @@ export async function deploy(
return "done";
}

export type JobExec = (
src?: string
) =>
| Promise<Directory | string>
| ((src?: string, cachePath?: string, cacheKey?: string) => Promise<string>);
export type JobExec =
| ((src: string) => Promise<Directory | string>)
| ((
src: string,
token: string | Secret,
cachePath?: string,
cacheKey?: string
) => Promise<string>);

export const runnableJobs: Record<Job, JobExec> = {
[Job.build]: build,
Expand Down
4 changes: 2 additions & 2 deletions example/.fluentci/src/dagger/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function pipeline(src = ".", args: string[] = []) {
return;
}
await build(src);
await deploy(src);
await deploy(src, Deno.env.get("SPIN_AUTH_TOKEN")!);
}

async function runSpecificJobs(args: jobs.Job[]) {
Expand All @@ -21,6 +21,6 @@ async function runSpecificJobs(args: jobs.Job[]) {
if (!job) {
throw new Error(`Job ${name} not found`);
}
await job();
await job(".", Deno.env.get("SPIN_AUTH_TOKEN")!);
}
}
21 changes: 12 additions & 9 deletions src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const exclude = ["target", ".git", ".fluentci"];
* @returns {string}
*/
export async function build(
src: string | Directory = "."
src: string | Directory
): Promise<Directory | string> {
let id = "";
await connect(async (client: Client) => {
Expand Down Expand Up @@ -66,10 +66,10 @@ export async function build(
* @returns {string}
*/
export async function deploy(
src: string | Directory | undefined = ".",
src: string | Directory,
authToken: string | Secret,
cachePath = "/app/target",
cacheKey = "spin-target-cache",
authToken?: string | Secret
cacheKey = "spin-target-cache"
): Promise<string> {
const cache = [
{
Expand Down Expand Up @@ -122,11 +122,14 @@ export async function deploy(
return "done";
}

export type JobExec = (
src?: string
) =>
| Promise<Directory | string>
| ((src?: string, cachePath?: string, cacheKey?: string) => Promise<string>);
export type JobExec =
| ((src: string) => Promise<Directory | string>)
| ((
src: string,
token: string | Secret,
cachePath?: string,
cacheKey?: string
) => Promise<string>);

export const runnableJobs: Record<Job, JobExec> = {
[Job.build]: build,
Expand Down
4 changes: 2 additions & 2 deletions src/dagger/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function pipeline(src = ".", args: string[] = []) {
return;
}
await build(src);
await deploy(src);
await deploy(src, Deno.env.get("SPIN_AUTH_TOKEN")!);
}

async function runSpecificJobs(args: jobs.Job[]) {
Expand All @@ -21,6 +21,6 @@ async function runSpecificJobs(args: jobs.Job[]) {
if (!job) {
throw new Error(`Job ${name} not found`);
}
await job();
await job(".", Deno.env.get("SPIN_AUTH_TOKEN")!);
}
}

0 comments on commit 6130313

Please sign in to comment.