@@ -10,6 +10,9 @@ var os = require('os');
1010global . endpoint = process . env . CONSUL_ENDPOINT || "127.0.0.1" ;
1111global . port = process . env . CONSUL_PORT || 8500 ;
1212global . secure = process . env . CONSUL_SECURE || false ;
13+ global . cert_filename = process . env . CONSUL_CERT || '' ;
14+ global . key_filename = process . env . CONSUL_KEY || '' ;
15+ global . ca_filename = process . env . CONSUL_CA || '' ;
1316global . token = process . env . TOKEN || null ;
1417global . config_file = null ;
1518global . config_key = "git2consul/config"
@@ -60,7 +63,45 @@ for (var i=2; i<process.argv.length; ++i) {
6063 }
6164 global . config_file = process . argv [ i + 1 ] ;
6265 }
66+
67+ if ( process . argv [ i ] === '--cert' ) {
68+ if ( i + 1 >= process . argv . length ) {
69+ logger . error ( "No file provided with --cert option" ) ;
70+ process . exit ( 7 ) ;
71+ }
72+ global . cert_filename = process . argv [ i + 1 ] ;
73+ }
74+
75+ if ( process . argv [ i ] === '--key' ) {
76+ if ( i + 1 >= process . argv . length ) {
77+ logger . error ( "No file provided with --key option" ) ;
78+ process . exit ( 7 ) ;
79+ }
80+ global . key_filename = process . argv [ i + 1 ] ;
81+ }
82+
83+ if ( process . argv [ i ] === '--ca' ) {
84+ if ( i + 1 >= process . argv . length ) {
85+ logger . error ( "No file provided with --ca option" ) ;
86+ process . exit ( 7 ) ;
87+ }
88+ global . ca_filename = process . argv [ i + 1 ] ;
89+ }
90+ }
91+
92+ /**
93+ * Read the certificate, key and CA files.
94+ */
95+ if ( global . cert_filename !== '' ) {
96+ global . cert = fs . readFileSync ( global . cert_filename ) ;
97+ }
98+ if ( global . key_filename !== '' ) {
99+ global . key = fs . readFileSync ( global . key_filename ) ;
63100}
101+ if ( global . ca_filename !== '' ) {
102+ global . ca = fs . readFileSync ( global . ca_filename ) ;
103+ }
104+
64105
65106var config_reader = require ( './config_reader.js' ) ;
66107var config_seeder = require ( './config_seeder.js' ) ;
0 commit comments