Skip to content
Snippets Groups Projects
Commit 07d2a1ab authored by joel.vonderwe's avatar joel.vonderwe Committed by michael.minelli
Browse files

Add sonar types

parent 715230bb
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,13 +10,15 @@ class SharedConfig { ...@@ -7,13 +10,15 @@ class SharedConfig {
public sonar: { public sonar: {
enabled: boolean enabled: boolean
url: string url: string
token: string
} }
constructor() { constructor() {
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