Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target Metadata for get-job-inputs #88

Merged
merged 8 commits into from
Oct 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
target-metadata
zacharyblasczyk committed Sep 30, 2024
commit ae8abffe65ecedf5f5105a25c491d563f22f9395
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { notFound, redirect } from "next/navigation";
import { SiGithub } from "@icons-pack/react-simple-icons";

import { auth } from "@ctrlplane/auth";
import { logger } from "@ctrlplane/logger";
import { Button } from "@ctrlplane/ui/button";
import { Card } from "@ctrlplane/ui/card";

@@ -43,6 +44,13 @@ export default async function GitHubIntegrationPage({
const githubUser = await api.github.user.byUserId(session.user.id);

const configFiles = await api.github.configFile.list(workspace.id);
logger.info("Github configured", {
githubUrl,
githubBotName,
githubBotClientId,
githubUser,
configFiles,
});

return (
<div className="flex flex-col gap-12">
12 changes: 11 additions & 1 deletion apps/webservice/src/app/api/v1/jobs/[jobId]/route.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import {
runbook,
runbookJobTrigger,
target,
targetMetadata,
updateJob,
} from "@ctrlplane/db/schema";
import { onJobCompletion } from "@ctrlplane/job-dispatch";
@@ -58,7 +59,16 @@ export const GET = async (
jobVariableRows.map((v) => [v.key, v.value]),
);

return NextResponse.json({ ...je.job, ...je, variables });
const jobTargetMetadataRows = await db
.select()
.from(targetMetadata)
.where(eq(targetMetadata.targetId, je.target?.id ?? ""));

const metadata = Object.fromEntries(
jobTargetMetadataRows.map((m) => [m.key, m.value]),
);

return NextResponse.json({ ...je.job, ...je, variables, metadata });
};

const bodySchema = updateJob;
8 changes: 6 additions & 2 deletions github/get-job-inputs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/get-job-inputs/src/index.ts
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ async function run() {
setOutputAndLog("target_version", target?.version);
setOutputAndLog("target_identifier", target?.identifier);
setOutputsRecursively("target_config", target?.config);
setOutputsRecursively("target_metadata", target?.metadata);

setOutputAndLog("workspace_id", target?.workspaceId);

13 changes: 12 additions & 1 deletion packages/node-sdk/openapi.yaml
Original file line number Diff line number Diff line change
@@ -337,8 +337,19 @@ paths:
type: string
config:
type: object
metadata:
type: object
required:
[id, name, version, kind, identifier, workspaceId, config]
[
id,
name,
version,
kind,
identifier,
workspaceId,
config,
metadata,
]

environment:
type: object
9 changes: 9 additions & 0 deletions packages/node-sdk/src/models/GetJob200ResponseTarget.ts
Original file line number Diff line number Diff line change
@@ -62,6 +62,12 @@ export interface GetJob200ResponseTarget {
* @memberof GetJob200ResponseTarget
*/
config: object;
/**
*
* @type {object}
* @memberof GetJob200ResponseTarget
*/
metadata: object;
}

/**
@@ -79,6 +85,7 @@ export function instanceOfGetJob200ResponseTarget(
if (!("workspaceId" in value) || value["workspaceId"] === undefined)
return false;
if (!("config" in value) || value["config"] === undefined) return false;
if (!("metadata" in value) || value["metadata"] === undefined) return false;
return true;
}

@@ -103,6 +110,7 @@ export function GetJob200ResponseTargetFromJSONTyped(
identifier: json["identifier"],
workspaceId: json["workspaceId"],
config: json["config"],
metadata: json["metadata"],
};
}

@@ -120,5 +128,6 @@ export function GetJob200ResponseTargetToJSON(
identifier: value["identifier"],
workspaceId: value["workspaceId"],
config: value["config"],
metadata: value["metadata"],
};
}