mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Simplify environment variable overrides.
This commit is contained in:
parent
e4679b65c0
commit
01070bcf6c
1 changed files with 40 additions and 38 deletions
78
lib/cli.js
78
lib/cli.js
|
@ -147,56 +147,60 @@ program
|
||||||
.option('-p, --port <port>'
|
.option('-p, --port <port>'
|
||||||
, 'port (or $PORT)'
|
, 'port (or $PORT)'
|
||||||
, Number
|
, Number
|
||||||
, 7120)
|
, process.env.PORT || 7120)
|
||||||
.option('-s, --secret <secret>'
|
.option('-s, --secret <secret>'
|
||||||
, 'secret (or $SECRET)'
|
, 'secret (or $SECRET)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.SECRET)
|
||||||
.option('-i, --ssid <ssid>'
|
.option('-i, --ssid <ssid>'
|
||||||
, 'session SSID (or $SSID)'
|
, 'session SSID (or $SSID)'
|
||||||
, String
|
, String
|
||||||
, 'ssid')
|
, process.env.SSID || 'ssid')
|
||||||
.option('-u, --ldap-url <url>'
|
.option('-u, --ldap-url <url>'
|
||||||
, 'LDAP server URL (or $LDAP_URL)'
|
, 'LDAP server URL (or $LDAP_URL)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.LDAP_URL)
|
||||||
.option('-t, --ldap-timeout <timeout>'
|
.option('-t, --ldap-timeout <timeout>'
|
||||||
, 'LDAP timeout (or $LDAP_TIMEOUT)'
|
, 'LDAP timeout (or $LDAP_TIMEOUT)'
|
||||||
, Number
|
, Number
|
||||||
, 1000)
|
, process.env.LDAP_TIMEOUT || 1000)
|
||||||
.option('--ldap-bind-dn <dn>'
|
.option('--ldap-bind-dn <dn>'
|
||||||
, 'LDAP bind DN (or $LDAP_BIND_DN)'
|
, 'LDAP bind DN (or $LDAP_BIND_DN)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.LDAP_BIND_DN)
|
||||||
.option('--ldap-bind-credentials <credentials>'
|
.option('--ldap-bind-credentials <credentials>'
|
||||||
, 'LDAP bind credentials (or $LDAP_BIND_CREDENTIALS)'
|
, 'LDAP bind credentials (or $LDAP_BIND_CREDENTIALS)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.LDAP_BIND_CREDENTIALS)
|
||||||
.option('--ldap-search-dn <dn>'
|
.option('--ldap-search-dn <dn>'
|
||||||
, 'LDAP search DN (or $LDAP_SEARCH_DN)'
|
, 'LDAP search DN (or $LDAP_SEARCH_DN)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.LDAP_SEARCH_DN)
|
||||||
.option('--ldap-search-scope <scope>'
|
.option('--ldap-search-scope <scope>'
|
||||||
, 'LDAP search scope (or $LDAP_SEARCH_SCOPE)'
|
, 'LDAP search scope (or $LDAP_SEARCH_SCOPE)'
|
||||||
, String
|
, String
|
||||||
, 'sub')
|
, process.env.LDAP_SEARCH_SCOPE || 'sub')
|
||||||
.option('--ldap-search-class <class>'
|
.option('--ldap-search-class <class>'
|
||||||
, 'LDAP search objectClass (or $LDAP_SEARCH_CLASS)'
|
, 'LDAP search objectClass (or $LDAP_SEARCH_CLASS)'
|
||||||
, String
|
, String
|
||||||
, 'user')
|
, process.env.LDAP_SEARCH_CLASS || 'user')
|
||||||
.action(function(options) {
|
.action(function(options) {
|
||||||
var env = process.env
|
|
||||||
require('./roles/auth/ldap')({
|
require('./roles/auth/ldap')({
|
||||||
port: env.PORT || options.port
|
port: options.port
|
||||||
, secret: options.secret || env.SECRET
|
, secret: options.secret
|
||||||
, ssid: options.ssid || env.SSID
|
, ssid: options.ssid
|
||||||
, ldap: {
|
, ldap: {
|
||||||
url: options.ldapUrl || env.LDAP_URL
|
url: options.ldapUrl
|
||||||
, timeout: options.ldapTimeout || env.LDAP_TIMEOUT
|
, timeout: options.ldapTimeout
|
||||||
, bind: {
|
, bind: {
|
||||||
dn: options.ldapBindDn || env.LDAP_BIND_DN
|
dn: options.ldapBindDn
|
||||||
, credentials: options.ldapBindCredentials || env.LDAP_BIND_CREDENTIALS
|
, credentials: options.ldapBindCredentials
|
||||||
}
|
}
|
||||||
, search: {
|
, search: {
|
||||||
dn: options.ldapSearchDn || env.LDAP_SEARCH_DN
|
dn: options.ldapSearchDn
|
||||||
, scope: options.ldapSearchScope || env.LDAP_SEARCH_SCOPE
|
, scope: options.ldapSearchScope
|
||||||
, objectClass: options.ldapSearchClass || env.LDAP_SEARCH_CLASS
|
, objectClass: options.ldapSearchClass
|
||||||
, loginField: options.ldapSearchLoginField || env.LDAP_SEARCH_LOGINFIELD
|
, loginField: options.ldapSearchLoginField
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -208,20 +212,19 @@ program
|
||||||
.option('-p, --port <port>'
|
.option('-p, --port <port>'
|
||||||
, 'port (or $PORT)'
|
, 'port (or $PORT)'
|
||||||
, Number
|
, Number
|
||||||
, 7120)
|
, process.env.PORT || 7120)
|
||||||
.option('-s, --secret <secret>'
|
.option('-s, --secret <secret>'
|
||||||
, 'secret (or $SECRET)'
|
, 'secret (or $SECRET)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.SECRET)
|
||||||
.option('-i, --ssid <ssid>'
|
.option('-i, --ssid <ssid>'
|
||||||
, 'session SSID (or $SSID)'
|
, 'session SSID (or $SSID)'
|
||||||
, String
|
, String
|
||||||
, 'ssid')
|
, process.env.SSID || 'ssid')
|
||||||
.option('-a, --app-url <url>'
|
.option('-a, --app-url <url>'
|
||||||
, 'URL to app'
|
, 'URL to app'
|
||||||
, String)
|
, String)
|
||||||
.action(function(options) {
|
.action(function(options) {
|
||||||
var env = process.env
|
|
||||||
|
|
||||||
if (!options.secret) {
|
if (!options.secret) {
|
||||||
this.missingArgument('--secret')
|
this.missingArgument('--secret')
|
||||||
}
|
}
|
||||||
|
@ -230,9 +233,9 @@ program
|
||||||
}
|
}
|
||||||
|
|
||||||
require('./roles/auth/mock')({
|
require('./roles/auth/mock')({
|
||||||
port: env.PORT || options.port
|
port: options.port
|
||||||
, secret: options.secret || env.SECRET
|
, secret: options.secret
|
||||||
, ssid: options.ssid || env.SSID
|
, ssid: options.ssid
|
||||||
, appUrl: options.appUrl
|
, appUrl: options.appUrl
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -282,20 +285,19 @@ program
|
||||||
.option('-p, --port <port>'
|
.option('-p, --port <port>'
|
||||||
, 'port (or $PORT)'
|
, 'port (or $PORT)'
|
||||||
, Number
|
, Number
|
||||||
, 7100)
|
, process.env.PORT || 7100)
|
||||||
.option('-s, --secret <secret>'
|
.option('-s, --secret <secret>'
|
||||||
, 'secret (or $SECRET)'
|
, 'secret (or $SECRET)'
|
||||||
, String)
|
, String
|
||||||
|
, process.env.SECRET)
|
||||||
.option('-i, --ssid <ssid>'
|
.option('-i, --ssid <ssid>'
|
||||||
, 'session SSID (or $SSID)'
|
, 'session SSID (or $SSID)'
|
||||||
, String
|
, String
|
||||||
, 'ssid')
|
, process.env.SSID || 'ssid')
|
||||||
.option('-a, --auth-url <url>'
|
.option('-a, --auth-url <url>'
|
||||||
, 'URL to auth client'
|
, 'URL to auth client'
|
||||||
, String)
|
, String)
|
||||||
.action(function(options) {
|
.action(function(options) {
|
||||||
var env = process.env
|
|
||||||
|
|
||||||
if (!options.secret) {
|
if (!options.secret) {
|
||||||
this.missingArgument('--secret')
|
this.missingArgument('--secret')
|
||||||
}
|
}
|
||||||
|
@ -304,9 +306,9 @@ program
|
||||||
}
|
}
|
||||||
|
|
||||||
require('./roles/app')({
|
require('./roles/app')({
|
||||||
port: env.PORT || options.port
|
port: options.port
|
||||||
, secret: options.secret || env.SECRET
|
, secret: options.secret
|
||||||
, ssid: options.ssid || env.SSID
|
, ssid: options.ssid
|
||||||
, authUrl: options.authUrl
|
, authUrl: options.authUrl
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue