summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/k8s-connection-plugin
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-03-24 19:01:34 +0100
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-03-24 19:02:11 +0100
commitc7bd99a9bf07e3023ab510dfe84fc2acbe74299b (patch)
tree9f08173846d125f8ce472e304e851fc76156a9cb /ms/blueprintsprocessor/functions/k8s-connection-plugin
parentf4c4b404e18ef1fddfe7425186026c1e3b43488b (diff)
Fixed bug when k8s profile is created for default k8s version
Fixed bug when k8s profile is created for default k8s version Issue-ID: CCSDK-3239 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: Ibc0c8a6057b4b9eef3beb1821093b935f3b2e53b
Diffstat (limited to 'ms/blueprintsprocessor/functions/k8s-connection-plugin')
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfile.kt3
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfileUploadComponent.kt7
2 files changed, 9 insertions, 1 deletions
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfile.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfile.kt
index dcaf48710..69c835543 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfile.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfile.kt
@@ -32,6 +32,9 @@ class K8sProfile {
@get:JsonProperty("profile-name")
var profileName: String? = null
+ @get:JsonProperty("kubernetes-version")
+ var kubernetesVersion: String? = null
+
@get:JsonProperty("namespace")
var namespace: String? = "default"
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfileUploadComponent.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfileUploadComponent.kt
index 201895cc6..5e853d05f 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfileUploadComponent.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/profile/K8sProfileUploadComponent.kt
@@ -65,6 +65,7 @@ open class K8sProfileUploadComponent(
const val INPUT_K8S_DEFINITION_NAME = "k8s-rb-definition-name"
const val INPUT_K8S_DEFINITION_VERSION = "k8s-rb-definition-version"
const val INPUT_K8S_PROFILE_NAMESPACE = "k8s-rb-profile-namespace"
+ const val INPUT_K8S_PROFILE_K8S_VERSION = "k8s-rb-profile-k8s-version"
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"
@@ -85,6 +86,7 @@ open class K8sProfileUploadComponent(
INPUT_K8S_DEFINITION_NAME,
INPUT_K8S_DEFINITION_VERSION,
INPUT_K8S_PROFILE_NAMESPACE,
+ INPUT_K8S_PROFILE_K8S_VERSION,
INPUT_K8S_PROFILE_SOURCE,
INPUT_ARTIFACT_PREFIX_NAMES
)
@@ -130,7 +132,7 @@ open class K8sProfileUploadComponent(
if ((profileName == null) || (definitionName == null) || (definitionVersion == null)) {
log.warn("Prefix $prefix does not have required data for us to continue.")
} else if (!api.hasDefinition(definitionName, definitionVersion)) {
- log.warn("K8s RB Definition ($definitionName/$definitionVersion) not found ")
+ throw BlueprintProcessorException("K8s RB Definition ($definitionName/$definitionVersion) not found ")
} else if (profileName == "") {
log.warn("K8s rb profile name is empty! Either define profile name to use or choose default")
} else if (api.hasProfile(definitionName, definitionVersion, profileName)) {
@@ -139,6 +141,7 @@ open class K8sProfileUploadComponent(
log.info("Uploading K8s Profile..")
outputPrefixStatuses.put(prefix, OUTPUT_ERROR)
val profileNamespace: String? = prefixInputParamsMap[INPUT_K8S_PROFILE_NAMESPACE]?.returnNullIfMissing()?.asText()
+ val profileK8sVersion: String? = prefixInputParamsMap[INPUT_K8S_PROFILE_K8S_VERSION]?.returnNullIfMissing()?.asText()
var profileSource: String? = prefixInputParamsMap[INPUT_K8S_PROFILE_SOURCE]?.returnNullIfMissing()?.asText()
if (profileNamespace == null)
throw BlueprintProcessorException("Profile $profileName namespace is missing")
@@ -158,6 +161,8 @@ open class K8sProfileUploadComponent(
profile.rbName = definitionName
profile.rbVersion = definitionVersion
profile.namespace = profileNamespace
+ if (profileK8sVersion != null)
+ profile.kubernetesVersion = profileK8sVersion
val profileFilePath: Path = prepareProfileFile(profileName, profileSource, artifact.file)
api.createProfile(definitionName, definitionVersion, profile)
api.uploadProfileContent(definitionName, definitionVersion, profile, profileFilePath)