import { Arguments , Registrar } from '@kui-shell/core' ; import { doHelp , doExecWithPty , getNamespaceForArgv , KubeOptions } from '@kui-shell/plugin-kubectl' ; import isUsage from './usage' ; import doExecWithStdout from './exec' ; const name = /^NAME:\s+([\w-]+)/ ; async function doInstall ( args ) { if ( isUsage ( args , 'install' ) ) { return doHelp ( 'helm' , args ) ; } else if ( /[\n;&]/ . test ( args . command ) ) { return doExecWithPty ( args , undefined , 'helm' ) ; } try { const response = await doExecWithStdout ( args ) ; const releaseName = response . match ( name ) [ 1 ] ; return args . REPL . qexec ( `helm status ${ args . REPL . encodeComponent ( releaseName ) } ${ getNamespaceForArgv ( args ) }` ) . catch ( err => { console . error ( 'error in helm get for helm install' , err ) ; return response ; } ) ; } catch ( err ) { if ( /still in use/ . test ( err . message ) ) { err [ 'code' ] = 409 ; err [ 'statusCode' ] = 409 ; } throw err ; } } export default ( registrar ) => { registrar . listen ( '/helm/install' , doInstall ) ; } ;