Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • jw_sonar
  • jw_sonar_backup
  • main
  • move-to-esm-only
  • open_tool_for_self_hosting
  • v5.0
  • v4.1
  • v4.2
8 results

Target

Select target project
  • dojo_project/projects/shared/nodesharedcode
1 result
Select Git revision
  • jw_sonar
  • jw_sonar_backup
  • main
  • move-to-esm-only
  • open_tool_for_self_hosting
  • v5.0
  • v4.1
  • v4.2
8 results
Show changes
Commits on Source (6)
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;
}
}
/**
* Map a language name to the equivalent language ID in Sonar
* Most language have the same name, so by default the same name is returned, even for languages that doesn't exist in sonar.
* @param language
*/
mapLanguage(language: string): string {
switch (language) {
case "csharp":
return "cs";
case "python":
return "py";
default:
return language;
}
}
}
export default new SharedSonarManager();
\ No newline at end of file
...@@ -11,6 +11,8 @@ enum ExerciseCheckerError { ...@@ -11,6 +11,8 @@ enum ExerciseCheckerError {
COMPOSE_FILE_VOLUME_MISSING = 209, COMPOSE_FILE_VOLUME_MISSING = 209,
DOCKERFILE_NOT_FOUND = 210, DOCKERFILE_NOT_FOUND = 210,
COMPOSE_RUN_SUCCESSFULLY = 211, // Yes, this is an error COMPOSE_RUN_SUCCESSFULLY = 211, // Yes, this is an error
ASSIGNMENT_MISSING = 212,
BUILD_LINE_MISSING = 213,
} }
......
...@@ -5,6 +5,7 @@ import { z } from 'zod'; ...@@ -5,6 +5,7 @@ import { z } from 'zod';
const AssignmentFile = z.object({ const AssignmentFile = z.object({
dojoAssignmentVersion: z.number(), dojoAssignmentVersion: z.number(),
version : z.number(), version : z.number(),
buildLine : z.string().optional(),
immutable : z.array(ImmutableFileDescriptor.transform(value => value as ImmutableFileDescriptor)), immutable : z.array(ImmutableFileDescriptor.transform(value => value as ImmutableFileDescriptor)),
result : z.object({ result : z.object({
container: z.string(), container: z.string(),
......
...@@ -14,7 +14,8 @@ enum DojoStatusCode { ...@@ -14,7 +14,8 @@ enum DojoStatusCode {
ASSIGNMENT_CREATION_SONAR_ERROR = 208, ASSIGNMENT_CREATION_SONAR_ERROR = 208,
EXERCISE_CREATION_GITLAB_ERROR = 302, EXERCISE_CREATION_GITLAB_ERROR = 302,
EXERCISE_CREATION_INTERNAL_ERROR = 303, EXERCISE_CREATION_INTERNAL_ERROR = 303,
MAX_EXERCISE_PER_ASSIGNMENT_REACHED = 304 MAX_EXERCISE_PER_ASSIGNMENT_REACHED = 304,
EXERCISE_CREATION_SONAR_ERROR = 305
} }
......
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',
GET_LANGUAGES = '/api/languages/list'
}
export default SonarRoute;
\ No newline at end of file