blob: a73964a77fc67259a73ff4dca719ae10e6d4d250 [file] [log] [blame]
Matteo Scandolobd13aab2017-08-08 13:05:24 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Matteo Scandoloe3ed0162016-12-01 10:09:12 -080017(function () {
18 'use strict';
Zack Williamsea89ebb2018-09-07 12:37:36 -070019
20 // NOTE do we still need CLI args?
Matteo Scandoloe3ed0162016-12-01 10:09:12 -080021 // Won't be better to use NODE_ENV and the native node-yaml-config feature
22
23 const argv = require('yargs').argv;
24 const path = require('path');
25 const yaml_config = require('node-yaml-config');
26 const logger = require('../config/logger.js');
27
28 // if a config file is specified in as a CLI arguments use that one
29 const cfgFile = argv.config || 'config.yml';
30
31 let config;
32 try {
Matteo Scandolo1116b972018-12-18 09:33:59 -080033 logger.log('debug', `Loading ${path.join(__dirname, cfgFile)}`);
Matteo Scandoloe3ed0162016-12-01 10:09:12 -080034 config = yaml_config.load(path.join(__dirname, cfgFile));
Matteo Scandolo1116b972018-12-18 09:33:59 -080035 logger.log('debug', `Parsed config: ${JSON.stringify(config)}`);
Matteo Scandoloe3ed0162016-12-01 10:09:12 -080036 }
37 catch(e) {
38 logger.log('debug', `No ${cfgFile} found, using default params`);
39 }
40
41 module.exports = {
Matteo Scandoloe3ed0162016-12-01 10:09:12 -080042 gateway: {
43 port: (config && config.gateway) ? config.gateway.port : 3000
Zack Williamsea89ebb2018-09-07 12:37:36 -070044 },
45 kafka_bootstrap_servers: ( config && config.kafka_bootstrap_servers ) ?
46 config.kafka_bootstrap_servers : ['cord-kafka:9092']
Matteo Scandoloe3ed0162016-12-01 10:09:12 -080047 };
Zack Williamsea89ebb2018-09-07 12:37:36 -070048})();