Skip to content

Commit 13fc9fa

Browse files
authored
Support profiles and services arguments on more compose commands (#247)
1 parent ec17857 commit 13fc9fa

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

packages/vscode-container-client/src/clients/DockerComposeClient/DockerComposeClient.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function withCommonOrchestratorArgs(options: CommonOrchestratorCommandOptions):
3333
withNamedArg('--file', options.files),
3434
withNamedArg('--env-file', options.environmentFile),
3535
withNamedArg('--project-name', options.projectName),
36+
withNamedArg('--profile', options.profiles),
3637
);
3738
}
3839

@@ -90,7 +91,6 @@ export class DockerComposeClient extends ConfigurableClient implements IContaine
9091
return composeArgs(
9192
withComposeArg(this.composeV2),
9293
withCommonOrchestratorArgs(options),
93-
withNamedArg('--profile', options.profiles),
9494
withArg('up'),
9595
withFlagArg('--detach', options.detached),
9696
withFlagArg('--build', options.build),
@@ -127,6 +127,7 @@ export class DockerComposeClient extends ConfigurableClient implements IContaine
127127
withFlagArg('--volumes', options.removeVolumes),
128128
withNamedArg('--timeout', options.timeoutSeconds?.toString(10)),
129129
withVerbatimArg(options.customOptions),
130+
withArg(...(options.services || [])),
130131
)();
131132
}
132133

@@ -151,6 +152,7 @@ export class DockerComposeClient extends ConfigurableClient implements IContaine
151152
withComposeArg(this.composeV2),
152153
withCommonOrchestratorArgs(options),
153154
withArg('start'),
155+
withArg(...(options.services || [])),
154156
)();
155157
}
156158

@@ -176,6 +178,7 @@ export class DockerComposeClient extends ConfigurableClient implements IContaine
176178
withCommonOrchestratorArgs(options),
177179
withArg('stop'),
178180
withNamedArg('--timeout', options.timeoutSeconds?.toString(10)),
181+
withArg(...(options.services || [])),
179182
)();
180183
}
181184

@@ -201,6 +204,7 @@ export class DockerComposeClient extends ConfigurableClient implements IContaine
201204
withCommonOrchestratorArgs(options),
202205
withArg('restart'),
203206
withNamedArg('--timeout', options.timeoutSeconds?.toString(10)),
207+
withArg(...(options.services || [])),
204208
)();
205209
}
206210

@@ -227,6 +231,7 @@ export class DockerComposeClient extends ConfigurableClient implements IContaine
227231
withArg('logs'),
228232
withFlagArg('--follow', options.follow),
229233
withNamedArg('--tail', options.tail?.toString(10)),
234+
withArg(...(options.services || [])),
230235
)();
231236
}
232237

packages/vscode-container-client/src/contracts/ContainerOrchestratorClient.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export type CommonOrchestratorCommandOptions = CommonCommandOptions & {
2121
* Project name
2222
*/
2323
projectName?: string;
24+
/**
25+
* Specific service profiles to start/stop/etc.
26+
*/
27+
profiles?: Array<string>;
2428
};
2529

2630
// Up command types
@@ -45,10 +49,6 @@ export type UpCommandOptions = CommonOrchestratorCommandOptions & {
4549
* Specific services to start
4650
*/
4751
services?: Array<string>;
48-
/**
49-
* Specific service profiles to start
50-
*/
51-
profiles?: Array<string>;
5252
/**
5353
* Override specific service scaling
5454
*/
@@ -81,6 +81,10 @@ export type DownCommandOptions = CommonOrchestratorCommandOptions & {
8181
* A timeout in seconds
8282
*/
8383
timeoutSeconds?: number;
84+
/**
85+
* Specific services to stop
86+
*/
87+
services?: Array<string>;
8488
/**
8589
* Additional custom options to pass
8690
*/
@@ -96,8 +100,12 @@ type DownCommand = {
96100
};
97101

98102
// Start command types
99-
// No special options
100-
export type StartCommandOptions = CommonOrchestratorCommandOptions;
103+
export type StartCommandOptions = CommonOrchestratorCommandOptions & {
104+
/**
105+
* Specific services to start
106+
*/
107+
services?: Array<string>;
108+
};
101109

102110
type StartCommand = {
103111
/**
@@ -113,6 +121,10 @@ export type StopCommandOptions = CommonOrchestratorCommandOptions & {
113121
* A timeout in seconds
114122
*/
115123
timeoutSeconds?: number;
124+
/**
125+
* Specific services to stop
126+
*/
127+
services?: Array<string>;
116128
};
117129

118130
type StopCommand = {
@@ -129,6 +141,10 @@ export type RestartCommandOptions = CommonOrchestratorCommandOptions & {
129141
* A timeout in seconds
130142
*/
131143
timeoutSeconds?: number;
144+
/**
145+
* Specific services to restart
146+
*/
147+
services?: Array<string>;
132148
};
133149

134150
type RestartCommand = {
@@ -149,6 +165,10 @@ export type LogsCommandOptions = CommonOrchestratorCommandOptions & {
149165
* Maximum number of lines to show from the end of the logs
150166
*/
151167
tail?: number;
168+
/**
169+
* Specific services to get logs for
170+
*/
171+
services?: Array<string>;
152172
};
153173

154174
type LogsCommand = {
@@ -160,7 +180,8 @@ type LogsCommand = {
160180
};
161181

162182
// Config command types
163-
export type ConfigCommandOptions = CommonOrchestratorCommandOptions & {
183+
// The `--profile` argument works, but has rather confusing results when used with the config command. Best to not support it.
184+
export type ConfigCommandOptions = Omit<CommonOrchestratorCommandOptions, 'profiles'> & {
164185
configType: 'services' | 'images' | 'profiles' | 'volumes';
165186
};
166187

0 commit comments

Comments
 (0)