@@ -67,31 +67,25 @@ export async function deleteObjects(
67
67
// other common functions
68
68
export function getManifestObjects ( filePaths : string [ ] ) : BlueGreenManifests {
69
69
const deploymentEntityList : K8sObject [ ] = [ ]
70
+ const serviceEntityList : K8sObject [ ] = [ ]
70
71
const routedServiceEntityList : K8sObject [ ] = [ ]
71
72
const unroutedServiceEntityList : K8sObject [ ] = [ ]
72
73
const ingressEntityList : K8sObject [ ] = [ ]
73
74
const otherEntitiesList : K8sObject [ ] = [ ]
74
75
const serviceNameMap = new Map < string , string > ( )
75
76
77
+ // Manifest objects per type. All resources should be parsed and
78
+ // organized before we can check if services are “routed” or not.
76
79
filePaths . forEach ( ( filePath : string ) => {
77
80
const fileContents = fs . readFileSync ( filePath ) . toString ( )
78
81
yaml . safeLoadAll ( fileContents , ( inputObject ) => {
79
82
if ( ! ! inputObject ) {
80
83
const kind = inputObject . kind
81
- const name = inputObject . metadata . name
82
84
83
85
if ( isDeploymentEntity ( kind ) ) {
84
86
deploymentEntityList . push ( inputObject )
85
87
} 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 )
95
89
} else if ( isIngressEntity ( kind ) ) {
96
90
ingressEntityList . push ( inputObject )
97
91
} else {
@@ -101,6 +95,16 @@ export function getManifestObjects(filePaths: string[]): BlueGreenManifests {
101
95
} )
102
96
} )
103
97
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
+
104
108
return {
105
109
serviceEntityList : routedServiceEntityList ,
106
110
serviceNameMap : serviceNameMap ,
0 commit comments