Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
entity.kind = kind.value
}
if (verb === 'list' && entity.name) {
//
// then this is the .map(addPrettyName) part of a list result
//
if (!entity.onclick) {
// a postprocess handler might have already added an onclick handler
entity.onclick = `wsk ${entity.type} get ${REPL.encodeComponent(`/${entity.namespace}/${entity.name}`)}`
}
if (entity.type === 'actions' && entity.prettyType === 'sequence') {
// add a fun a->b->c rendering of the sequence
const action = REPL.qexec(`wsk action get "/${entity.namespace}/${entity.name}"`)
const ns = REPL.qexec('wsk namespace current')
entity.prettyVersion = await action.then(async action => {
if (action.exec && action.exec.components) {
const nsPattern = new RegExp('^/' + (await ns) + '/')
return action.exec.components
.map(_ => _.replace(nsPattern, '')) // remove the namespace, to keep it a bit shorter
.join(' \u27f6 ')
// ^^^^^^ this is a unicode ->
}
})
} else if (entity.type === 'rules') {
// rule-specific cells
const rule = REPL.qexec(`wsk rule get "/${entity.namespace}/${entity.name}"`)
entity.status = rule.then(rule => rule.status)
entity.prettyVersion = await rule.then(rule => `${rule.trigger.name} \u27fc ${rule.action.name}`)
postprocess: ({ apidoc }) => {
const { basePath } = apidoc
const path = Object.keys(apidoc.paths)[0]
const api = apidoc.paths[path]
const verb = Object.keys(api)[0]
const { action: name, namespace } = api[verb]['x-openwhisk']
// manufacture an entity-like object
return REPL.qexec(`wsk action get "/${namespace}/${name}"`).then(action =>
Object.assign(action, {
name,
namespace,
packageName: `${verb} ${basePath}${path}`
})
)
}
}
debug('error installing istio CRDs', err.code, err)
if (err.code === 409) {
debug('already exists... that should be ok')
} else {
throw err
}
} */
debug('installing service account')
// service account
// helm https://raw.githubusercontent.com/istio/istio/1.0.6/install/kubernetes/helm/helm-service-account.yaml
// helm init --service-account tiller
debug('installing charts')
const chart = join(installDir, 'install/kubernetes/helm/istio')
return REPL.qexec(
`helm install ${chart} --name istio --namespace istio-system --set grafana.enabled=true --set tracing.enabled=true`
)
}
auth: AUTH
})
} catch (err) {
reject(err)
}
}
})
)
} else if (options.apiHost && options.auth) {
// specified on command line
return options
} else if ((options.apiHost && !options.auth) || (!options.apiHost && options.auth)) {
throw new Error('Please specify both --apiHost and --auth')
} else {
// use the global settings
const [apiHost, auth] = await Promise.all([REPL.qexec('wsk host get'), REPL.qexec('wsk auth get')])
return { apiHost, auth }
}
}
export const lt = options =>
REPL.qexec(`wsk action get "${options.url}"`)
.then(generateScriptForAction(options))
.catch(generateScriptForURL(options))
.then(_lt(options))
const ingressFor = (appName: string): Promise => {
return REPL.qexec(`istio ingress "${appName}"`)
}
direct: (tab: UI.Tab, entity: { name: string }) =>
REPL.qexec(
`${mode} ${optionsToString(options)}${
entity && entity.name ? ' ' + entity.name : options.name ? ' ' + options.name : ''
}`
)
})
Promise.all(activations.map(activation => REPL.qexec(`wsk activation get ${activation.activationId}`))).then(
activations => activations.filter(activation => !activation['response'].success)
const describe = async ({ command, parsedOptions, execOptions }: Commands.Arguments) => {
const noDelegationPlease = Object.assign({}, execOptions, { noDelegation: true })
delete noDelegationPlease.delegationOk
const getCmd = command.replace(/summary/, 'get').replace(/(-o|--output)[= ](yaml|json)/, '')
const summaryCmd = command.replace(/get/, 'summary').replace(/(-o|--output)[= ](yaml|json)/, '')
debug('summaryCmd', summaryCmd)
debug('getCmd', getCmd)
const [resource, summary] = await Promise.all([
REPL.qexec(getCmd, undefined, undefined, Object.assign({ raw: true }, noDelegationPlease)) as Promise,
REPL.qexec(`${getCmd} -o wide`, undefined, undefined, noDelegationPlease).then(toMap)
])
debug('resource', resource)
debug('summary', summary)
return renderDescribe(command, getCmd, summaryCmd, resource, summary, parsedOptions)
}
cell.onmouseenter = evt => {
const win = this.gridGrid.getBoundingClientRect()
const cell = evt.currentTarget as HTMLElement
if (win.right - evt.clientX < 80) {
cell.setAttribute('data-balloon-pos', 'up-right')
} else if (evt.clientX - win.left < 80) {
cell.setAttribute('data-balloon-pos', 'up-left')
}
if (cell.id && cell['isFailure'] && !cell['failureMessage']) {
REPL.qexec(`wsk activation get ${cell.id}`).then(({ response }: Activation) => {
if (response.result.error) {
const failureMessage =
typeof response.result.error === 'string'
? response.result.error
: response.result.error.error || response.result.error.message
cell['failureMessage'] = failureMessage
cell.setAttribute(
'data-balloon',
cell.getAttribute('data-balloon') + ` with: ${failureMessage.substring(0, 40)}`
)
}
})
}
}