mirror of
https://github.com/openstf/stf
synced 2025-10-03 17:59:28 +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>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, 7120)
|
||||
, process.env.PORT || 7120)
|
||||
.option('-s, --secret <secret>'
|
||||
, 'secret (or $SECRET)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.SECRET)
|
||||
.option('-i, --ssid <ssid>'
|
||||
, 'session SSID (or $SSID)'
|
||||
, String
|
||||
, 'ssid')
|
||||
, process.env.SSID || 'ssid')
|
||||
.option('-u, --ldap-url <url>'
|
||||
, 'LDAP server URL (or $LDAP_URL)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.LDAP_URL)
|
||||
.option('-t, --ldap-timeout <timeout>'
|
||||
, 'LDAP timeout (or $LDAP_TIMEOUT)'
|
||||
, Number
|
||||
, 1000)
|
||||
, process.env.LDAP_TIMEOUT || 1000)
|
||||
.option('--ldap-bind-dn <dn>'
|
||||
, 'LDAP bind DN (or $LDAP_BIND_DN)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.LDAP_BIND_DN)
|
||||
.option('--ldap-bind-credentials <credentials>'
|
||||
, 'LDAP bind credentials (or $LDAP_BIND_CREDENTIALS)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.LDAP_BIND_CREDENTIALS)
|
||||
.option('--ldap-search-dn <dn>'
|
||||
, 'LDAP search DN (or $LDAP_SEARCH_DN)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.LDAP_SEARCH_DN)
|
||||
.option('--ldap-search-scope <scope>'
|
||||
, 'LDAP search scope (or $LDAP_SEARCH_SCOPE)'
|
||||
, String
|
||||
, 'sub')
|
||||
, process.env.LDAP_SEARCH_SCOPE || 'sub')
|
||||
.option('--ldap-search-class <class>'
|
||||
, 'LDAP search objectClass (or $LDAP_SEARCH_CLASS)'
|
||||
, String
|
||||
, 'user')
|
||||
, process.env.LDAP_SEARCH_CLASS || 'user')
|
||||
.action(function(options) {
|
||||
var env = process.env
|
||||
require('./roles/auth/ldap')({
|
||||
port: env.PORT || options.port
|
||||
, secret: options.secret || env.SECRET
|
||||
, ssid: options.ssid || env.SSID
|
||||
port: options.port
|
||||
, secret: options.secret
|
||||
, ssid: options.ssid
|
||||
, ldap: {
|
||||
url: options.ldapUrl || env.LDAP_URL
|
||||
, timeout: options.ldapTimeout || env.LDAP_TIMEOUT
|
||||
url: options.ldapUrl
|
||||
, timeout: options.ldapTimeout
|
||||
, bind: {
|
||||
dn: options.ldapBindDn || env.LDAP_BIND_DN
|
||||
, credentials: options.ldapBindCredentials || env.LDAP_BIND_CREDENTIALS
|
||||
dn: options.ldapBindDn
|
||||
, credentials: options.ldapBindCredentials
|
||||
}
|
||||
, search: {
|
||||
dn: options.ldapSearchDn || env.LDAP_SEARCH_DN
|
||||
, scope: options.ldapSearchScope || env.LDAP_SEARCH_SCOPE
|
||||
, objectClass: options.ldapSearchClass || env.LDAP_SEARCH_CLASS
|
||||
, loginField: options.ldapSearchLoginField || env.LDAP_SEARCH_LOGINFIELD
|
||||
dn: options.ldapSearchDn
|
||||
, scope: options.ldapSearchScope
|
||||
, objectClass: options.ldapSearchClass
|
||||
, loginField: options.ldapSearchLoginField
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -208,20 +212,19 @@ program
|
|||
.option('-p, --port <port>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, 7120)
|
||||
, process.env.PORT || 7120)
|
||||
.option('-s, --secret <secret>'
|
||||
, 'secret (or $SECRET)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.SECRET)
|
||||
.option('-i, --ssid <ssid>'
|
||||
, 'session SSID (or $SSID)'
|
||||
, String
|
||||
, 'ssid')
|
||||
, process.env.SSID || 'ssid')
|
||||
.option('-a, --app-url <url>'
|
||||
, 'URL to app'
|
||||
, String)
|
||||
.action(function(options) {
|
||||
var env = process.env
|
||||
|
||||
if (!options.secret) {
|
||||
this.missingArgument('--secret')
|
||||
}
|
||||
|
@ -230,9 +233,9 @@ program
|
|||
}
|
||||
|
||||
require('./roles/auth/mock')({
|
||||
port: env.PORT || options.port
|
||||
, secret: options.secret || env.SECRET
|
||||
, ssid: options.ssid || env.SSID
|
||||
port: options.port
|
||||
, secret: options.secret
|
||||
, ssid: options.ssid
|
||||
, appUrl: options.appUrl
|
||||
})
|
||||
})
|
||||
|
@ -282,20 +285,19 @@ program
|
|||
.option('-p, --port <port>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, 7100)
|
||||
, process.env.PORT || 7100)
|
||||
.option('-s, --secret <secret>'
|
||||
, 'secret (or $SECRET)'
|
||||
, String)
|
||||
, String
|
||||
, process.env.SECRET)
|
||||
.option('-i, --ssid <ssid>'
|
||||
, 'session SSID (or $SSID)'
|
||||
, String
|
||||
, 'ssid')
|
||||
, process.env.SSID || 'ssid')
|
||||
.option('-a, --auth-url <url>'
|
||||
, 'URL to auth client'
|
||||
, String)
|
||||
.action(function(options) {
|
||||
var env = process.env
|
||||
|
||||
if (!options.secret) {
|
||||
this.missingArgument('--secret')
|
||||
}
|
||||
|
@ -304,9 +306,9 @@ program
|
|||
}
|
||||
|
||||
require('./roles/app')({
|
||||
port: env.PORT || options.port
|
||||
, secret: options.secret || env.SECRET
|
||||
, ssid: options.ssid || env.SSID
|
||||
port: options.port
|
||||
, secret: options.secret
|
||||
, ssid: options.ssid
|
||||
, authUrl: options.authUrl
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue