Skip to content

Commit e52890d

Browse files
authored
Fix “Service” route-method of the Blue-Green strategy with some manifest files (#283)
1 parent dd4bbd1 commit e52890d

File tree

3 files changed

+31
-219
lines changed

3 files changed

+31
-219
lines changed

package-lock.json

Lines changed: 16 additions & 208 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"@types/jest": "^26.0.0",
2525
"@types/js-yaml": "^3.12.7",
2626
"@types/node": "^12.20.41",
27+
"@vercel/ncc": "^0.36.1",
2728
"jest": "^26.0.0",
28-
"ncc": "^0.3.6",
2929
"prettier": "^2.7.1",
3030
"ts-jest": "^26.0.0",
3131
"typescript": "3.9.5"

src/strategyHelpers/blueGreen/blueGreenHelper.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,25 @@ export async function deleteObjects(
6767
// other common functions
6868
export function getManifestObjects(filePaths: string[]): BlueGreenManifests {
6969
const deploymentEntityList: K8sObject[] = []
70+
const serviceEntityList: K8sObject[] = []
7071
const routedServiceEntityList: K8sObject[] = []
7172
const unroutedServiceEntityList: K8sObject[] = []
7273
const ingressEntityList: K8sObject[] = []
7374
const otherEntitiesList: K8sObject[] = []
7475
const serviceNameMap = new Map<string, string>()
7576

77+
// Manifest objects per type. All resources should be parsed and
78+
// organized before we can check if services are “routed” or not.
7679
filePaths.forEach((filePath: string) => {
7780
const fileContents = fs.readFileSync(filePath).toString()
7881
yaml.safeLoadAll(fileContents, (inputObject) => {
7982
if (!!inputObject) {
8083
const kind = inputObject.kind
81-
const name = inputObject.metadata.name
8284

8385
if (isDeploymentEntity(kind)) {
8486
deploymentEntityList.push(inputObject)
8587
} else if (isServiceEntity(kind)) {
86-
if (isServiceRouted(inputObject, deploymentEntityList)) {
87-
routedServiceEntityList.push(inputObject)
88-
serviceNameMap.set(
89-
name,
90-
getBlueGreenResourceName(name, GREEN_SUFFIX)
91-
)
92-
} else {
93-
unroutedServiceEntityList.push(inputObject)
94-
}
88+
serviceEntityList.push(inputObject)
9589
} else if (isIngressEntity(kind)) {
9690
ingressEntityList.push(inputObject)
9791
} else {
@@ -101,6 +95,16 @@ export function getManifestObjects(filePaths: string[]): BlueGreenManifests {
10195
})
10296
})
10397

98+
serviceEntityList.forEach((inputObject: any) => {
99+
if (isServiceRouted(inputObject, deploymentEntityList)) {
100+
const name = inputObject.metadata.name
101+
routedServiceEntityList.push(inputObject)
102+
serviceNameMap.set(name, getBlueGreenResourceName(name, GREEN_SUFFIX))
103+
} else {
104+
unroutedServiceEntityList.push(inputObject)
105+
}
106+
})
107+
104108
return {
105109
serviceEntityList: routedServiceEntityList,
106110
serviceNameMap: serviceNameMap,

0 commit comments

Comments
 (0)