From: Lukasz Rajewski Date: Fri, 9 Oct 2020 21:19:07 +0000 (+0200) Subject: Fixed k8s profile upload for source with tar.gz file X-Git-Tag: 1.1.0~142 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=e7396afde23c4d335a097fa02bcae5f47a4ca6ed;p=ccsdk%2Fcds.git Fixed k8s profile upload for source with tar.gz file Fixed k8s profile upload for source with tar.gz file Change was tested with CBA https://gerrit.onap.org/r/c/demo/+/113732 Change-Id: I08aa834cc4fedaf77b4c660ec16dea930dade588 Issue-ID: CCSDK-2899 Signed-off-by: Lukasz Rajewski --- diff --git a/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt b/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt index 6b575a60a..76b7fae71 100644 --- a/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt +++ b/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt @@ -198,16 +198,13 @@ open class K8sProfileUploadComponent( private suspend fun prepareProfileFile(k8sRbProfileName: String, ks8ProfileSource: String, ks8ProfileLocation: String): Path { val bluePrintContext = bluePrintRuntimeService.bluePrintContext() val bluePrintBasePath: String = bluePrintContext.rootPath - val profileSourceFileFolderPath: String = bluePrintBasePath.plus(File.separator) - .plus(ks8ProfileLocation) - val profileFilePathTarGz: String = profileSourceFileFolderPath.plus(".tar.gz") - val profileFilePathTgz: String = profileSourceFileFolderPath.plus(".tgz") + val profileSourceFileFolderPath: Path = Paths.get( + bluePrintBasePath.plus(File.separator).plus(ks8ProfileLocation) + ) - if (Paths.get(profileFilePathTarGz).toFile().exists()) - return Paths.get(profileFilePathTarGz) - else if (Paths.get(profileFilePathTgz).toFile().exists()) - return Paths.get(profileFilePathTgz) - else if (Paths.get(profileSourceFileFolderPath).toFile().exists()) { + if (profileSourceFileFolderPath.toFile().exists() && !profileSourceFileFolderPath.toFile().isDirectory) + return profileSourceFileFolderPath + else if (profileSourceFileFolderPath.toFile().exists()) { log.info("Profile building started from source $ks8ProfileSource") val properties: MutableMap = mutableMapOf() properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = false @@ -227,12 +224,12 @@ open class K8sProfileUploadComponent( try { val manifestFiles: ArrayList? = readManifestFiles( - Paths.get(profileSourceFileFolderPath).toFile(), + profileSourceFileFolderPath.toFile(), tempProfilePath ) if (manifestFiles != null) { templateLocation( - Paths.get(profileSourceFileFolderPath).toFile(), resolutionResult.second, + profileSourceFileFolderPath.toFile(), resolutionResult.second, tempProfilePath, manifestFiles ) } else @@ -258,7 +255,7 @@ open class K8sProfileUploadComponent( throw t } } else - throw BluePrintProcessorException("Profile source $ks8ProfileSource is missing in CBA folder") + throw BluePrintProcessorException("Profile source $ks8ProfileLocation is missing in CBA folder") } private fun readManifestFiles(profileSource: File, destinationFolder: File): ArrayList? {