@@ -2,7 +2,7 @@ import * as k8s from '@kubernetes/client-node'
22import * as fs from 'fs'
33import * as yaml from 'js-yaml'
44import * as core from '@actions/core'
5- import { Mount } from 'hooklib'
5+ import { ServiceContainerInfo , Mount } from 'hooklib'
66import * as path from 'path'
77import { v1 as uuidv4 } from 'uuid'
88import { POD_VOLUME_NAME } from './index'
@@ -160,14 +160,28 @@ exec ${environmentPrefix} ${entryPoint} ${
160160 }
161161}
162162
163- export function generateContainerName ( image : string ) : string {
163+ export function generateContainerName ( service : ServiceContainerInfo ) : string {
164+ const image = service . image
164165 const nameWithTag = image . split ( '/' ) . pop ( )
165- const name = nameWithTag ?. split ( ':' ) . at ( 0 )
166+ let name = nameWithTag ?. split ( ':' ) . at ( 0 )
166167
167168 if ( ! name ) {
168169 throw new Error ( `Image definition '${ image } ' is invalid` )
169170 }
170171
172+ if ( service . createOptions ) {
173+ const optionsArr = service . createOptions . split ( / [ ] + / )
174+ for ( let i = 0 ; i < optionsArr . length ; i ++ ) {
175+ if ( optionsArr [ i ] === '--name' ) {
176+ if ( i + 1 >= optionsArr . length ) {
177+ throw new Error ( `Invalid create options: ${ service . createOptions } (missing a value after --name)` )
178+ }
179+ name = optionsArr [ ++ i ]
180+ core . debug ( `Overriding service container name with: ${ name } ` )
181+ }
182+ }
183+ }
184+
171185 return name
172186}
173187
0 commit comments