aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
authorshikha0203 <shivani.khare@est.tech>2023-05-18 14:11:03 +0100
committerMichael Morris <michael.morris@est.tech>2023-05-24 18:29:14 +0000
commit871b9813322801509a566b49a1cdcc65c052de29 (patch)
tree1fba6b9768712bf5c7d641a2a98c7dc1ce03fe09 /catalog-ui
parente3f5545168163fdbf0d83314ee9dd51983e4bcc8 (diff)
Support import of service with no substitution mapping node type
Issue-ID: SDC-4506 Signed-off-by: shikha0203 <shivani.khare@est.tech> Change-Id: I7bc8f020418f2b9299be3454ffbc1e016a2d300e
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/utils/service-csar-reader.ts17
1 files changed, 12 insertions, 5 deletions
diff --git a/catalog-ui/src/app/utils/service-csar-reader.ts b/catalog-ui/src/app/utils/service-csar-reader.ts
index 90de53b8c9..20dfe6ca6b 100644
--- a/catalog-ui/src/app/utils/service-csar-reader.ts
+++ b/catalog-ui/src/app/utils/service-csar-reader.ts
@@ -20,7 +20,7 @@
import {ServiceCsar, ToscaMetaEntry} from "../models";
import {load} from 'js-yaml';
-import { ComponentType } from "./constants";
+import {ComponentType} from "./constants";
export class ServiceCsarReader {
@@ -35,8 +35,12 @@ export class ServiceCsarReader {
this.readToscaMeta(toscaMetaFileContent);
const entryDefinitionFileContent = await zip.file(this.serviceCsar.entryDefinitionFileName).async("string");
this.readServiceMetadata(entryDefinitionFileContent);
- const interfaceDefinitionFileContent = await zip.file(this.serviceCsar.interfaceDefinitionFileName).async("string");
- this.readServiceSubstitutionNode(interfaceDefinitionFileContent);
+ if (zip.file(this.serviceCsar.interfaceDefinitionFileName) != null) {
+ const interfaceDefinitionFileContent = await zip.file(this.serviceCsar.interfaceDefinitionFileName).async("string");
+ this.readSubstitutionNodeFromInterfaceDefinitionFile(interfaceDefinitionFileContent);
+ } else {
+ this.readSubstitutionNodeFromMainTemplateFile(entryDefinitionFileContent);
+ }
resolve(this.serviceCsar);
} catch (error) {
reject(error);
@@ -60,7 +64,6 @@ export class ServiceCsarReader {
private readEntryDefinitionFileName() {
this.serviceCsar.entryDefinitionFileName = this.serviceCsar.toscaMeta.getEntry(ToscaMetaEntry.ENTRY_DEFINITIONS);
}
-
private readInterfaceDefinitionFileName() {
let fileNameArray:Array<string> = this.serviceCsar.entryDefinitionFileName.split(".");
fileNameArray.splice(fileNameArray.length - 1, 0, "-interface.");
@@ -72,12 +75,16 @@ export class ServiceCsarReader {
this.setMetadata(metadata);
}
- private readServiceSubstitutionNode(interfaceDefinitionFileContent) {
+ private readSubstitutionNodeFromInterfaceDefinitionFile(interfaceDefinitionFileContent) {
const nodeTypes = load(interfaceDefinitionFileContent).node_types;
let nodeType = Object.keys(nodeTypes).values().next().value;
this.serviceCsar.substitutionNodeType = nodeTypes[nodeType]["derived_from"];
}
+ private readSubstitutionNodeFromMainTemplateFile(entryDefinitionFileContent) {
+ this.serviceCsar.substitutionNodeType = load(entryDefinitionFileContent).topology_template.substitution_mappings.node_type;
+ }
+
private setMetadata = (metadata:object) : void => {
let extraServiceMetadata: Map<string, string> = new Map<string, string>();
this.serviceCsar.serviceMetadata.componentType = ComponentType.SERVICE;