@@ -46,7 +46,7 @@ interface Cache {
4646 when : "on_success" | "on_failure" | "always" ;
4747}
4848
49- interface Service {
49+ export interface Service {
5050 name : string ;
5151 entrypoint : string [ ] | null ;
5252 command : string [ ] | null ;
@@ -1583,15 +1583,8 @@ If you know what you're doing and would like to suppress this warning, use one o
15831583 }
15841584 }
15851585
1586- const serviceAlias = service . alias ;
15871586 const serviceName = service . name ;
1588- const serviceNameWithoutVersion = serviceName . replace ( / ( .* ) ( : .* ) / , "$1" ) ;
1589- const aliases = new Set < string > ( ) ;
1590- aliases . add ( serviceNameWithoutVersion . replaceAll ( "/" , "-" ) ) ;
1591- aliases . add ( serviceNameWithoutVersion . replaceAll ( "/" , "__" ) ) ;
1592- if ( serviceAlias ) {
1593- aliases . add ( serviceAlias ) ;
1594- }
1587+ const aliases = Utils . getAllServiceAliases ( service ) ;
15951588
15961589 for ( const [ key , val ] of Object . entries ( expanded ) ) {
15971590 // Replacing `'` with `'\''` to correctly handle single quotes(if `val` contains `'`) in shell commands
@@ -1642,23 +1635,14 @@ If you know what you're doing and would like to suppress this warning, use one o
16421635 }
16431636
16441637 private async serviceHealthCheck ( writeStreams : WriteStreams , service : Service , serviceIndex : number , serviceContainerLogFile : string ) {
1645- const serviceAlias = service . alias ;
1638+ const serviceAlias = Utils . getServiceAlias ( service ) ;
16461639 const serviceName = service . name ;
16471640 const waitImageName = this . argv . waitImage ;
16481641 const waitForServicesTimeout = this . argv . waitForServicesTimeout ;
16491642
16501643 const { stdout} = await Utils . spawn ( [ this . argv . containerExecutable , "image" , "inspect" , serviceName ] ) ;
16511644 const imageInspect = JSON . parse ( stdout ) ;
16521645
1653- // Copied from the startService block. Important thing is that the aliases match
1654- const serviceNameWithoutVersion = serviceName . replace ( / ( .* ) ( : .* ) / , "$1" ) ;
1655- const aliases = [ serviceNameWithoutVersion . replaceAll ( "/" , "-" ) , serviceNameWithoutVersion . replaceAll ( "/" , "__" ) ] ;
1656- if ( serviceAlias ) {
1657- aliases . push ( serviceAlias ) ;
1658- }
1659-
1660- const uniqueAlias = aliases [ aliases . length - 1 ] ;
1661-
16621646 if ( ( imageInspect [ 0 ] ?. Config ?. ExposedPorts ?? null ) === null ) {
16631647 return writeStreams . stderr ( chalk `${ this . formattedJobName } {yellow Could not find exposed tcp ports ${ serviceName } }\n` ) ;
16641648 }
@@ -1670,7 +1654,7 @@ If you know what you're doing and would like to suppress this warning, use one o
16701654 if ( ! port . endsWith ( "/tcp" ) ) return ;
16711655 const portNum = parseInt ( port . replace ( "/tcp" , "" ) ) ;
16721656 const containerName = `gcl-wait-for-it-${ this . jobId } -${ serviceIndex } -${ portNum } ` ;
1673- const spawnCmd = [ this . argv . containerExecutable , "run" , "--rm" , `--name=${ containerName } ` , "--network" , `${ this . _serviceNetworkId } ` , `${ waitImageName } ` , `${ uniqueAlias } :${ portNum } ` , "-t" , `${ waitForServicesTimeout } ` ] ;
1657+ const spawnCmd = [ this . argv . containerExecutable , "run" , "--rm" , `--name=${ containerName } ` , "--network" , `${ this . _serviceNetworkId } ` , `${ waitImageName } ` , `${ serviceAlias } :${ portNum } ` , "-t" , `${ waitForServicesTimeout } ` ] ;
16741658 this . _containersToClean . push ( containerName ) ;
16751659 return Utils . spawn ( spawnCmd ) ;
16761660 } ) ) ;
0 commit comments