async function promoteCanary()

in src/actions/promote.ts [61:142]


async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
   let includeServices = false

   const manifestFilesForDeployment: string[] = updateManifestFiles(manifests)

   const trafficSplitMethod = parseTrafficSplitMethod(
      core.getInput('traffic-split-method', {required: true})
   )
   let promoteResult: DeployResult
   let filesToAnnotate: string[]
   if (trafficSplitMethod == TrafficSplitMethod.SMI) {
      includeServices = true

      // In case of SMI traffic split strategy when deployment is promoted, first we will redirect traffic to
      // canary deployment, then update stable deployment and then redirect traffic to stable deployment
      core.startGroup('Redirecting traffic to canary deployment')
      await SMICanaryDeploymentHelper.redirectTrafficToCanaryDeployment(
         kubectl,
         manifests
      )
      core.endGroup()

      core.startGroup(
         'Deploying input manifests with SMI canary strategy from promote'
      )

      promoteResult = await SMICanaryDeploymentHelper.deploySMICanary(
         manifestFilesForDeployment,
         kubectl,
         true
      )

      core.endGroup()

      core.startGroup('Redirecting traffic to stable deployment')
      const stableRedirectManifests =
         await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment(
            kubectl,
            manifests
         )

      filesToAnnotate = promoteResult.manifestFiles.concat(
         stableRedirectManifests
      )

      core.endGroup()
   } else {
      core.startGroup('Deploying input manifests from promote')
      promoteResult = await PodCanaryHelper.deployPodCanary(
         manifestFilesForDeployment,
         kubectl,
         true
      )
      filesToAnnotate = promoteResult.manifestFiles
      core.endGroup()
   }

   core.startGroup('Deleting canary and baseline workloads')
   try {
      await canaryDeploymentHelper.deleteCanaryDeployment(
         kubectl,
         manifests,
         includeServices
      )
   } catch (ex) {
      core.warning(
         `Exception occurred while deleting canary and baseline workloads: ${ex}`
      )
   }
   core.endGroup()

   // annotate resources
   core.startGroup('Annotating resources')
   const resources: Resource[] = getResources(
      filesToAnnotate,
      models.DEPLOYMENT_TYPES.concat([
         models.DiscoveryAndLoadBalancerResource.SERVICE
      ])
   )
   await annotateAndLabelResources(filesToAnnotate, kubectl, resources)
   core.endGroup()
}