import { Arguments } from '@kui-shell/core' ; import { KubeResource , KubeItems } from '@kui-shell/plugin-kubectl' ; export default class GetKubeInfo { private rawOutput = '' ; public async getNamespace ( args ) { return ( await args . REPL . qexec < KubeItems < KubeResource > > ( `kubectl get ns -o json` ) ) . items . map ( ns => ns . metadata . name ) . map ( ( name , i ) => ( { id : `ns-${ i }` , text : name } ) ) ; } public async getSvc ( ns , args ) { return ( await args . REPL . qexec < KubeItems < KubeResource > > ( `kubectl get svc -n ${ ns } -o yaml` ) ) . items . map ( svc => svc . metadata . name ) . map ( ( name , i ) => ( { id : `svc-${ i }` , text : name } ) ) ; } public async getDeployment ( ns , svc , args ) { return ( await args . REPL . qexec < KubeItems < KubeResource > > ( `kubectl get deployments -n ${ ns } -o yaml` ) ) . items . map ( d => d . metadata . name ) . map ( ( name , i ) => ( { id : `d-${ i }` , text : name } ) ) ; } }