in src/strategyHelpers/deploymentHelper.ts [40:107]
export async function deployManifests(
files: string[],
deploymentStrategy: DeploymentStrategy,
kubectl: Kubectl,
trafficSplitMethod: TrafficSplitMethod
): Promise<string[]> {
switch (deploymentStrategy) {
case DeploymentStrategy.CANARY: {
const canaryDeployResult: DeployResult =
trafficSplitMethod == TrafficSplitMethod.SMI
? await deploySMICanary(files, kubectl)
: await deployPodCanary(files, kubectl)
checkForErrors([canaryDeployResult.execResult])
return canaryDeployResult.manifestFiles
}
case DeploymentStrategy.BLUE_GREEN: {
const routeStrategy = parseRouteStrategy(
core.getInput('route-method', {required: true})
)
const blueGreenDeployment = await deployBlueGreen(
kubectl,
files,
routeStrategy
)
core.debug(
`objects deployed for ${routeStrategy}: ${JSON.stringify(
blueGreenDeployment.objects
)} `
)
checkForErrors([blueGreenDeployment.deployResult.execResult])
const deployedManifestFiles =
blueGreenDeployment.deployResult.manifestFiles
core.debug(
`from blue-green service, deployed manifest files are ${deployedManifestFiles}`
)
return deployedManifestFiles
}
case DeploymentStrategy.BASIC: {
const trafficSplitMethod = parseTrafficSplitMethod(
core.getInput('traffic-split-method', {required: true})
)
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
if (trafficSplitMethod === TrafficSplitMethod.SMI) {
const updatedManifests = appendStableVersionLabelToResource(files)
const result = await kubectl.apply(
updatedManifests,
forceDeployment
)
checkForErrors([result])
} else {
const result = await kubectl.apply(files, forceDeployment)
checkForErrors([result])
}
return files
}
default: {
throw new Error('Deployment strategy is not recognized.')
}
}
}