mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: simplify naming schema
This commit is contained in:
parent
879311c332
commit
32ebd9b3b9
@ -12,6 +12,7 @@ const baseApp: ApplicationNested = {
|
||||
branch: null,
|
||||
buildArgs: null,
|
||||
buildPath: "/",
|
||||
gitlabPathNamespace: "",
|
||||
buildType: "nixpacks",
|
||||
bitbucketBranch: "",
|
||||
bitbucketBuildPath: "",
|
||||
|
@ -53,7 +53,7 @@ export const AddBitbucketProvider = () => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const url = useUrl();
|
||||
const { mutateAsync, error, isError } =
|
||||
api.gitProvider.createBitbucketProvider.useMutation();
|
||||
api.gitProvider.createBitbucket.useMutation();
|
||||
const { data: auth } = api.auth.get.useQuery();
|
||||
const router = useRouter();
|
||||
const form = useForm<Schema>({
|
@ -0,0 +1,231 @@
|
||||
import {
|
||||
BitbucketIcon,
|
||||
GithubIcon,
|
||||
GitlabIcon,
|
||||
} from "@/components/icons/data-tools-icons";
|
||||
import { AlertBlock } from "@/components/shared/alert-block";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardContent } from "@/components/ui/card";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { api } from "@/utils/api";
|
||||
import { useUrl } from "@/utils/hooks/use-url";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
import { z } from "zod";
|
||||
|
||||
const Schema = z.object({
|
||||
name: z.string().min(1, {
|
||||
message: "Name is required",
|
||||
}),
|
||||
username: z.string().min(1, {
|
||||
message: "Username is required",
|
||||
}),
|
||||
password: z.string().min(1, {
|
||||
message: "App Password is required",
|
||||
}),
|
||||
workspaceName: z.string().optional(),
|
||||
});
|
||||
|
||||
type Schema = z.infer<typeof Schema>;
|
||||
|
||||
export const AddBitbucketProvider = () => {
|
||||
// const {data} = api.gitProvider.
|
||||
const utils = api.useUtils();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const url = useUrl();
|
||||
const { mutateAsync, error, isError } =
|
||||
api.gitProvider.createBitbucket.useMutation();
|
||||
const { data: auth } = api.auth.get.useQuery();
|
||||
const router = useRouter();
|
||||
const form = useForm<Schema>({
|
||||
defaultValues: {
|
||||
username: "",
|
||||
password: "",
|
||||
workspaceName: "",
|
||||
},
|
||||
resolver: zodResolver(Schema),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
form.reset({
|
||||
username: "",
|
||||
password: "",
|
||||
workspaceName: "",
|
||||
});
|
||||
}, [form, isOpen]);
|
||||
|
||||
const onSubmit = async (data: Schema) => {
|
||||
await mutateAsync({
|
||||
bitbucketUsername: data.username,
|
||||
appPassword: data.password,
|
||||
bitbucketWorkspaceName: data.workspaceName || "",
|
||||
authId: auth?.id || "",
|
||||
name: data.name || "",
|
||||
})
|
||||
.then(async () => {
|
||||
await utils.gitProvider.getAll.invalidate();
|
||||
toast.success("Bitbucket configured successfully");
|
||||
setIsOpen(false);
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error("Error configuring Bitbucket");
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
variant="secondary"
|
||||
className="flex items-center space-x-1 bg-blue-700 text-white hover:bg-blue-600"
|
||||
>
|
||||
<BitbucketIcon />
|
||||
<span>Bitbucket</span>
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-2xl overflow-y-auto max-h-screen">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
Bitbucket Provider <BitbucketIcon className="size-5" />
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
{isError && <AlertBlock type="error">{error?.message}</AlertBlock>}
|
||||
<Form {...form}>
|
||||
<form
|
||||
id="hook-form-add-bitbucket"
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="grid w-full gap-1"
|
||||
>
|
||||
<CardContent className="p-0">
|
||||
<div className="flex flex-col gap-4">
|
||||
<p className="text-muted-foreground text-sm">
|
||||
To integrate your Bitbucket account, you need to create a new
|
||||
App Password in your Bitbucket settings. Follow these steps:
|
||||
</p>
|
||||
<ol className="list-decimal list-inside text-sm text-muted-foreground">
|
||||
<li className="flex flex-row gap-2 items-center">
|
||||
Create new App Password{" "}
|
||||
<Link
|
||||
href="https://bitbucket.org/account/settings/app-passwords/new"
|
||||
target="_blank"
|
||||
>
|
||||
<ExternalLink className="w-fit text-primary size-4" />
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
When creating the App Password, ensure you grant the
|
||||
following permissions:
|
||||
<ul className="list-disc list-inside ml-4">
|
||||
<li>Account: Read</li>
|
||||
<li>Workspace membership: Read</li>
|
||||
<li>Projects: Read</li>
|
||||
<li>Repositories: Read</li>
|
||||
<li>Pull requests: Read</li>
|
||||
<li>Webhooks: Read and write</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
After creating, you'll receive an App Password. Copy it and
|
||||
paste it below along with your Bitbucket username.
|
||||
</li>
|
||||
</ol>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Name</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="Random Name eg(my-personal-account)"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="username"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Bitbucket Username</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="Your Bitbucket username"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="password"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>App Password</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="password"
|
||||
placeholder="ATBBPDYUC94nR96Nj7Cqpp4pfwKk03573DD2"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="workspaceName"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Workspace Name (Optional)</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="For organization accounts"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button isLoading={form.formState.isSubmitting}>
|
||||
Configure Bitbucket
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
@ -54,7 +54,7 @@ export const AddGitlabProvider = () => {
|
||||
const url = useUrl();
|
||||
const { data: auth } = api.auth.get.useQuery();
|
||||
const { mutateAsync, error, isError } =
|
||||
api.gitProvider.createGitlabProvider.useMutation();
|
||||
api.gitProvider.createGitlab.useMutation();
|
||||
const webhookUrl = `${url}/api/providers/gitlab/callback`;
|
||||
|
||||
const form = useForm<Schema>({
|
@ -1,13 +1,13 @@
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { AddGitlabProvider } from "./add-gitlab-provider";
|
||||
import { AddGitlabProvider } from "./gitlab/add-gitlab-provider";
|
||||
import {
|
||||
BitbucketIcon,
|
||||
GithubIcon,
|
||||
GitlabIcon,
|
||||
} from "@/components/icons/data-tools-icons";
|
||||
import { AddGithubProvider } from "./add-github-provider";
|
||||
import { AddBitbucketProvider } from "./add-bitbucket-provider";
|
||||
import { AddGithubProvider } from "./github/add-github-provider";
|
||||
import { AddBitbucketProvider } from "./bitbucket/add-bitbucket-provider";
|
||||
import { api } from "@/utils/api";
|
||||
import Link from "next/link";
|
||||
import { RemoveGitProvider } from "./remove-git-provider";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { findAdmin } from "@/server/api/services/admin";
|
||||
import { db } from "@/server/db";
|
||||
import { applications, compose, githubProvider } from "@/server/db/schema";
|
||||
import { applications, compose } from "@/server/db/schema";
|
||||
import type { DeploymentJob } from "@/server/queues/deployments-queue";
|
||||
import { myQueue } from "@/server/queues/queueSetup";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
@ -22,13 +22,13 @@ export default async function handler(
|
||||
const signature = req.headers["x-hub-signature-256"];
|
||||
const github = req.body;
|
||||
|
||||
if(!github?.installation.id) {
|
||||
if (!github?.installation.id) {
|
||||
res.status(400).json({ message: "Github Installation not found" });
|
||||
return;
|
||||
}
|
||||
|
||||
const githubResult = await db.query.githubProvider.findFirst({
|
||||
where: eq(githubProvider.githubInstallationId, github.installation.id),
|
||||
const githubResult = await db.query.github.findFirst({
|
||||
where: eq(github.githubInstallationId, github.installation.id),
|
||||
});
|
||||
|
||||
if (!githubResult) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createGithubProvider } from "@/server/api/services/git-provider";
|
||||
import { createGithub } from "@/server/api/services/git-provider";
|
||||
import { db } from "@/server/db";
|
||||
import { githubProvider } from "@/server/db/schema";
|
||||
import { github } from "@/server/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { Octokit } from "octokit";
|
||||
@ -34,7 +34,7 @@ export default async function handler(
|
||||
},
|
||||
);
|
||||
|
||||
await createGithubProvider({
|
||||
await createGithub({
|
||||
name: data.name,
|
||||
githubAppName: data.html_url,
|
||||
githubAppId: data.id,
|
||||
@ -46,11 +46,11 @@ export default async function handler(
|
||||
});
|
||||
} else if (action === "gh_setup") {
|
||||
await db
|
||||
.update(githubProvider)
|
||||
.update(github)
|
||||
.set({
|
||||
githubInstallationId: installation_id,
|
||||
})
|
||||
.where(eq(githubProvider.githubId, value as string))
|
||||
.where(eq(github.githubId, value as string))
|
||||
.returning();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {
|
||||
getGitlabProvider,
|
||||
updateGitlabProvider,
|
||||
findGitlabById,
|
||||
updateGitlab,
|
||||
} from "@/server/api/services/git-provider";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
@ -14,7 +14,7 @@ export default async function handler(
|
||||
return res.status(400).json({ error: "Missing or invalid code" });
|
||||
}
|
||||
|
||||
const gitlab = await getGitlabProvider(gitlabId as string);
|
||||
const gitlab = await findGitlabById(gitlabId as string);
|
||||
|
||||
const response = await fetch("https://gitlab.com/oauth/token", {
|
||||
method: "POST",
|
||||
@ -37,7 +37,7 @@ export default async function handler(
|
||||
}
|
||||
|
||||
const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
|
||||
await updateGitlabProvider(gitlab.gitlabId, {
|
||||
await updateGitlab(gitlab.gitlabId, {
|
||||
accessToken: result.access_token,
|
||||
refreshToken: result.refresh_token,
|
||||
expiresAt,
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { createTRPCRouter, protectedProcedure } from "@/server/api/trpc";
|
||||
import { db } from "@/server/db";
|
||||
import {
|
||||
apiCreateBitbucketProvider,
|
||||
apiCreateGitlabProvider,
|
||||
apiCreateBitbucket,
|
||||
apiCreateGitlab,
|
||||
apiGetBranches,
|
||||
} from "@/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import {
|
||||
createBitbucketProvider,
|
||||
createGitlabProvider,
|
||||
createBitbucket,
|
||||
createGitlab,
|
||||
haveGithubRequirements,
|
||||
removeGithubProvider,
|
||||
removeGithub,
|
||||
} from "../services/git-provider";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
@ -41,7 +41,7 @@ export const gitProvider = createTRPCRouter({
|
||||
.input(z.object({ gitProviderId: z.string() }))
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
return await removeGithubProvider(input.gitProviderId);
|
||||
return await removeGithub(input.gitProviderId);
|
||||
} catch (error) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
@ -49,11 +49,11 @@ export const gitProvider = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
}),
|
||||
createGitlabProvider: protectedProcedure
|
||||
.input(apiCreateGitlabProvider)
|
||||
createGitlab: protectedProcedure
|
||||
.input(apiCreateGitlab)
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
return await createGitlabProvider(input);
|
||||
return await createGitlab(input);
|
||||
} catch (error) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
@ -62,11 +62,11 @@ export const gitProvider = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
}),
|
||||
createBitbucketProvider: protectedProcedure
|
||||
.input(apiCreateBitbucketProvider)
|
||||
createBitbucket: protectedProcedure
|
||||
.input(apiCreateBitbucket)
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
return await createBitbucketProvider(input);
|
||||
return await createBitbucket(input);
|
||||
} catch (error) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
@ -76,7 +76,7 @@ export const gitProvider = createTRPCRouter({
|
||||
}
|
||||
}),
|
||||
githubProviders: protectedProcedure.query(async () => {
|
||||
const result = await db.query.githubProvider.findMany({
|
||||
const result = await db.query.github.findMany({
|
||||
with: {
|
||||
gitProvider: true,
|
||||
},
|
||||
@ -96,7 +96,7 @@ export const gitProvider = createTRPCRouter({
|
||||
return filtered;
|
||||
}),
|
||||
gitlabProviders: protectedProcedure.query(async () => {
|
||||
const result = await db.query.gitlabProvider.findMany({
|
||||
const result = await db.query.gitlab.findMany({
|
||||
with: {
|
||||
gitProvider: true,
|
||||
},
|
||||
@ -115,7 +115,7 @@ export const gitProvider = createTRPCRouter({
|
||||
return filtered;
|
||||
}),
|
||||
bitbucketProviders: protectedProcedure.query(async () => {
|
||||
const result = await db.query.bitbucketProvider.findMany({
|
||||
const result = await db.query.bitbucket.findMany({
|
||||
with: {
|
||||
gitProvider: true,
|
||||
},
|
||||
@ -182,21 +182,9 @@ export const gitProvider = createTRPCRouter({
|
||||
.query(async ({ input }) => {
|
||||
return await getGithubBranches(input);
|
||||
}),
|
||||
// getGithub: protectedProcedure
|
||||
// .input(apiGetGithub)
|
||||
// .query(async ({ input }) => {
|
||||
// return await findGithub(input);
|
||||
// }),
|
||||
});
|
||||
// 1725175543
|
||||
// {
|
||||
// access_token: '11d422887d8fac712191ee9b09dfdb043a705938cd67a4a39f36b4bc65b3106d',
|
||||
// token_type: 'Bearer',
|
||||
// expires_in: 7200,
|
||||
// refresh_token: '3806d8022d32886c19d91eb9d1cea9328b864387f39c5d0469d08c48e18b674e',
|
||||
// scope: 'api read_user read_repository',
|
||||
// created_at: 1725167656
|
||||
// }
|
||||
// {
|
||||
// access_token: 'd256b52b10bf72ebf2784f8c0528e48a04a7d249c28695b6cc105b47b09c7336',
|
||||
// token_type: 'Bearer',
|
||||
// expires_in: 7200,
|
||||
// refresh_token: '265eb87d0bbef410e0c30a2c239c4fa3698943219a439fb43cf2f8227d1fcaf2',
|
||||
// scope: 'api read_user read_repository',
|
||||
// created_at: 1725167803
|
||||
// }
|
||||
|
@ -83,9 +83,9 @@ export const findApplicationById = async (applicationId: string) => {
|
||||
security: true,
|
||||
ports: true,
|
||||
registry: true,
|
||||
gitlabProvider: true,
|
||||
githubProvider: true,
|
||||
bitbucketProvider: true,
|
||||
gitlab: true,
|
||||
github: true,
|
||||
bitbucket: true,
|
||||
},
|
||||
});
|
||||
if (!application) {
|
||||
|
@ -93,9 +93,9 @@ export const findComposeById = async (composeId: string) => {
|
||||
deployments: true,
|
||||
mounts: true,
|
||||
domains: true,
|
||||
githubProvider: true,
|
||||
gitlabProvider: true,
|
||||
bitbucketProvider: true,
|
||||
github: true,
|
||||
gitlab: true,
|
||||
bitbucket: true,
|
||||
},
|
||||
});
|
||||
if (!result) {
|
||||
|
@ -1,22 +1,20 @@
|
||||
import { db } from "@/server/db";
|
||||
import {
|
||||
type apiCreateBitbucketProvider,
|
||||
type apiCreateGithubProvider,
|
||||
type apiCreateGitlabProvider,
|
||||
bitbucketProvider,
|
||||
githubProvider,
|
||||
gitlabProvider,
|
||||
type apiCreateBitbucket,
|
||||
type apiCreateGithub,
|
||||
type apiCreateGitlab,
|
||||
bitbucket,
|
||||
github,
|
||||
gitlab,
|
||||
gitProvider,
|
||||
} from "@/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
export type GithubProvider = typeof githubProvider.$inferSelect;
|
||||
export type Github = typeof github.$inferSelect;
|
||||
|
||||
export type GitlabProvider = typeof gitlabProvider.$inferSelect;
|
||||
export const createGithubProvider = async (
|
||||
input: typeof apiCreateGithubProvider._type,
|
||||
) => {
|
||||
export type Gitlab = typeof gitlab.$inferSelect;
|
||||
export const createGithub = async (input: typeof apiCreateGithub._type) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
const newGitProvider = await tx
|
||||
.insert(gitProvider)
|
||||
@ -36,7 +34,7 @@ export const createGithubProvider = async (
|
||||
}
|
||||
|
||||
return await tx
|
||||
.insert(githubProvider)
|
||||
.insert(github)
|
||||
.values({
|
||||
...input,
|
||||
gitProviderId: newGitProvider?.gitProviderId,
|
||||
@ -46,9 +44,7 @@ export const createGithubProvider = async (
|
||||
});
|
||||
};
|
||||
|
||||
export const createGitlabProvider = async (
|
||||
input: typeof apiCreateGitlabProvider._type,
|
||||
) => {
|
||||
export const createGitlab = async (input: typeof apiCreateGitlab._type) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
const newGitProvider = await tx
|
||||
.insert(gitProvider)
|
||||
@ -68,7 +64,7 @@ export const createGitlabProvider = async (
|
||||
}
|
||||
|
||||
await tx
|
||||
.insert(gitlabProvider)
|
||||
.insert(gitlab)
|
||||
.values({
|
||||
...input,
|
||||
gitProviderId: newGitProvider?.gitProviderId,
|
||||
@ -78,8 +74,8 @@ export const createGitlabProvider = async (
|
||||
});
|
||||
};
|
||||
|
||||
export const createBitbucketProvider = async (
|
||||
input: typeof apiCreateBitbucketProvider._type,
|
||||
export const createBitbucket = async (
|
||||
input: typeof apiCreateBitbucket._type,
|
||||
) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
const newGitProvider = await tx
|
||||
@ -100,7 +96,7 @@ export const createBitbucketProvider = async (
|
||||
}
|
||||
|
||||
await tx
|
||||
.insert(bitbucketProvider)
|
||||
.insert(bitbucket)
|
||||
.values({
|
||||
...input,
|
||||
gitProviderId: newGitProvider?.gitProviderId,
|
||||
@ -110,7 +106,7 @@ export const createBitbucketProvider = async (
|
||||
});
|
||||
};
|
||||
|
||||
export const removeGithubProvider = async (gitProviderId: string) => {
|
||||
export const removeGithub = async (gitProviderId: string) => {
|
||||
const result = await db
|
||||
.delete(gitProvider)
|
||||
.where(eq(gitProvider.gitProviderId, gitProviderId))
|
||||
@ -119,9 +115,9 @@ export const removeGithubProvider = async (gitProviderId: string) => {
|
||||
return result[0];
|
||||
};
|
||||
|
||||
export const getGithubProvider = async (githubId: string) => {
|
||||
const githubProviderResult = await db.query.githubProvider.findFirst({
|
||||
where: eq(githubProvider.githubId, githubId),
|
||||
export const findGithubById = async (githubId: string) => {
|
||||
const githubProviderResult = await db.query.github.findFirst({
|
||||
where: eq(github.githubId, githubId),
|
||||
});
|
||||
|
||||
if (!githubProviderResult) {
|
||||
@ -134,17 +130,17 @@ export const getGithubProvider = async (githubId: string) => {
|
||||
return githubProviderResult;
|
||||
};
|
||||
|
||||
export const haveGithubRequirements = (githubProvider: GithubProvider) => {
|
||||
export const haveGithubRequirements = (github: Github) => {
|
||||
return !!(
|
||||
githubProvider?.githubAppId &&
|
||||
githubProvider?.githubPrivateKey &&
|
||||
githubProvider?.githubInstallationId
|
||||
github?.githubAppId &&
|
||||
github?.githubPrivateKey &&
|
||||
github?.githubInstallationId
|
||||
);
|
||||
};
|
||||
|
||||
export const getGitlabProvider = async (gitlabId: string) => {
|
||||
const gitlabProviderResult = await db.query.gitlabProvider.findFirst({
|
||||
where: eq(gitlabProvider.gitlabId, gitlabId),
|
||||
export const findGitlabById = async (gitlabId: string) => {
|
||||
const gitlabProviderResult = await db.query.gitlab.findFirst({
|
||||
where: eq(gitlab.gitlabId, gitlabId),
|
||||
});
|
||||
|
||||
if (!gitlabProviderResult) {
|
||||
@ -157,24 +153,24 @@ export const getGitlabProvider = async (gitlabId: string) => {
|
||||
return gitlabProviderResult;
|
||||
};
|
||||
|
||||
export const updateGitlabProvider = async (
|
||||
export const updateGitlab = async (
|
||||
gitlabId: string,
|
||||
input: Partial<GitlabProvider>,
|
||||
input: Partial<Gitlab>,
|
||||
) => {
|
||||
const result = await db
|
||||
.update(gitlabProvider)
|
||||
.update(gitlab)
|
||||
.set({
|
||||
...input,
|
||||
})
|
||||
.where(eq(gitlabProvider.gitlabId, gitlabId))
|
||||
.where(eq(gitlab.gitlabId, gitlabId))
|
||||
.returning();
|
||||
|
||||
return result[0];
|
||||
};
|
||||
|
||||
export const getBitbucketProvider = async (bitbucketId: string) => {
|
||||
const bitbucketProviderResult = await db.query.bitbucketProvider.findFirst({
|
||||
where: eq(bitbucketProvider.bitbucketId, bitbucketId),
|
||||
export const findBitbucketById = async (bitbucketId: string) => {
|
||||
const bitbucketProviderResult = await db.query.bitbucket.findFirst({
|
||||
where: eq(bitbucket.bitbucketId, bitbucketId),
|
||||
});
|
||||
|
||||
if (!bitbucketProviderResult) {
|
||||
|
@ -21,11 +21,7 @@ import { security } from "./security";
|
||||
import { applicationStatus } from "./shared";
|
||||
import { sshKeys } from "./ssh-key";
|
||||
import { generateAppName } from "./utils";
|
||||
import {
|
||||
bitbucketProvider,
|
||||
githubProvider,
|
||||
gitlabProvider,
|
||||
} from "./git-provider";
|
||||
import { bitbucket, github, gitlab } from "./git-provider";
|
||||
|
||||
export const sourceType = pgEnum("sourceType", [
|
||||
"docker",
|
||||
@ -187,18 +183,15 @@ export const applications = pgTable("application", {
|
||||
projectId: text("projectId")
|
||||
.notNull()
|
||||
.references(() => projects.projectId, { onDelete: "cascade" }),
|
||||
githubId: text("githubId").references(() => githubProvider.githubId, {
|
||||
githubId: text("githubId").references(() => github.githubId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
gitlabId: text("gitlabId").references(() => gitlabProvider.gitlabId, {
|
||||
gitlabId: text("gitlabId").references(() => gitlab.gitlabId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(() => bitbucket.bitbucketId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(
|
||||
() => bitbucketProvider.bitbucketId,
|
||||
{
|
||||
onDelete: "set null",
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
export const applicationsRelations = relations(
|
||||
@ -222,17 +215,17 @@ export const applicationsRelations = relations(
|
||||
fields: [applications.registryId],
|
||||
references: [registry.registryId],
|
||||
}),
|
||||
githubProvider: one(githubProvider, {
|
||||
github: one(github, {
|
||||
fields: [applications.githubId],
|
||||
references: [githubProvider.githubId],
|
||||
references: [github.githubId],
|
||||
}),
|
||||
gitlabProvider: one(gitlabProvider, {
|
||||
gitlab: one(gitlab, {
|
||||
fields: [applications.gitlabId],
|
||||
references: [gitlabProvider.gitlabId],
|
||||
references: [gitlab.gitlabId],
|
||||
}),
|
||||
bitbucketProvider: one(bitbucketProvider, {
|
||||
bitbucket: one(bitbucket, {
|
||||
fields: [applications.bitbucketId],
|
||||
references: [bitbucketProvider.bitbucketId],
|
||||
references: [bitbucket.bitbucketId],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
@ -10,11 +10,7 @@ import { mounts } from "./mount";
|
||||
import { projects } from "./project";
|
||||
import { applicationStatus } from "./shared";
|
||||
import { generateAppName } from "./utils";
|
||||
import {
|
||||
bitbucketProvider,
|
||||
githubProvider,
|
||||
gitlabProvider,
|
||||
} from "./git-provider";
|
||||
import { bitbucket, github, gitlab } from "./git-provider";
|
||||
|
||||
export const sourceTypeCompose = pgEnum("sourceTypeCompose", [
|
||||
"git",
|
||||
@ -76,18 +72,15 @@ export const compose = pgTable("compose", {
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
|
||||
githubId: text("githubId").references(() => githubProvider.githubId, {
|
||||
githubId: text("githubId").references(() => github.githubId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
gitlabId: text("gitlabId").references(() => gitlabProvider.gitlabId, {
|
||||
gitlabId: text("gitlabId").references(() => gitlab.gitlabId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(() => bitbucket.bitbucketId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(
|
||||
() => bitbucketProvider.bitbucketId,
|
||||
{
|
||||
onDelete: "set null",
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
export const composeRelations = relations(compose, ({ one, many }) => ({
|
||||
@ -102,17 +95,17 @@ export const composeRelations = relations(compose, ({ one, many }) => ({
|
||||
references: [sshKeys.sshKeyId],
|
||||
}),
|
||||
domains: many(domains),
|
||||
githubProvider: one(githubProvider, {
|
||||
github: one(github, {
|
||||
fields: [compose.githubId],
|
||||
references: [githubProvider.githubId],
|
||||
references: [github.githubId],
|
||||
}),
|
||||
gitlabProvider: one(gitlabProvider, {
|
||||
gitlab: one(gitlab, {
|
||||
fields: [compose.gitlabId],
|
||||
references: [gitlabProvider.gitlabId],
|
||||
references: [gitlab.gitlabId],
|
||||
}),
|
||||
bitbucketProvider: one(bitbucketProvider, {
|
||||
bitbucket: one(bitbucket, {
|
||||
fields: [compose.bitbucketId],
|
||||
references: [bitbucketProvider.bitbucketId],
|
||||
references: [bitbucket.bitbucketId],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
@ -27,17 +27,17 @@ export const gitProvider = pgTable("git_provider", {
|
||||
});
|
||||
|
||||
export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||
github: one(githubProvider, {
|
||||
github: one(github, {
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [githubProvider.gitProviderId],
|
||||
references: [github.gitProviderId],
|
||||
}),
|
||||
gitlab: one(gitlabProvider, {
|
||||
gitlab: one(gitlab, {
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [gitlabProvider.gitProviderId],
|
||||
references: [gitlab.gitProviderId],
|
||||
}),
|
||||
bitbucket: one(bitbucketProvider, {
|
||||
bitbucket: one(bitbucket, {
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [bitbucketProvider.gitProviderId],
|
||||
references: [bitbucket.gitProviderId],
|
||||
}),
|
||||
auth: one(auth, {
|
||||
fields: [gitProvider.authId],
|
||||
@ -45,7 +45,7 @@ export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const githubProvider = pgTable("github_provider", {
|
||||
export const github = pgTable("github", {
|
||||
githubId: text("githubId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@ -62,17 +62,14 @@ export const githubProvider = pgTable("github_provider", {
|
||||
.references(() => gitProvider.gitProviderId, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const githubProviderRelations = relations(
|
||||
githubProvider,
|
||||
({ one, }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [githubProvider.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
export const githubProviderRelations = relations(github, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [github.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export const gitlabProvider = pgTable("gitlab_provider", {
|
||||
export const gitlab = pgTable("gitlab", {
|
||||
gitlabId: text("gitlabId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@ -89,17 +86,14 @@ export const gitlabProvider = pgTable("gitlab_provider", {
|
||||
.references(() => gitProvider.gitProviderId, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const gitlabProviderRelations = relations(
|
||||
gitlabProvider,
|
||||
({ one}) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [gitlabProvider.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
export const gitlabProviderRelations = relations(gitlab, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [gitlab.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export const bitbucketProvider = pgTable("bitbucket_provider", {
|
||||
export const bitbucket = pgTable("bitbucket", {
|
||||
bitbucketId: text("bitbucketId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@ -112,19 +106,16 @@ export const bitbucketProvider = pgTable("bitbucket_provider", {
|
||||
.references(() => gitProvider.gitProviderId, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const bitbucketProviderRelations = relations(
|
||||
bitbucketProvider,
|
||||
({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [bitbucketProvider.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
export const bitbucketProviderRelations = relations(bitbucket, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [bitbucket.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
const createSchema = createInsertSchema(gitProvider);
|
||||
|
||||
export const apiCreateGithubProvider = createSchema.extend({
|
||||
export const apiCreateGithub = createSchema.extend({
|
||||
githubAppName: z.string().optional(),
|
||||
githubAppId: z.number().optional(),
|
||||
githubClientId: z.string().optional(),
|
||||
@ -135,7 +126,7 @@ export const apiCreateGithubProvider = createSchema.extend({
|
||||
gitProviderId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const apiCreateGitlabProvider = createSchema.extend({
|
||||
export const apiCreateGitlab = createSchema.extend({
|
||||
applicationId: z.string().optional(),
|
||||
secret: z.string().optional(),
|
||||
groupName: z.string().optional(),
|
||||
@ -143,7 +134,7 @@ export const apiCreateGitlabProvider = createSchema.extend({
|
||||
redirectUri: z.string().optional(),
|
||||
});
|
||||
|
||||
export const apiCreateBitbucketProvider = createSchema.extend({
|
||||
export const apiCreateBitbucket = createSchema.extend({
|
||||
bitbucketUsername: z.string().optional(),
|
||||
appPassword: z.string().optional(),
|
||||
bitbucketWorkspaceName: z.string().optional(),
|
||||
|
@ -5,17 +5,17 @@ import { TRPCError } from "@trpc/server";
|
||||
import { recreateDirectory } from "../filesystem/directory";
|
||||
import { spawnAsync } from "../process/spawnAsync";
|
||||
import type { InferResultType } from "@/server/types/with";
|
||||
import { getBitbucketProvider } from "@/server/api/services/git-provider";
|
||||
import { findBitbucketById } from "@/server/api/services/git-provider";
|
||||
import type { Compose } from "@/server/api/services/compose";
|
||||
|
||||
export type ApplicationWithBitbucket = InferResultType<
|
||||
"applications",
|
||||
{ bitbucketProvider: true }
|
||||
{ bitbucket: true }
|
||||
>;
|
||||
|
||||
export type ComposeWithBitbucket = InferResultType<
|
||||
"compose",
|
||||
{ bitbucketProvider: true }
|
||||
{ bitbucket: true }
|
||||
>;
|
||||
|
||||
export const cloneBitbucketRepository = async (
|
||||
@ -30,7 +30,7 @@ export const cloneBitbucketRepository = async (
|
||||
bitbucketOwner,
|
||||
bitbucketBranch,
|
||||
bitbucketId,
|
||||
bitbucketProvider,
|
||||
bitbucket,
|
||||
} = entity;
|
||||
|
||||
if (!bitbucketId) {
|
||||
@ -44,7 +44,7 @@ export const cloneBitbucketRepository = async (
|
||||
const outputPath = join(basePath, appName, "code");
|
||||
await recreateDirectory(outputPath);
|
||||
const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`;
|
||||
const cloneUrl = `https://${bitbucketProvider?.bitbucketUsername}:${bitbucketProvider?.appPassword}@${repoclone}`;
|
||||
const cloneUrl = `https://${bitbucket?.bitbucketUsername}:${bitbucket?.appPassword}@${repoclone}`;
|
||||
try {
|
||||
writeStream.write(`\nCloning Repo ${repoclone} to ${outputPath}: ✅\n`);
|
||||
await spawnAsync(
|
||||
@ -90,7 +90,7 @@ export const cloneRawBitbucketRepository = async (entity: Compose) => {
|
||||
});
|
||||
}
|
||||
|
||||
const bitbucketProvider = await getBitbucketProvider(bitbucketId);
|
||||
const bitbucketProvider = await findBitbucketById(bitbucketId);
|
||||
const basePath = COMPOSE_PATH;
|
||||
const outputPath = join(basePath, appName, "code");
|
||||
await recreateDirectory(outputPath);
|
||||
@ -123,7 +123,7 @@ export const getBitbucketRepositories = async (
|
||||
if (!input.bitbucketId) {
|
||||
return [];
|
||||
}
|
||||
const bitbucketProvider = await getBitbucketProvider(input.bitbucketId);
|
||||
const bitbucketProvider = await findBitbucketById(input.bitbucketId);
|
||||
|
||||
const username =
|
||||
bitbucketProvider.bitbucketWorkspaceName ||
|
||||
@ -179,7 +179,7 @@ export const getBitbucketBranches = async (input: GetBitbucketBranches) => {
|
||||
if (!input.bitbucketId) {
|
||||
return [];
|
||||
}
|
||||
const bitbucketProvider = await getBitbucketProvider(input.bitbucketId);
|
||||
const bitbucketProvider = await findBitbucketById(input.bitbucketId);
|
||||
const { owner, repo } = input;
|
||||
const url = `https://api.bitbucket.org/2.0/repositories/${owner}/${repo}/refs/branches`;
|
||||
|
||||
|
@ -8,12 +8,12 @@ import { recreateDirectory } from "../filesystem/directory";
|
||||
import { spawnAsync } from "../process/spawnAsync";
|
||||
import type { InferResultType } from "@/server/types/with";
|
||||
import {
|
||||
getGithubProvider,
|
||||
type GithubProvider,
|
||||
findGithubById,
|
||||
type Github,
|
||||
} from "@/server/api/services/git-provider";
|
||||
import type { Compose } from "@/server/api/services/compose";
|
||||
|
||||
export const authGithub = (githubProvider: GithubProvider) => {
|
||||
export const authGithub = (githubProvider: Github) => {
|
||||
if (!haveGithubRequirements(githubProvider)) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
@ -45,7 +45,7 @@ export const getGithubToken = async (
|
||||
return installation.token;
|
||||
};
|
||||
|
||||
export const haveGithubRequirements = (githubProvider: GithubProvider) => {
|
||||
export const haveGithubRequirements = (githubProvider: Github) => {
|
||||
return !!(
|
||||
githubProvider?.githubAppId &&
|
||||
githubProvider?.githubPrivateKey &&
|
||||
@ -70,13 +70,10 @@ const getErrorCloneRequirements = (entity: {
|
||||
|
||||
export type ApplicationWithGithub = InferResultType<
|
||||
"applications",
|
||||
{ githubProvider: true }
|
||||
{ github: true }
|
||||
>;
|
||||
|
||||
export type ComposeWithGithub = InferResultType<
|
||||
"compose",
|
||||
{ githubProvider: true }
|
||||
>;
|
||||
export type ComposeWithGithub = InferResultType<"compose", { github: true }>;
|
||||
export const cloneGithubRepository = async (
|
||||
entity: ApplicationWithGithub | ComposeWithGithub,
|
||||
logPath: string,
|
||||
@ -108,7 +105,7 @@ export const cloneGithubRepository = async (
|
||||
});
|
||||
}
|
||||
|
||||
const githubProvider = await getGithubProvider(githubId);
|
||||
const githubProvider = await findGithubById(githubId);
|
||||
const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH;
|
||||
const outputPath = join(basePath, appName, "code");
|
||||
const octokit = authGithub(githubProvider);
|
||||
@ -155,7 +152,7 @@ export const cloneRawGithubRepository = async (entity: Compose) => {
|
||||
message: "GitHub Provider not found",
|
||||
});
|
||||
}
|
||||
const githubProvider = await getGithubProvider(githubId);
|
||||
const githubProvider = await findGithubById(githubId);
|
||||
const basePath = COMPOSE_PATH;
|
||||
const outputPath = join(basePath, appName, "code");
|
||||
const octokit = authGithub(githubProvider);
|
||||
@ -188,7 +185,7 @@ export const getGithubRepositories = async (input: GetGithubRepositories) => {
|
||||
return [];
|
||||
}
|
||||
|
||||
const githubProvider = await getGithubProvider(input.githubId);
|
||||
const githubProvider = await findGithubById(input.githubId);
|
||||
|
||||
const octokit = new Octokit({
|
||||
authStrategy: createAppAuth,
|
||||
@ -218,7 +215,7 @@ export const getGithubBranches = async (input: GetGithubBranches) => {
|
||||
if (!input.githubId) {
|
||||
return [];
|
||||
}
|
||||
const githubProvider = await getGithubProvider(input.githubId);
|
||||
const githubProvider = await findGithubById(input.githubId);
|
||||
|
||||
const octokit = new Octokit({
|
||||
authStrategy: createAppAuth,
|
||||
|
@ -5,15 +5,15 @@ import { TRPCError } from "@trpc/server";
|
||||
import { recreateDirectory } from "../filesystem/directory";
|
||||
import { spawnAsync } from "../process/spawnAsync";
|
||||
import {
|
||||
getGitlabProvider,
|
||||
type GitlabProvider,
|
||||
updateGitlabProvider,
|
||||
findGitlabById,
|
||||
type Gitlab,
|
||||
updateGitlab,
|
||||
} from "@/server/api/services/git-provider";
|
||||
import type { InferResultType } from "@/server/types/with";
|
||||
import type { Compose } from "@/server/api/services/compose";
|
||||
|
||||
export const refreshGitlabToken = async (gitlabProviderId: string) => {
|
||||
const gitlabProvider = await getGitlabProvider(gitlabProviderId);
|
||||
const gitlabProvider = await findGitlabById(gitlabProviderId);
|
||||
const currentTime = Math.floor(Date.now() / 1000);
|
||||
|
||||
const safetyMargin = 60;
|
||||
@ -48,7 +48,7 @@ export const refreshGitlabToken = async (gitlabProviderId: string) => {
|
||||
|
||||
console.log("Refreshed token");
|
||||
|
||||
await updateGitlabProvider(gitlabProviderId, {
|
||||
await updateGitlab(gitlabProviderId, {
|
||||
accessToken: data.access_token,
|
||||
refreshToken: data.refresh_token,
|
||||
expiresAt,
|
||||
@ -56,7 +56,7 @@ export const refreshGitlabToken = async (gitlabProviderId: string) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const haveGitlabRequirements = (gitlabProvider: GitlabProvider) => {
|
||||
export const haveGitlabRequirements = (gitlabProvider: Gitlab) => {
|
||||
return !!(gitlabProvider?.accessToken && gitlabProvider?.refreshToken);
|
||||
};
|
||||
|
||||
@ -77,13 +77,10 @@ const getErrorCloneRequirements = (entity: {
|
||||
|
||||
export type ApplicationWithGitlab = InferResultType<
|
||||
"applications",
|
||||
{ gitlabProvider: true }
|
||||
{ gitlab: true }
|
||||
>;
|
||||
|
||||
export type ComposeWithGitlab = InferResultType<
|
||||
"compose",
|
||||
{ gitlabProvider: true }
|
||||
>;
|
||||
export type ComposeWithGitlab = InferResultType<"compose", { gitlab: true }>;
|
||||
|
||||
export const cloneGitlabRepository = async (
|
||||
entity: ApplicationWithGitlab | ComposeWithGitlab,
|
||||
@ -91,13 +88,8 @@ export const cloneGitlabRepository = async (
|
||||
isCompose = false,
|
||||
) => {
|
||||
const writeStream = createWriteStream(logPath, { flags: "a" });
|
||||
const {
|
||||
appName,
|
||||
gitlabBranch,
|
||||
gitlabId,
|
||||
gitlabProvider,
|
||||
gitlabPathNamespace,
|
||||
} = entity;
|
||||
const { appName, gitlabBranch, gitlabId, gitlab, gitlabPathNamespace } =
|
||||
entity;
|
||||
|
||||
if (!gitlabId) {
|
||||
throw new TRPCError({
|
||||
@ -127,7 +119,7 @@ export const cloneGitlabRepository = async (
|
||||
const outputPath = join(basePath, appName, "code");
|
||||
await recreateDirectory(outputPath);
|
||||
const repoclone = `gitlab.com/${gitlabPathNamespace}.git`;
|
||||
const cloneUrl = `https://oauth2:${gitlabProvider?.accessToken}@${repoclone}`;
|
||||
const cloneUrl = `https://oauth2:${gitlab?.accessToken}@${repoclone}`;
|
||||
|
||||
try {
|
||||
writeStream.write(`\nClonning Repo ${repoclone} to ${outputPath}: ✅\n`);
|
||||
@ -167,7 +159,7 @@ export const getGitlabRepositories = async (input: {
|
||||
|
||||
await refreshGitlabToken(input.gitlabId);
|
||||
|
||||
const gitlabProvider = await getGitlabProvider(input.gitlabId);
|
||||
const gitlabProvider = await findGitlabById(input.gitlabId);
|
||||
|
||||
const response = await fetch(
|
||||
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
||||
@ -227,7 +219,7 @@ export const getGitlabBranches = async (input: {
|
||||
return [];
|
||||
}
|
||||
|
||||
const gitlabProvider = await getGitlabProvider(input.gitlabId);
|
||||
const gitlabProvider = await findGitlabById(input.gitlabId);
|
||||
|
||||
const branchesResponse = await fetch(
|
||||
`https://gitlab.com/api/v4/projects/${input.id}/repository/branches`,
|
||||
@ -270,7 +262,7 @@ export const cloneRawGitlabRepository = async (entity: Compose) => {
|
||||
});
|
||||
}
|
||||
|
||||
const gitlabProvider = await getGitlabProvider(gitlabId);
|
||||
const gitlabProvider = await findGitlabById(gitlabId);
|
||||
|
||||
await refreshGitlabToken(gitlabId);
|
||||
const basePath = COMPOSE_PATH;
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user