Merge pull request #804 from titouanmathis/feat/git-source-custom-user

feat(git-source): Add support for custom SSH user for GitLab self-hosted
This commit is contained in:
Andras Bacsai
2023-01-10 11:17:01 +01:00
committed by GitHub
8 changed files with 63 additions and 10 deletions

View File

@@ -22,11 +22,11 @@ export async function listSources(request: FastifyRequest) {
export async function saveSource(request, reply) {
try {
const { id } = request.params
let { name, htmlUrl, apiUrl, customPort, isSystemWide } = request.body
let { name, htmlUrl, apiUrl, customPort, customUser, isSystemWide } = request.body
if (customPort) customPort = Number(customPort)
await prisma.gitSource.update({
where: { id },
data: { name, htmlUrl, apiUrl, customPort, isSystemWide }
data: { name, htmlUrl, apiUrl, customPort, customUser, isSystemWide }
});
return reply.code(201).send()
} catch ({ status, message }) {
@@ -48,6 +48,7 @@ export async function getSource(request: FastifyRequest<OnlyId>) {
apiUrl: null,
organization: null,
customPort: 22,
customUser: 'git',
},
settings
}
@@ -102,7 +103,7 @@ export async function saveGitHubSource(request: FastifyRequest<SaveGitHubSource>
const { teamId } = request.user
const { id } = request.params
let { name, htmlUrl, apiUrl, organization, customPort, isSystemWide } = request.body
let { name, htmlUrl, apiUrl, organization, customPort, customUser, isSystemWide } = request.body
if (customPort) customPort = Number(customPort)
if (id === 'new') {
@@ -115,6 +116,7 @@ export async function saveGitHubSource(request: FastifyRequest<SaveGitHubSource>
apiUrl,
organization,
customPort,
customUser,
isSystemWide,
type: 'github',
teams: { connect: { id: teamId } }
@@ -133,7 +135,7 @@ export async function saveGitLabSource(request: FastifyRequest<SaveGitLabSource>
try {
const { id } = request.params
const { teamId } = request.user
let { type, name, htmlUrl, apiUrl, oauthId, appId, appSecret, groupName, customPort } =
let { type, name, htmlUrl, apiUrl, oauthId, appId, appSecret, groupName, customPort, customUser } =
request.body
if (oauthId) oauthId = Number(oauthId);
@@ -142,7 +144,7 @@ export async function saveGitLabSource(request: FastifyRequest<SaveGitLabSource>
if (id === 'new') {
const newId = cuid()
await prisma.gitSource.create({ data: { id: newId, type, apiUrl, htmlUrl, name, customPort, teams: { connect: { id: teamId } } } });
await prisma.gitSource.create({ data: { id: newId, type, apiUrl, htmlUrl, name, customPort, customUser, teams: { connect: { id: teamId } } } });
await prisma.gitlabApp.create({
data: {
teams: { connect: { id: teamId } },
@@ -158,7 +160,7 @@ export async function saveGitLabSource(request: FastifyRequest<SaveGitLabSource>
id: newId
}
} else {
await prisma.gitSource.update({ where: { id }, data: { type, apiUrl, htmlUrl, name, customPort } });
await prisma.gitSource.update({ where: { id }, data: { type, apiUrl, htmlUrl, name, customPort, customUser } });
await prisma.gitlabApp.update({
where: { id },
data: {

View File

@@ -21,6 +21,7 @@ export interface SaveGitLabSource extends OnlyId {
appSecret: string,
groupName: string,
customPort: number,
customUser: string,
}
}
export interface CheckGitLabOAuthId extends OnlyId {