@@ -23,30 +23,30 @@ export async function composeGroupLogs(context: IActionContext, node: ComposeGro
2323
2424 if ( ! workingDirectory ) {
2525 context . errorHandling . suppressReportIssue = true ;
26- throw new Error ( l10n . t ( 'Unable to determine compose project info for container group \'{0}\'.' , node . label ) ) ;
26+ throw new Error ( l10n . t ( 'Unable to determine compose project info for group \'{0}\'.' , getProjectLabel ( node ) ) ) ;
2727 }
2828
2929 const folder = workspace . getWorkspaceFolder ( Uri . file ( workingDirectory ) ) ?? Uri . file ( workingDirectory ) ;
3030
3131 const composeFilesString = options . files ?. map ( file => `-f "${ file } "` ) . join ( ' ' ) ;
3232 return selectComposeLogsCommand ( context , folder , composeFilesString , options . projectName , options . environmentFile ) ;
33- } , node , { follow : true , tail : 1000 } , 'logs' ) ;
33+ } , node , 'logs' , { follow : true , tail : 1000 } ) ;
3434}
3535
3636export async function composeGroupStart ( context : IActionContext , node : ComposeGroupNode ) : Promise < void > {
37- return composeGroup ( context , ( client , options ) => client . start ( options ) , node , undefined , 'start' ) ;
37+ return composeGroup ( context , ( client , options ) => client . start ( options ) , node , 'start' ) ;
3838}
3939
4040export async function composeGroupStop ( context : IActionContext , node : ComposeGroupNode ) : Promise < void > {
41- return composeGroup ( context , ( client , options ) => client . stop ( options ) , node , undefined , 'stop' ) ;
41+ return composeGroup ( context , ( client , options ) => client . stop ( options ) , node , 'stop' ) ;
4242}
4343
4444export async function composeGroupRestart ( context : IActionContext , node : ComposeGroupNode ) : Promise < void > {
45- return composeGroup ( context , ( client , options ) => client . restart ( options ) , node , undefined , 'restart' ) ;
45+ return composeGroup ( context , ( client , options ) => client . restart ( options ) , node , 'restart' ) ;
4646}
4747
4848export async function composeGroupDown ( context : IActionContext , node : ComposeGroupNode ) : Promise < void > {
49- return composeGroup ( context , ( client , options ) => client . down ( options ) , node , undefined , 'down' ) ;
49+ return composeGroup ( context , ( client , options ) => client . down ( options ) , node , 'down' ) ;
5050}
5151
5252type AdditionalOptions < TOptions extends CommonOrchestratorCommandOptions > = Omit < TOptions , keyof CommonOrchestratorCommandOptions > ;
@@ -55,8 +55,8 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
5555 context : IActionContext ,
5656 composeCommandCallback : ( client : IContainerOrchestratorClient , options : TOptions ) => Promise < VoidCommandResponse > ,
5757 node : ComposeGroupNode ,
58- additionalOptions ?: AdditionalOptions < TOptions > ,
59- commandName : string = '<command>'
58+ commandName : string = '<command>' ,
59+ additionalOptions ?: AdditionalOptions < TOptions >
6060) : Promise < void > {
6161 if ( ! node ) {
6262 await ext . containersTree . refresh ( context ) ;
@@ -75,7 +75,7 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
7575
7676 if ( ! workingDirectory || ! orchestratorFiles || ! projectName ) {
7777 context . errorHandling . suppressReportIssue = true ;
78- throw new Error ( l10n . t ( 'Unable to determine compose project info for container group \'{0}\'.' , node . label ) ) ;
78+ throw new Error ( l10n . t ( 'Unable to determine compose project info for group \'{0}\'.' , getProjectLabel ( node ) ) ) ;
7979 }
8080
8181 let profileArg : string [ ] | undefined ;
@@ -130,7 +130,16 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
130130 * parsing, so we can still locate a container in the group from the list labels, but we
131131 * must `inspect` it to recover the accurate, verbatim label values (compose files, etc).
132132 */
133- async function getComposeGroupLabels ( node : ComposeGroupNode ) : Promise < { [ key : string ] : string } | undefined > {
133+ // Exported only for unit testing; not intended to be called outside this module.
134+ export function getProjectLabel ( node : ComposeGroupNode ) : string {
135+ if ( node instanceof ComposeProfileGroupTreeItem && node . parent ?. label ) {
136+ return node . parent . label ;
137+ }
138+ return node . label ;
139+ }
140+
141+ // Exported only for unit testing; not intended to be called outside this module.
142+ export function findContainerWithComposeConfig ( node : ComposeGroupNode ) : ContainerTreeItem | undefined {
134143 // Find a container in the group that carries the compose project config files label.
135144 // For ComposeProfileGroupTreeItem the direct children are ContainerTreeItem instances.
136145 // For ContainerGroupTreeItem with profile sub-groups the direct children may be
@@ -151,6 +160,11 @@ async function getComposeGroupLabels(node: ComposeGroupNode): Promise<{ [key: st
151160 }
152161 }
153162
163+ return container ;
164+ }
165+
166+ async function getComposeGroupLabels ( node : ComposeGroupNode ) : Promise < { [ key : string ] : string } | undefined > {
167+ const container = findContainerWithComposeConfig ( node ) ;
154168 if ( ! container ) {
155169 return undefined ;
156170 }
0 commit comments