Skip to content
Snippets Groups Projects
Commit e3270b06 authored by joel.vonderwe's avatar joel.vonderwe
Browse files

Add sonar types

parent e65bf725
No related branches found
No related tags found
No related merge requests found
import * as process from 'process';
class SharedConfig { class SharedConfig {
public readonly production: boolean; public readonly production: boolean;
public debug: boolean = false; public debug: boolean = false;
...@@ -7,6 +10,7 @@ class SharedConfig { ...@@ -7,6 +10,7 @@ class SharedConfig {
public sonar: { public sonar: {
enabled: boolean enabled: boolean
url: string url: string
token: string
} }
public gitlab: { public gitlab: {
...@@ -28,7 +32,8 @@ class SharedConfig { ...@@ -28,7 +32,8 @@ class SharedConfig {
this.production = process.env.NODE_ENV === 'production'; this.production = process.env.NODE_ENV === 'production';
this.sonar = { this.sonar = {
enabled: ['yes', 'true', '1', 'on'].includes(process.env.SONAR_ENABLED?.trim()?.toLowerCase() ?? ''), enabled: ['yes', 'true', '1', 'on'].includes(process.env.SONAR_ENABLED?.trim()?.toLowerCase() ?? ''),
url: process.env.SONAR_URL || '' url: process.env.SONAR_URL || '',
token: process.env.SONAR_TOKEN || ''
}; };
this.logsFolder = process.env.LOGS_FOLDER || ''; this.logsFolder = process.env.LOGS_FOLDER || '';
......
import axios from 'axios';
import https from 'https';
import SharedConfig from '../config/SharedConfig';
class SharedSonarManager {
// Use custom instance to allow self-signed certificates
private instance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
});
async isSonarSupported(): Promise<boolean> {
if (!SharedConfig.sonar.enabled) {
return false;
}
try {
const sonar = await this.instance.get(SharedConfig.sonar.url);
return sonar.status == 200;
} catch ( error ) {
return false;
}
}
}
export default new SharedSonarManager();
\ No newline at end of file
interface SonarProjectCreation {
project: {
key: string,
name: string,
qualifier: string,
visibility: string
}
}
export default SonarProjectCreation;
\ No newline at end of file
enum SonarRoute {
SET_PAT = '/api/alm_integrations/set_pat',
PROJECT_CREATE_GITLAB = '/api/alm_integrations/import_gitlab_project'
}
export default SonarRoute;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment