Skip to content

Commit

Permalink
Merge pull request #965 from 4xpl0r3r/main
Browse files Browse the repository at this point in the history
support custom Gitlab instance with new env var GITLAB_HOST
  • Loading branch information
jgadsden authored Jun 3, 2024
2 parents f8009f8 + 2072bab commit 8c1a395
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
4 changes: 1 addition & 3 deletions td.server/src/env/Gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class GitlabEnv extends Env {
{ key: 'CLIENT_ID', required: false },
{ key: 'CLIENT_SECRET', required: false },
{ key: 'SCOPE', required: false },
{ key: 'ENTERPRISE_HOSTNAME', required: false },
{ key: 'ENTERPRISE_PROTOCOL', required: false },
{ key: 'ENTERPRISE_PORT', required: false },
{ key: 'HOST', required: false },
{ key: 'USE_SEARCH', required: false },
{ key: 'SEARCH_QUERY', required: false },
{ key: 'REDIRECT_URI', required: false },
Expand Down
9 changes: 1 addition & 8 deletions td.server/src/providers/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ const isConfigured = () => Boolean(env.get().config.GITLAB_CLIENT_ID);
* @returns {String}
*/
const getGitlabUrl = () => {
const enterpriseHostname = env.get().config.GITLAB_ENTERPRISE_HOSTNAME;
if(enterpriseHostname) {
const port = env.get().config.GITLAB_ENTERPRISE_PORT || '';
const protocol = env.get().config.GITLAB_ENTERPRISE_PROTOCOL || 'https';
const enterpriseUrl = `${protocol}://${enterpriseHostname}${port ? ':' + port : ''}`;
return enterpriseUrl;
}
return 'https://gitlab.com';
return env.get().config.GITLAB_HOST || 'https://gitlab.com';
};

/**
Expand Down
12 changes: 5 additions & 7 deletions td.server/src/repositories/gitlabrepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ export class GitlabClientWrapper {
}

export const getClient = (accessToken) => {


const enterpriseHostname = env.get().config.GITLAB_ENTERPRISE_HOSTNAME;
if (enterpriseHostname) {
throw new Error(`Gitlab Enterprise is not supported yet`);
}
const clientOptions = {
let clientOptions = {
auth: {
oauthToken: accessToken,
},
};
if (env.get().config.GITLAB_HOST) {
clientOptions.auth['host']=env.get().config.GITLAB_HOST
}

return GitlabClientWrapper.getClient(clientOptions.auth);
};

Expand Down

0 comments on commit 8c1a395

Please sign in to comment.