aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src')
-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;