Skip to content

Commit

Permalink
fix: Rename target upsert to resource upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Nov 14, 2024
1 parent 1526207 commit 71598b8
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 98 deletions.
4 changes: 2 additions & 2 deletions apps/event-worker/src/target-scan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
resourceProviderGoogle,
workspace,
} from "@ctrlplane/db/schema";
import { upsertTargets } from "@ctrlplane/job-dispatch";
import { upsertResources } from "@ctrlplane/job-dispatch";
import { logger } from "@ctrlplane/logger";
import { Channel } from "@ctrlplane/validators/events";

Expand Down Expand Up @@ -72,7 +72,7 @@ export const createTargetScanWorker = () =>
`Upserting ${targets.length} targets for provider ${tp.resource_provider.id}`,
);
if (targets.length > 0) {
await upsertTargets(db, targets);
await upsertResources(db, targets);
} else {
logger.info(
`No targets found for provider ${tp.resource_provider.id}, skipping upsert.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
resourceProvider,
workspace,
} from "@ctrlplane/db/schema";
import { upsertTargets } from "@ctrlplane/job-dispatch";
import { upsertResources } from "@ctrlplane/job-dispatch";
import { Permission } from "@ctrlplane/validators/auth";

import { authn, authz } from "~/app/api/v1/auth";
Expand Down Expand Up @@ -77,7 +77,7 @@ export const PATCH = request()
workspaceId: provider.workspaceId,
}));

const targets = await upsertTargets(
const targets = await upsertResources(
db,
targetsToInsert.map((t) => ({
...t,
Expand Down
4 changes: 2 additions & 2 deletions apps/webservice/src/app/api/v1/targets/[targetId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from "zod";

import { eq } from "@ctrlplane/db";
import * as schema from "@ctrlplane/db/schema";
import { upsertTargets } from "@ctrlplane/job-dispatch";
import { upsertResources } from "@ctrlplane/job-dispatch";
import { Permission } from "@ctrlplane/validators/auth";

import { authn, authz } from "../../auth";
Expand Down Expand Up @@ -80,7 +80,7 @@ export const PATCH = request()
if (target == null)
return NextResponse.json({ error: "Target not found" }, { status: 404 });

const t = await upsertTargets(db, [_.merge(target, body)]);
const t = await upsertResources(db, [_.merge(target, body)]);

return NextResponse.json(t[0]);
});
Expand Down
4 changes: 2 additions & 2 deletions apps/webservice/src/app/api/v1/targets/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from "zod";

import { db } from "@ctrlplane/db/client";
import { createResource } from "@ctrlplane/db/schema";
import { upsertTargets } from "@ctrlplane/job-dispatch";
import { upsertResources } from "@ctrlplane/job-dispatch";
import { Permission } from "@ctrlplane/validators/auth";

import { authn, authz } from "../auth";
Expand Down Expand Up @@ -55,7 +55,7 @@ export const POST = request()
{ status: 400 },
);

const targets = await upsertTargets(
const targets = await upsertResources(
db,
ctx.body.targets.map((t) => ({
...t,
Expand Down
2 changes: 1 addition & 1 deletion packages/job-dispatch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from "./policy-checker.js";
export * from "./policy-create.js";
export * from "./release-sequencing.js";
export * from "./gradual-rollout.js";
export * from "./new-target.js";
export * from "./new-resource.js";
export * from "./target.js";
export * from "./lock-checker.js";
export * from "./queue.js";
Expand Down
File renamed without changes.
Loading

0 comments on commit 71598b8

Please sign in to comment.