Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const apiVersion = process.env[PropertyEnv.APIVERSION] || config.get('runtime.apiversion') || properties.get(PropertyKey.APIVERSION) || PropertyDefault.APIVERSION
if (flags.all || flags.apiversion) {
data.push({ Property: PropertyGet.flags.apiversion.description, Value: apiVersion })
}
const cert = config.get('runtime.cert') || properties.get(PropertyKey.CERT) || PropertyDefault.CERT
if (flags.all || flags.cert) {
data.push({ Property: PropertyGet.flags.cert.description, Value: cert })
}
const key = config.get('runtime.key') || properties.get(PropertyKey.KEY) || PropertyDefault.KEY
if (flags.all || flags.key) {
data.push({ Property: PropertyGet.flags.key.description, Value: key })
}
const namespace = process.env[PropertyEnv.NAMESPACE] || config.get('runtime.namespace') || properties.get(PropertyKey.NAMESPACE) || PropertyDefault.NAMESPACE
if (flags.all || flags.namespace) {
data.push({ Property: PropertyGet.flags.namespace.description, Value: namespace })
}
if (flags.all || flags.cliversion) {
data.push({ Property: PropertyGet.flags.cliversion.description, Value: this.config.userAgent })
}
// to get apibuild and apibuildno, we need to do a server call
if (flags.all || flags.apibuild || flags.apibuildno) {
const uri = `${apiHost}/api/${apiVersion}`
let result = { build: 'error', buildno: 'error' }
try {
debug(`Getting data from url ${uri} ...\n`)
async wsk () {
const { flags } = this.parse(this.constructor)
const properties = propertiesFile()
const options = {
cert: flags.cert || config.get('runtime.cert') || properties.get('CERT'),
key: flags.key || config.get('runtime.key') || properties.get('KEY'),
apiversion: flags.apiversion || config.get('runtime.apiversion') || properties.get('APIVERSION') || PropertyDefault.APIVERSION,
apihost: flags.apihost || config.get('runtime.apihost') || properties.get('APIHOST') || PropertyDefault.APIHOST,
namespace: config.get('runtime.namespace') || properties.get('NAMESPACE'),
api_key: flags.auth || config.get('runtime.auth') || properties.get('AUTH'),
ignore_certs: flags.insecure || config.get('runtime.insecure')
}
// remove any null or undefined keys
Object
.keys(options)
.forEach((key) => {
if (options[key] === null || options[key] === undefined) {
delete options[key]
}
})
async wsk () {
const { flags } = this.parse(this.constructor)
const properties = propertiesFile()
const options = {
cert: flags.cert || config.get('runtime.cert') || properties.get('CERT'),
key: flags.key || config.get('runtime.key') || properties.get('KEY'),
apiversion: flags.apiversion || config.get('runtime.apiversion') || properties.get('APIVERSION') || PropertyDefault.APIVERSION,
apihost: flags.apihost || config.get('runtime.apihost') || properties.get('APIHOST') || PropertyDefault.APIHOST,
namespace: config.get('runtime.namespace') || properties.get('NAMESPACE'),
api_key: flags.auth || config.get('runtime.auth') || properties.get('AUTH'),
ignore_certs: flags.insecure || config.get('runtime.insecure')
}
// remove any null or undefined keys
Object
.keys(options)
.forEach((key) => {
if (options[key] === null || options[key] === undefined) {
delete options[key]
}
})
debug(options)
if (!(options.apihost).toString().trim()) {
throw new Error('An API host must be specified')
}
const data = []
const properties = propertiesFile()
// get property data
const auth = process.env[PropertyEnv.AUTH] || config.get('runtime.auth') || properties.get(PropertyKey.AUTH) || PropertyDefault.AUTH
if (flags.all || flags.auth) {
data.push({ Property: PropertyGet.flags.auth.description, Value: auth })
}
const apiHost = process.env[PropertyEnv.APIHOST] || config.get('runtime.apihost') || properties.get(PropertyKey.APIHOST) || PropertyDefault.APIHOST
if (flags.all || flags.apihost) {
data.push({ Property: PropertyGet.flags.apihost.description, Value: apiHost })
}
const apiVersion = process.env[PropertyEnv.APIVERSION] || config.get('runtime.apiversion') || properties.get(PropertyKey.APIVERSION) || PropertyDefault.APIVERSION
if (flags.all || flags.apiversion) {
data.push({ Property: PropertyGet.flags.apiversion.description, Value: apiVersion })
}
const cert = config.get('runtime.cert') || properties.get(PropertyKey.CERT) || PropertyDefault.CERT
if (flags.all || flags.cert) {
data.push({ Property: PropertyGet.flags.cert.description, Value: cert })
}
const key = config.get('runtime.key') || properties.get(PropertyKey.KEY) || PropertyDefault.KEY
if (flags.all || flags.key) {
data.push({ Property: PropertyGet.flags.key.description, Value: key })
}
const namespace = process.env[PropertyEnv.NAMESPACE] || config.get('runtime.namespace') || properties.get(PropertyKey.NAMESPACE) || PropertyDefault.NAMESPACE
if (flags.all || flags.namespace) {
async wsk () {
const { flags } = this.parse(this.constructor)
const properties = propertiesFile()
const options = {
cert: flags.cert || config.get('runtime.cert') || properties.get('CERT'),
key: flags.key || config.get('runtime.key') || properties.get('KEY'),
apiversion: flags.apiversion || config.get('runtime.apiversion') || properties.get('APIVERSION') || PropertyDefault.APIVERSION,
apihost: flags.apihost || config.get('runtime.apihost') || properties.get('APIHOST') || PropertyDefault.APIHOST,
namespace: config.get('runtime.namespace') || properties.get('NAMESPACE'),
api_key: flags.auth || config.get('runtime.auth') || properties.get('AUTH'),
ignore_certs: flags.insecure || config.get('runtime.insecure')
}
// remove any null or undefined keys
Object
.keys(options)
.forEach((key) => {
if (options[key] === null || options[key] === undefined) {
delete options[key]
}
})
async wsk () {
const { flags } = this.parse(this.constructor)
const properties = propertiesFile()
const options = {
cert: flags.cert || config.get('runtime.cert') || properties.get('CERT'),
key: flags.key || config.get('runtime.key') || properties.get('KEY'),
apiversion: flags.apiversion || config.get('runtime.apiversion') || properties.get('APIVERSION') || PropertyDefault.APIVERSION,
apihost: flags.apihost || config.get('runtime.apihost') || properties.get('APIHOST') || PropertyDefault.APIHOST,
namespace: config.get('runtime.namespace') || properties.get('NAMESPACE'),
api_key: flags.auth || config.get('runtime.auth') || properties.get('AUTH'),
ignore_certs: flags.insecure || config.get('runtime.insecure')
}
// remove any null or undefined keys
Object
.keys(options)
.forEach((key) => {
if (options[key] === null || options[key] === undefined) {
delete options[key]
}
})
debug(options)
if (!(options.apihost).toString().trim()) {
async wsk () {
const { flags } = this.parse(this.constructor)
const properties = propertiesFile()
const options = {
cert: flags.cert || config.get('runtime.cert') || properties.get('CERT'),
key: flags.key || config.get('runtime.key') || properties.get('KEY'),
apiversion: flags.apiversion || config.get('runtime.apiversion') || properties.get('APIVERSION') || PropertyDefault.APIVERSION,
apihost: flags.apihost || config.get('runtime.apihost') || properties.get('APIHOST') || PropertyDefault.APIHOST,
namespace: config.get('runtime.namespace') || properties.get('NAMESPACE'),
api_key: flags.auth || config.get('runtime.auth') || properties.get('AUTH'),
ignore_certs: flags.insecure || config.get('runtime.insecure')
}
// remove any null or undefined keys
Object
.keys(options)
.forEach((key) => {
if (options[key] === null || options[key] === undefined) {
delete options[key]
}
})
debug(options)
async wsk () {
const { flags } = this.parse(this.constructor)
const properties = propertiesFile()
const options = {
cert: flags.cert || config.get('runtime.cert') || properties.get('CERT'),
key: flags.key || config.get('runtime.key') || properties.get('KEY'),
apiversion: flags.apiversion || config.get('runtime.apiversion') || properties.get('APIVERSION') || PropertyDefault.APIVERSION,
apihost: flags.apihost || config.get('runtime.apihost') || properties.get('APIHOST') || PropertyDefault.APIHOST,
namespace: config.get('runtime.namespace') || properties.get('NAMESPACE'),
api_key: flags.auth || config.get('runtime.auth') || properties.get('AUTH'),
ignore_certs: flags.insecure || config.get('runtime.insecure')
}
// remove any null or undefined keys
Object
.keys(options)
.forEach((key) => {
if (options[key] === null || options[key] === undefined) {
delete options[key]
}
})
debug(options)
function propertiesFile () {
let properties = { get: () => null }
const wskConfigFile = process.env[PropertyEnv.CONFIG_FILE] || config.get('runtime.config_file') || PropertyDefault.CONFIG_FILE
if (fs.existsSync(wskConfigFile)) {
properties = PropertiesReader(wskConfigFile)
}
properties.save = function () {
const saved = []
this.each((key, val) => saved.push(`${key}=${val}`))
fs.writeFileSync(wskConfigFile, saved.join('\n'))
}
return properties
}
const auth = process.env[PropertyEnv.AUTH] || config.get('runtime.auth') || properties.get(PropertyKey.AUTH) || PropertyDefault.AUTH
if (flags.all || flags.auth) {
data.push({ Property: PropertyGet.flags.auth.description, Value: auth })
}
const apiHost = process.env[PropertyEnv.APIHOST] || config.get('runtime.apihost') || properties.get(PropertyKey.APIHOST) || PropertyDefault.APIHOST
if (flags.all || flags.apihost) {
data.push({ Property: PropertyGet.flags.apihost.description, Value: apiHost })
}
const apiVersion = process.env[PropertyEnv.APIVERSION] || config.get('runtime.apiversion') || properties.get(PropertyKey.APIVERSION) || PropertyDefault.APIVERSION
if (flags.all || flags.apiversion) {
data.push({ Property: PropertyGet.flags.apiversion.description, Value: apiVersion })
}
const cert = config.get('runtime.cert') || properties.get(PropertyKey.CERT) || PropertyDefault.CERT
if (flags.all || flags.cert) {
data.push({ Property: PropertyGet.flags.cert.description, Value: cert })
}
const key = config.get('runtime.key') || properties.get(PropertyKey.KEY) || PropertyDefault.KEY
if (flags.all || flags.key) {
data.push({ Property: PropertyGet.flags.key.description, Value: key })
}
const namespace = process.env[PropertyEnv.NAMESPACE] || config.get('runtime.namespace') || properties.get(PropertyKey.NAMESPACE) || PropertyDefault.NAMESPACE
if (flags.all || flags.namespace) {
data.push({ Property: PropertyGet.flags.namespace.description, Value: namespace })
}
if (flags.all || flags.cliversion) {
data.push({ Property: PropertyGet.flags.cliversion.description, Value: this.config.userAgent })