fix: make auth an env var

so that it can be passed into docker easily
This commit is contained in:
2019-01-29 17:01:10 -07:00
parent aefbcabac0
commit ed6186f63b

View File

@@ -7,12 +7,12 @@ const logger = require('../src/lib/logger.mjs').default;
const esHost = process.env.ELASTICSEARCH_HOST || 'localhost'; const esHost = process.env.ELASTICSEARCH_HOST || 'localhost';
const esPort = process.env.ELASTICSEARCH_PORT || '9200'; const esPort = process.env.ELASTICSEARCH_PORT || '9200';
const auth = process.env.ELASTICSEARCH_AUTH || '';
const { index, interval, lat, lon, radius, ...elasticsearch } = getopts(process.argv.slice(2), { const { index, interval, lat, lon, radius, ...esConfig } = getopts(process.argv.slice(2), {
string: ['host', 'auth', 'log', 'index'], string: ['host', 'auth', 'log', 'index'],
alias: { alias: {
h: 'host', h: 'host',
u: 'auth',
l: 'log', l: 'log',
i: 'index', i: 'index',
t: 'interval', t: 'interval',
@@ -35,7 +35,7 @@ function handleError(err) {
async function fetchAndIndex() { async function fetchAndIndex() {
logger.debug('Fetching and indexing data...'); logger.debug('Fetching and indexing data...');
return mod(index, { elasticsearch, filter: { lat, lon, radius } }); return mod(index, { elasticsearch: { ...esConfig, auth }, filter: { lat, lon, radius } });
} }
async function run() { async function run() {