import { ModeRegistration , Tab } from '@kui-shell/core' ; import { KubeResource } from '@kui-shell/plugin-kubectl' ; import { getMetricConfig } from '../components/metric-config' ; async function getMetricsYaml ( args ) { const { dump } = await import ( 'js-yaml' ) ; const [ res ] = await Promise . all ( [ getMetricConfig ( args ) ] ) ; delete res [ 'originatingCommand' ] ; delete res [ 'kuiRawData' ] ; delete res [ 'isKubeResource' ] ; return dump ( res ) ; } function verifyMetricResponse ( resource ) { return resource . kind === 'Command' && resource . metadata . name === 'Metric Command' ; } const metricListMode = { when : verifyMetricResponse , mode : { mode : 'Metric List' , content : ( tab ) => import ( './MetricsUI' ) . then ( _ => _ . default ( tab ) ) } } ; const metricYamlMode = { when : verifyMetricResponse , mode : { mode : 'Metric Yaml' , label : 'Config Map' , content : getMetricsYaml , contentType : 'yaml' } } ; export { metricListMode , metricYamlMode } ;