+ if (profileModificationAllowed) {
+ //Here we can add extra files inside the archive
+ val profileModificationDecisionData = getDynamicProperties("profile-modification-decision-data")
+ log.info("Profile modification decision data: ${profileModificationDecisionData}")
+ if (profileModificationDecisionData != null && profileModificationDecisionData.asText().toInt() > 0) {
+ log.info("Modification of profile content")
+
+ val profileArtifacts = getDynamicProperties("profile-artifacts")
+ val sshServiceFileContent = profileArtifacts.get("ssh-service").asText()
+ val sshServiceFileName = "ssh-service.yaml"
+ val serviceFilePath = tempProfilePath.toString().plus(File.separator).plus(sshServiceFileName)
+ File(serviceFilePath).bufferedWriter().use { out -> out.write(sshServiceFileContent) }
+ val manifestFileName = tempProfilePath.toString().plus(File.separator).plus("manifest.yaml")
+ var finalManifest = ""
+ File(manifestFileName).bufferedReader().use { inr ->
+ val manifestYaml = Yaml()
+ val manifestObject: Map<String, Any> = manifestYaml.load(inr)
+ val typeObject: MutableMap<String, Any> = manifestObject.get("type") as MutableMap<String, Any>
+ if (!typeObject.containsKey("configresource"))
+ typeObject.put("configresource", ArrayList<LinkedHashMap<String, Any>>())
+ val configFiles: MutableList<LinkedHashMap<String, Any>> = typeObject.get("configresource") as MutableList<LinkedHashMap<String, Any>>
+ val sshConfigFile = LinkedHashMap<String, Any>()
+ sshConfigFile.put("filepath", sshServiceFileName)
+ sshConfigFile.put("chartpath", "vpkg/templates/${sshServiceFileName}")
+ configFiles.add(sshConfigFile)
+ finalManifest = manifestYaml.dump(manifestObject)
+ }
+ File(manifestFileName).bufferedWriter().use { out -> out.write(finalManifest) }
+ log.info("Modified K8s profile manifest file")
+ log.info(finalManifest)
+ log.info("Modification of profile completed")
+ }
+ }
+