@@ -119,11 +119,12 @@ export async function prepareJob(
119119 throw new Error ( `failed to determine if the pod is alpine: ${ message } ` )
120120 }
121121 core . debug ( `Setting isAlpine to ${ isAlpine } ` )
122- generateResponseFile ( responseFile , createdPod , isAlpine )
122+ generateResponseFile ( responseFile , args , createdPod , isAlpine )
123123}
124124
125125function generateResponseFile (
126126 responseFile : string ,
127+ args : PrepareJobArgs ,
127128 appPod : k8s . V1Pod ,
128129 isAlpine
129130) : void {
@@ -156,24 +157,27 @@ function generateResponseFile(
156157 }
157158 }
158159
159- const serviceContainers = appPod . spec ?. containers . filter (
160- c => c . name !== JOB_CONTAINER_NAME
161- )
162- if ( serviceContainers ?. length ) {
163- response . context [ 'services' ] = serviceContainers . map ( c => {
164- const ctxPorts : ContextPorts = { }
165- if ( c . ports ?. length ) {
166- for ( const port of c . ports ) {
167- ctxPorts [ port . containerPort ] = port . hostPort
160+ if ( args . services ?. length ) {
161+ const serviceContainerNames =
162+ args . services ?. map ( s => generateContainerName ( s . image ) ) || [ ]
163+
164+ response . context [ 'services' ] = appPod ?. spec ?. containers
165+ ?. filter ( c => serviceContainerNames . includes ( c . name ) )
166+ . map ( c => {
167+ const ctxPorts : ContextPorts = { }
168+ if ( c . ports ?. length ) {
169+ for ( const port of c . ports ) {
170+ ctxPorts [ port . containerPort ] = port . hostPort
171+ }
168172 }
169- }
170173
171- return {
172- image : c . image ,
173- ports : ctxPorts
174- }
175- } )
174+ return {
175+ image : c . image ,
176+ ports : ctxPorts
177+ }
178+ } )
176179 }
180+
177181 writeToResponseFile ( responseFile , JSON . stringify ( response ) )
178182}
179183
0 commit comments