export function getManifestObjects()

in src/strategyHelpers/blueGreen/blueGreenHelper.ts [68:120]


export function getManifestObjects(filePaths: string[]): BlueGreenManifests {
   const deploymentEntityList: K8sObject[] = []
   const serviceEntityList: K8sObject[] = []
   const routedServiceEntityList: K8sObject[] = []
   const unroutedServiceEntityList: K8sObject[] = []
   const ingressEntityList: K8sObject[] = []
   const otherEntitiesList: K8sObject[] = []
   const serviceNameMap = new Map<string, string>()

   // Manifest objects per type. All resources should be parsed and
   // organized before we can check if services are “routed” or not.
   filePaths.forEach((filePath: string) => {
      try {
         const fileContents = fs.readFileSync(filePath).toString()
         yaml.loadAll(fileContents, (inputObject: any) => {
            if (!!inputObject) {
               const kind = inputObject.kind
               if (isDeploymentEntity(kind)) {
                  deploymentEntityList.push(inputObject)
               } else if (isServiceEntity(kind)) {
                  serviceEntityList.push(inputObject)
               } else if (isIngressEntity(kind)) {
                  ingressEntityList.push(inputObject)
               } else {
                  otherEntitiesList.push(inputObject)
               }
            }
         })
      } catch (error) {
         core.error(`Error processing file ${filePath}: ${error.message}`)
         throw error
      }
   })

   serviceEntityList.forEach((inputObject: any) => {
      if (isServiceRouted(inputObject, deploymentEntityList)) {
         const name = inputObject.metadata.name
         routedServiceEntityList.push(inputObject)
         serviceNameMap.set(name, getBlueGreenResourceName(name, GREEN_SUFFIX))
      } else {
         unroutedServiceEntityList.push(inputObject)
      }
   })

   return {
      serviceEntityList: routedServiceEntityList,
      serviceNameMap: serviceNameMap,
      unroutedServiceEntityList: unroutedServiceEntityList,
      deploymentEntityList: deploymentEntityList,
      ingressEntityList: ingressEntityList,
      otherObjects: otherEntitiesList
   }
}