aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2020-09-09 10:45:44 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2020-09-09 13:10:14 +0200
commit15f1d7121c4735c1dd33a80930d9cd61e58ac050 (patch)
tree4b1ef2c5197524492c793b4bb0e15dc3fe8d3df5 /ms
parent98627b6fcc481b6678fcc89c17891ab059d81ea2 (diff)
Changed method of k8s-upload-profile template prefix acquisition
Issue-ID: CCSDK-2630 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: Id3a493875a171ef374a4e2f0354ca7fe706d0a48
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt23
1 files changed, 17 insertions, 6 deletions
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<String, String>()
var inputParamsMap = mutableMapOf<String, JsonNode?>()
@@ -90,7 +93,7 @@ open class K8sProfileUploadComponent(
}
log.info("Getting the template prefixes")
- val prefixList: ArrayList<String> = getTemplatePrefixList(executionRequest)
+ val prefixList: ArrayList<String> = 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<String> {
- val result = ArrayList<String>()
- for (prefix in executionRequest.payload.get("resource-assignment-request").get("template-prefix").elements())
- result.add(prefix.asText())
+ private fun getTemplatePrefixList(node: JsonNode?): ArrayList<String> {
+ var result = ArrayList<String>()
+ when (node) {
+ is ArrayNode -> {
+ val arrayNode = node.toList()
+ for (prefixNode in arrayNode)
+ result.add(prefixNode.asText())
+ }
+ is ObjectNode -> {
+ result.add(node.asText())
+ }
+ }
return result
}