Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add profile support for docker-compose down #4467

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
"command": "vscode-docker.compose.down",
"when": "isWorkspaceTrusted"
},
{
"command": "vscode-docker.compose.down.subset",
"when": "isWorkspaceTrusted"
},
{
"command": "vscode-docker.compose.restart",
"when": "isWorkspaceTrusted"
Expand Down Expand Up @@ -154,6 +158,11 @@
"command": "vscode-docker.compose.down",
"group": "docker"
},
{
"when": "isWorkspaceTrusted && editorLangId == dockercompose",
"command": "vscode-docker.compose.down.subset",
"group": "docker"
},
{
"when": "isWorkspaceTrusted && editorLangId == dockercompose",
"command": "vscode-docker.compose.restart",
Expand All @@ -169,6 +178,11 @@
"command": "vscode-docker.compose.up.subset",
"group": "docker"
},
{
"when": "isWorkspaceTrusted && editorLangId == dockercompose",
"command": "vscode-docker.compose.down.subset",
"group": "docker"
},
{
"when": "isWorkspaceTrusted && editorLangId == dockerfile",
"command": "vscode-docker.images.build",
Expand All @@ -186,6 +200,11 @@
"command": "vscode-docker.compose.down",
"group": "docker"
},
{
"when": "isWorkspaceTrusted && resourceLangId == dockercompose",
"command": "vscode-docker.compose.down.subset",
"group": "docker"
},
{
"when": "isWorkspaceTrusted && resourceLangId == dockercompose",
"command": "vscode-docker.compose.restart",
Expand Down Expand Up @@ -1826,6 +1845,43 @@
],
"description": "%vscode-docker.config.template.composeDown.description%"
},
"docker.commands.composeDownSubset": {
"oneOf": [
{
"type": "array",
"items": {
"properties": {
"template": {
"type": "string",
"description": "%vscode-docker.config.template.composeDownSubset.template%"
},
"label": {
"type": "string",
"description": "%vscode-docker.config.template.composeDownSubset.label%"
},
"match": {
"type": "string",
"description": "%vscode-docker.config.template.composeDownSubset.match%"
}
},
"required": [
"label",
"template"
]
}
},
{
"type": "string"
}
],
"default": [
{
"label": "Compose Down",
"template": "${composeCommand} ${profileList} ${configurationFile} down"
}
],
"description": "%vscode-docker.config.template.composeDownSubset.description%"
},
"docker.containers.groupBy": {
"type": "string",
"default": "Compose Project Name",
Expand Down Expand Up @@ -2290,6 +2346,11 @@
"title": "%vscode-docker.commands.compose.down%",
"category": "%vscode-docker.commands.category.docker%"
},
{
"command": "vscode-docker.compose.down.subset",
"title": "%vscode-docker.commands.compose.down.subset%",
"category": "%vscode-docker.commands.category.docker%"
},
{
"command": "vscode-docker.compose.restart",
"title": "%vscode-docker.commands.compose.restart%",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"vscode-docker.config.template.composeUpSubset.label": "The label displayed to the user.",
"vscode-docker.config.template.composeUpSubset.match": "The regular expression for choosing the right template. Checked against docker-compose YAML files, folder name, etc.",
"vscode-docker.config.template.composeUpSubset.description": "Command templates for `docker-compose up <subset>` commands.",
"vscode-docker.config.template.composeDownSubset.description": "Command templates for `docker-compose <subset> down` commands.",
"vscode-docker.config.template.composeDown.template": "The command template.",
"vscode-docker.config.template.composeDown.label": "The label displayed to the user.",
"vscode-docker.config.template.composeDown.match": "The regular expression for choosing the right template. Checked against docker-compose YAML files, folder name, etc.",
Expand Down Expand Up @@ -203,6 +204,7 @@
"vscode-docker.config.docker.enableDockerComposeLanguageService": "Whether or not to enable the preview Docker Compose Language Service. Changing requires restart to take effect.",
"vscode-docker.config.deprecated": "This setting has been deprecated and will be removed in a future release.",
"vscode-docker.commands.compose.down": "Compose Down",
"vscode-docker.commands.compose.down.subset": "Compose Down - Select Services",
"vscode-docker.commands.compose.restart": "Compose Restart",
"vscode-docker.commands.compose.up": "Compose Up",
"vscode-docker.commands.compose.up.subset": "Compose Up - Select Services",
Expand Down
6 changes: 5 additions & 1 deletion src/commands/compose/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { quickPickWorkspaceFolder } from '../../utils/quickPickWorkspaceFolder';
import { selectComposeCommand } from '../selectCommandTemplate';
import { getComposeProfileList, getComposeProfilesOrServices, getComposeServiceList } from './getComposeSubsetList';

async function compose(context: IActionContext, commands: ('up' | 'down' | 'upSubset')[], message: string, dockerComposeFileUri?: vscode.Uri | string, selectedComposeFileUris?: vscode.Uri[], preselectedServices?: string[], preselectedProfiles?: string[]): Promise<void> {
async function compose(context: IActionContext, commands: ('up' | 'down' | 'upSubset' | 'downSubset')[], message: string, dockerComposeFileUri?: vscode.Uri | string, selectedComposeFileUris?: vscode.Uri[], preselectedServices?: string[], preselectedProfiles?: string[]): Promise<void> {
if (!vscode.workspace.isTrusted) {
throw new UserCancelledError('enforceTrust');
}
Expand Down Expand Up @@ -90,6 +90,10 @@ export async function composeDown(context: IActionContext, dockerComposeFileUri?
return await compose(context, ['down'], vscode.l10n.t('Choose Docker Compose file to take down'), dockerComposeFileUri, selectedComposeFileUris);
}

export async function composeDownSubset(context: IActionContext, dockerComposeFileUri?: vscode.Uri, selectedComposeFileUris?: vscode.Uri[], preselectedServices?: string[], preselectedProfiles?: string[]): Promise<void> {
return await compose(context, ['downSubset'], vscode.l10n.t('Choose Docker Compose file to take down'), dockerComposeFileUri, selectedComposeFileUris, preselectedServices, preselectedProfiles);
}

export async function composeRestart(context: IActionContext, dockerComposeFileUri?: vscode.Uri, selectedComposeFileUris?: vscode.Uri[]): Promise<void> {
return await compose(context, ['down', 'up'], vscode.l10n.t('Choose Docker Compose file to restart'), dockerComposeFileUri, selectedComposeFileUris);
}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ext } from "../extensionVariables";
import { scaffold } from "../scaffolding/scaffold";
import { scaffoldCompose } from "../scaffolding/scaffoldCompose";
import { scaffoldDebugConfig } from "../scaffolding/scaffoldDebugConfig";
import { composeDown, composeRestart, composeUp, composeUpSubset } from "./compose/compose";
import { composeDown, composeDownSubset, composeRestart, composeUp, composeUpSubset } from "./compose/compose";
import { attachShellContainer } from "./containers/attachShellContainer";
import { browseContainer } from "./containers/browseContainer";
import { composeGroupDown, composeGroupLogs, composeGroupRestart, composeGroupStart, composeGroupStop } from "./containers/composeGroup";
Expand Down Expand Up @@ -117,6 +117,7 @@ export function registerCommands(): void {
registerWorkspaceCommand('vscode-docker.debugging.initializeForDebugging', scaffoldDebugConfig);

registerWorkspaceCommand('vscode-docker.compose.down', composeDown);
registerWorkspaceCommand('vscode-docker.compose.down.subset', composeDownSubset);
registerWorkspaceCommand('vscode-docker.compose.restart', composeRestart);
registerWorkspaceCommand('vscode-docker.compose.up', composeUp);
registerWorkspaceCommand('vscode-docker.compose.up.subset', composeUpSubset);
Expand Down
7 changes: 5 additions & 2 deletions src/commands/selectCommandTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ext } from '../extensionVariables';
import { isDockerComposeClient } from '../runtimes/OrchestratorRuntimeManager';
import { resolveVariables } from '../utils/resolveVariables';

type TemplateCommand = 'build' | 'run' | 'runInteractive' | 'attach' | 'logs' | 'composeUp' | 'composeDown' | 'composeUpSubset';
type TemplateCommand = 'build' | 'run' | 'runInteractive' | 'attach' | 'logs' | 'composeUp' | 'composeDown' | 'composeUpSubset' | 'composeDownSubset';

type TemplatePicker = (items: IAzureQuickPickItem<CommandTemplate>[], options: IAzureQuickPickOptions) => Promise<IAzureQuickPickItem<CommandTemplate>>;

Expand Down Expand Up @@ -76,7 +76,7 @@ export async function selectLogsCommand(context: IActionContext, containerName:
);
}

export async function selectComposeCommand(context: IActionContext, folder: vscode.WorkspaceFolder, composeCommand: 'up' | 'down' | 'upSubset', configurationFile?: string, detached?: boolean, build?: boolean): Promise<VoidCommandResponse> {
export async function selectComposeCommand(context: IActionContext, folder: vscode.WorkspaceFolder, composeCommand: 'up' | 'down' | 'upSubset' | 'downSubset', configurationFile?: string, detached?: boolean, build?: boolean): Promise<VoidCommandResponse> {
let template: TemplateCommand;

switch (composeCommand) {
Expand All @@ -86,6 +86,9 @@ export async function selectComposeCommand(context: IActionContext, folder: vsco
case 'down':
template = 'composeDown';
break;
case 'downSubset':
template = 'composeDownSubset';
break;
case 'upSubset':
default:
template = 'composeUpSubset';
Expand Down