in src/strategyHelpers/canary/smiCanaryHelper.ts [233:281]
async function adjustTraffic(
kubectl: Kubectl,
manifestFilePaths: string[],
stableWeight: number,
canaryWeight: number
) {
if (!manifestFilePaths || manifestFilePaths?.length == 0) {
return
}
const trafficSplitManifests = []
for (const filePath of manifestFilePaths) {
try {
const fileContents = fs.readFileSync(filePath).toString()
const parsedYaml: K8sObject[] = yaml.loadAll(
fileContents
) as K8sObject[]
for (const inputObject of parsedYaml) {
const name = inputObject.metadata.name
const kind = inputObject.kind
if (isServiceEntity(kind)) {
trafficSplitManifests.push(
await createTrafficSplitManifestFile(
kubectl,
name,
stableWeight,
0,
canaryWeight
)
)
}
}
} catch (error) {
core.error(`Failed to process file at ${filePath}: ${error.message}`)
throw error
}
}
if (trafficSplitManifests.length <= 0) {
return
}
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
const result = await kubectl.apply(trafficSplitManifests, forceDeployment)
checkForErrors([result])
return trafficSplitManifests
}