import { Container } from "../kuberesources.objectmodel" ; import { PodSummary } from "../extension" ; import { ClusterExplorerResourceNode } from "../components/clusterexplorer/node" ; export interface ContainerContainer { readonly kindName : string ; readonly namespace : string | undefined ; readonly containers ? : Container [ ] ; readonly containersQueryPath : string ; } export module ContainerContainer { export function fromNode ( explorerNode ) { const queryPath = containersQueryPath ( explorerNode ) ; if ( ! queryPath ) { return undefined ; } return { kindName : explorerNode . kindName , namespace : explorerNode . namespace || undefined , containersQueryPath : queryPath } ; } export function fromPod ( pod ) { return { kindName : `pod/${ pod . name }` , namespace : pod . namespace || undefined , containers : pod . spec ? pod . spec . containers : undefined , containersQueryPath : '.spec' } ; } function containersQueryPath ( explorerNode ) { const kind = explorerNode . kind . abbreviation ; switch ( kind ) { case 'pod' : return '.spec' ; case 'job' : return '.spec.template.spec' ; default : return undefined ; } } }