From 15f1d7121c4735c1dd33a80930d9cd61e58ac050 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Wed, 9 Sep 2020 10:45:44 +0200 Subject: Changed method of k8s-upload-profile template prefix acquisition Issue-ID: CCSDK-2630 Signed-off-by: Lukasz Rajewski Change-Id: Id3a493875a171ef374a4e2f0354ca7fe706d0a48 --- .../profile/upload/K8sProfileUploadComponent.kt | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'ms/blueprintsprocessor') 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 0ae76ea7e..337104551 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 @@ -20,6 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.profile.upload import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.ObjectNode import org.apache.commons.io.FileUtils import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService @@ -63,6 +64,7 @@ open class K8sProfileUploadComponent( const val INPUT_K8S_PROFILE_NAMESPACE = "k8s-rb-profile-namespace" const val INPUT_K8S_PROFILE_SOURCE = "k8s-rb-profile-source" const val INPUT_RESOURCE_ASSIGNMENT_MAP = "resource-assignment-map" + const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names" const val OUTPUT_STATUSES = "statuses" const val OUTPUT_SKIPPED = "skipped" @@ -80,7 +82,8 @@ open class K8sProfileUploadComponent( INPUT_K8S_DEFINITION_NAME, INPUT_K8S_DEFINITION_VERSION, INPUT_K8S_PROFILE_NAMESPACE, - INPUT_K8S_PROFILE_SOURCE + INPUT_K8S_PROFILE_SOURCE, + INPUT_ARTIFACT_PREFIX_NAMES ) var outputPrefixStatuses = mutableMapOf() var inputParamsMap = mutableMapOf() @@ -90,7 +93,7 @@ open class K8sProfileUploadComponent( } log.info("Getting the template prefixes") - val prefixList: ArrayList = getTemplatePrefixList(executionRequest) + val prefixList: ArrayList = getTemplatePrefixList(inputParamsMap[INPUT_ARTIFACT_PREFIX_NAMES]) log.info("Iterating over prefixes in resource assignment map.") for (prefix in prefixList) { @@ -175,10 +178,18 @@ open class K8sProfileUploadComponent( bluePrintRuntimeService.getBluePrintError().addError(runtimeException.message!!) } - fun getTemplatePrefixList(executionRequest: ExecutionServiceInput): ArrayList { - val result = ArrayList() - for (prefix in executionRequest.payload.get("resource-assignment-request").get("template-prefix").elements()) - result.add(prefix.asText()) + private fun getTemplatePrefixList(node: JsonNode?): ArrayList { + var result = ArrayList() + when (node) { + is ArrayNode -> { + val arrayNode = node.toList() + for (prefixNode in arrayNode) + result.add(prefixNode.asText()) + } + is ObjectNode -> { + result.add(node.asText()) + } + } return result } -- cgit 1.2.3-korg