From 28114658520687dbd8d7a767e00f1a2e01b5b742 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Struewer <j.n.struewer@gmail.com> Date: Thu, 2 Nov 2023 16:27:24 +0100 Subject: [PATCH] Updated OCCMD tool to support private repositories --- .../iem/dataprovider/kpi/dto/KPITreeResponseDto.kt | 10 ++++++++-- .../dataprovider/tools/occmd/service/OccmdService.kt | 4 +++- src/main/resources/application-dev.properties | 2 +- src/main/resources/scripts/occmd.sh | 8 +++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt index fe62fda0..a4209700 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt +++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt @@ -18,7 +18,13 @@ data class KPITreeResponseDto( } } - val amountOfMissingDataTree: Double = children.sumOf { - it.kpi.amountOfMissingDataChildren + val amountOfMissingDataTree: Double = getAmountOfMissingDataForTree() + + private fun getAmountOfMissingDataForTree(): Double { + if (this.children.isEmpty()) { + return 0.0 + } + + return amountOfMissingDataChildren + children.sumOf { it.kpi.getAmountOfMissingDataForTree() } } } diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt index 254efa18..6e7e8fdb 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt +++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt @@ -66,7 +66,9 @@ class OccmdService( arrayOf( outDir.toString(), "$projectId", - gitlabApiProperties.accessToken + gitlabApiProperties.userName ?: "", + gitlabApiProperties.accessToken, + gitlabApiProperties.host ) ) // delete cloned repo diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index d7aa38bc..87948391 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -4,7 +4,7 @@ spring.config.import=optional:classpath:.env[.properties] opencode.host=https://gitlab.dev.o4oe.de/ opencode.access-token=${OC_GL_APIKEY:} opencode.analyze-private-repos=true -opencode.user-name=${OC_USER:} +opencode.user-name=${OC_GL_USER:} # Tool APIs opencode.api.base-path=https://sl.dev.o4oe.de/api/v1/project/ opencode.api.ort=/cve-result diff --git a/src/main/resources/scripts/occmd.sh b/src/main/resources/scripts/occmd.sh index 4db121a9..7395cd7e 100755 --- a/src/main/resources/scripts/occmd.sh +++ b/src/main/resources/scripts/occmd.sh @@ -2,9 +2,11 @@ INSTALL_DIR=/occmd PROJ_PATH=${1} PROJ_ID=${2} -API_KEY=${3} +USER_NAME=${3} +API_KEY=${4} +URL=${5} + +export OC_GL_APIKEY="${API_KEY}" && export OC_GL_USER="${USER_NAME}" && export OC_GL_URL="${URL}" && cd "${INSTALL_DIR}" && ./occmd check -d "${PROJ_PATH}" -i "${PROJ_ID}" -export OC_GL_APIKEY="${API_KEY}" && cd "${INSTALL_DIR}" && ./occmd check -d "${PROJ_PATH}" -i "${PROJ_ID}" -#(docker run --rm -e OC_GL_APIKEY="${API_KEY}" --mount "type=volume,src=res_occmd,dst=/opt/occmd/resources" --mount "type=bind,src=${PROJ_PATH},dst=/opt/target" occmd -i "${PROJ_ID}") exit 0 -- GitLab