formatNode()

in source/backend/discovery/src/discovery/dataClient.js [349:406]


    formatNode(node) {

        let configuration = JSON.parse(node.properties.configuration);

        if (configuration == null) {
            logger.error("Config parse error, configuration = null check config settings");
        }

        if (configuration != null) {
            for (let element of Object.keys(configuration)) {
                if (configToKeep.has(element)) {
                    node.properties[element] = configuration[element]
                }
            }
        }

        if (node.properties.state) {
            node.properties.state = JSON.stringify(node.properties.state);
        }

        if (node.properties.stateReason) {
            node.properties.stateReason = JSON.stringify(node.properties.stateReason);
        }

        if (node.properties.endpoint) {
            node.properties.endpoint = JSON.stringify(node.properties.endpoint);
        }

        // Create the URLS to the console
        let { loginURL, loggedInURL } = consoleM.getConsoleURLs(node);
        node.properties.loginURL = loginURL;
        node.properties.loggedInURL = loggedInURL;

        // Generate the title property
        generateHeader.generateHeader(node);

        // Add in missing VPC and subnet config
        if(configuration != null) {
            if (node.properties.resourceType === "AWS::Lambda::Function") {
                if (configuration.vpcConfig != null) {
                    node.properties.subnetIds = configuration.vpcConfig.subnetIds;
                }
            } else if(node.properties.resourceType === "AWS::RDS::DBInstance") {
                if(configuration.dBSubnetGroup != null) {
                    node.properties.vpcId = configuration.dBSubnetGroup.vpcId;
                    const {subnetIdentifier} = R.find(({subnetAvailabilityZone}) => subnetAvailabilityZone.name === configuration.availabilityZone,
                        configuration.dBSubnetGroup.subnets);
                    node.properties.subnetId = subnetIdentifier;
                }
            }
        }

        // Sometimes we have to store temporary data in the node to allow for
        // further processing.  See zoomUtils.expand....
        delete node.properties.temporary;

        return node;
    }