From 4399816485b7e9ebfc8d4c9364009aa04557addf Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 17 Jul 2013 10:29:19 +0200 Subject: [PATCH] Allow specifying api key via CDBSQL_APIKEY env variable --- tools/cdbsql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/cdbsql b/tools/cdbsql index 9f54d440..ca27899d 100755 --- a/tools/cdbsql +++ b/tools/cdbsql @@ -27,7 +27,7 @@ var username = 'dev'; var domain = 'localhost'; var port = 8080; var api_version = 2; -var api_key; +var api_key = process.env['CDBSQL_APIKEY']; var sql; var decimal_places; var echo_queries = false; @@ -46,7 +46,7 @@ function usage(exit_code) { console.log(" --domain service domain (" + domain + ")"); console.log(" --port service tcp port number (" + port + ")"); console.log(" --api-version API version (" + api_version +")"); - console.log(" --key API authentication key (" + api_key + ")"); + console.log(" --key API authentication key (CDBSQL_APIKEY)"); console.log(" --format Response format (json)"); console.log(" --dp Decimal places in geojson format (unspecified)"); console.log(" --skipfields Comma-separated list of fields to skip (none)"); @@ -176,7 +176,7 @@ function processQuery(sql, callback) } }; - if ( typeof(api_key) != 'undefined' ) opt.path += '&api_key=' + api_key; + if ( api_key ) opt.path += '&api_key=' + api_key; if ( typeof(decimal_places) != 'undefined' ) opt.path += '&dp=' + decimal_places; if ( typeof(skipfields) != 'undefined' ) opt.path += '&skipfields=' + encodeURIComponent(skipfields);