Skip to content

Commit

Permalink
Add profile support to Docker Compose down task definition
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoZhou committed Feb 20, 2025
1 parent 931659c commit 7528ba1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,13 @@
"description": "%vscode-docker.tasks.docker-compose.dockerCompose.down.removeVolumes%",
"default": false
},
"profiles": {
"type": "array",
"description": "%vscode-docker.tasks.docker-compose.dockerCompose.down.profiles%",
"items": {
"type": "string"
}
},
"customOptions": {
"type": "string",
"description": "%vscode-docker.tasks.docker-compose.dockerCompose.down.customOptions%"
Expand Down Expand Up @@ -1821,7 +1828,7 @@
"default": [
{
"label": "Compose Down",
"template": "${composeCommand} ${profileList} ${configurationFile} down"
"template": "${composeCommand} ${configurationFile} down"
}
],
"description": "%vscode-docker.config.template.composeDown.description%"
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"vscode-docker.tasks.docker-compose.dockerCompose.down.description": "Options for the `docker-compose down` command.",
"vscode-docker.tasks.docker-compose.dockerCompose.down.removeImages": "Images to remove.",
"vscode-docker.tasks.docker-compose.dockerCompose.down.removeVolumes": "Whether or not to remove named and anonymous volumes.",
"vscode-docker.tasks.docker-compose.dockerCompose.down.profiles": "A subset of profiles to stop and remove.",
"vscode-docker.tasks.docker-compose.dockerCompose.down.customOptions": "Any other options to add to the `docker-compose down` command. Cannot be combined with `up`.",
"vscode-docker.tasks.docker-compose.dockerCompose.envFiles.description": "(DEPRECATED) Use `envFile` instead.",
"vscode-docker.tasks.docker-compose.dockerCompose.envFile.description": "File of environment variables read in and applied to the Docker containers.",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/compose/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function compose(context: IActionContext, commands: ('up' | 'down' | 'upSu
if (!terminalCommand.args?.length) {
// Add the service list if needed
terminalCommand.command = await addServicesOrProfilesIfNeeded(context, folder, terminalCommand.command, preselectedServices, preselectedProfiles);
} else if (command === 'upSubset' || command === 'down') {
} else if (command === 'upSubset') {
// If there are arguments, it means we're using a default command (based on the logic in selectCommandTemplate.ts)
// So, we only want to add profile/service list for the upSubset command
terminalCommand = await addDefaultCommandServicesOrProfilesIfNeeded(context, folder, terminalCommand, preselectedServices, preselectedProfiles);
Expand Down
2 changes: 0 additions & 2 deletions src/commands/compose/getComposeSubsetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export async function getDefaultCommandComposeProfilesOrServices(context: IActio
useProfiles = true;
} else if (preselectedServices?.length) {
useProfiles = false;
} else if (composeCommand.args.includes('down')) {
useProfiles = true;
} else if (profiles?.length) {
const profilesOrServices: IAzureQuickPickItem<SubsetType>[] = [
{
Expand Down
1 change: 1 addition & 0 deletions src/tasks/DockerComposeTaskDefinitionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface DockerComposeDownOptions {
removeImages?: 'all' | 'local';
removeVolumes?: boolean;
customOptions?: string;
profiles?: string[];
};
}

Expand Down
1 change: 1 addition & 0 deletions src/tasks/DockerComposeTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class DockerComposeTaskProvider extends DockerTaskProvider {
files: options.files,
environmentFile: options.envFile,
projectName: options.projectName,
profiles: options.down.profiles,
removeImages: options.down.removeImages,
removeVolumes: options.down.removeVolumes,
customOptions: options.down.customOptions,
Expand Down

0 comments on commit 7528ba1

Please sign in to comment.