1import * as _ from 'lodash-es' 2import { AppsV1Api, V1Deployment } from '@kubernetes/client-node' 6export const getDockRegKubeResA = async ({dockReg}: {dockReg : string}) => { 9 const appsApi = kubeConfig.makeApiClient(AppsV1Api) 11 const doesMatch = ({image}: {image: string}) => _.includes(image, dockReg) 13 const deploymentsRes = await appsApi.listDeploymentForAllNamespaces() 15 const matchedResA = _.flatten([ 16 _.map(deploymentsRes.items, (deployment: V1Deployment) => { 17 const containers = _.get(deployment, 'spec.template.spec.containers', []) 18 const imageA = _.map(containers, 'image') 19 const hasMatchingImage = _.some(imageA, (image: string) => doesMatch({image})) 20 if (!hasMatchingImage) return 21 return {kind: 'Deployment', metadata: deployment.metadata, containers}