Skip to content
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
74 changes: 74 additions & 0 deletions extensions/vscode-containers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
"command": "vscode-containers.containers.composeGroup.down",
"when": "never"
},
{
"command": "vscode-containers.containers.composeGroup.pull",
"when": "never"
},
{
"command": "vscode-containers.compose.down",
"when": "isWorkspaceTrusted"
Expand All @@ -115,6 +119,10 @@
"command": "vscode-containers.compose.down.subset",
"when": "isWorkspaceTrusted"
},
{
"command": "vscode-containers.compose.pull",
"when": "isWorkspaceTrusted"
},
{
"command": "vscode-containers.configure",
"when": "isWorkspaceTrusted"
Expand Down Expand Up @@ -195,6 +203,11 @@
"command": "vscode-containers.compose.down.subset",
"group": "containers"
},
{
"when": "isWorkspaceTrusted && editorLangId == dockercompose",
"command": "vscode-containers.compose.pull",
"group": "containers"
},
{
"when": "isWorkspaceTrusted && editorLangId == dockerfile",
"command": "vscode-containers.images.build",
Expand Down Expand Up @@ -232,6 +245,11 @@
"command": "vscode-containers.compose.down.subset",
"group": "containers"
},
{
"when": "isWorkspaceTrusted && resourceLangId == dockercompose",
"command": "vscode-containers.compose.pull",
"group": "containers"
},
{
"when": "isWorkspaceTrusted && resourceLangId == dockerfile",
"command": "vscode-containers.images.build",
Expand Down Expand Up @@ -451,6 +469,11 @@
"when": "view == vscode-containers.views.containers && viewItem =~ /composeGroup$/i",
"group": "composeGroup_1_general@2"
},
{
"command": "vscode-containers.containers.composeGroup.pull",
"when": "view == vscode-containers.views.containers && viewItem =~ /composeGroup$/i",
"group": "composeGroup_1_general@2"
},
{
"command": "vscode-containers.containers.composeGroup.stop",
"when": "view == vscode-containers.views.containers && viewItem =~ /composeGroup$/i",
Expand Down Expand Up @@ -1860,6 +1883,46 @@
"advanced"
]
},
"containers.commands.composePull": {
"oneOf": [
{
"type": "array",
"items": {
"properties": {
"template": {
"type": "string",
"description": "%vscode-containers.config.template.composePull.template%"
},
"label": {
"type": "string",
"description": "%vscode-containers.config.template.composePull.label%"
},
"match": {
"type": "string",
"description": "%vscode-containers.config.template.composePull.match%"
}
},
"required": [
"label",
"template"
]
}
},
{
"type": "string"
}
],
"default": [
{
"label": "Compose Pull",
"template": "${composeCommand} ${configurationFile} pull"
}
],
"description": "%vscode-containers.config.template.composePull.description%",
"tags": [
"advanced"
]
},
"containers.commands.composeUp": {
"oneOf": [
{
Expand Down Expand Up @@ -2658,6 +2721,11 @@
"title": "%vscode-containers.commands.compose.down.subset%",
"category": "%vscode-containers.commands.category.containersGeneric%"
},
{
"command": "vscode-containers.compose.pull",
"title": "%vscode-containers.commands.compose.pull%",
"category": "%vscode-containers.commands.category.containersGeneric%"
},
{
"command": "vscode-containers.configure",
"title": "%vscode-containers.commands.configure%",
Expand Down Expand Up @@ -2788,6 +2856,11 @@
"title": "%vscode-containers.commands.containers.composeGroup.down%",
"category": "%vscode-containers.commands.category.containers%"
},
{
"command": "vscode-containers.containers.composeGroup.pull",
"title": "%vscode-containers.commands.containers.composeGroup.pull%",
"category": "%vscode-containers.commands.category.containers%"
},
{
"command": "vscode-containers.containers.filter",
"title": "%vscode-containers.commands.containers.filter%",
Expand Down Expand Up @@ -3396,6 +3469,7 @@
"containers.commands.composeUpSubset",
"containers.commands.composeDown",
"containers.commands.composeLogs",
"containers.commands.composePull",
"containers.environment",
"containers.scaffolding.templatePath",
"containers.containerCommand",
Expand Down
6 changes: 6 additions & 0 deletions extensions/vscode-containers/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@
"vscode-containers.config.template.composeDown.label": "The label displayed to the user.",
"vscode-containers.config.template.composeDown.match": "The regular expression for choosing the right template. Checked against compose YAML files, folder name, etc.",
"vscode-containers.config.template.composeDown.description": "Command templates for compose down commands.",
"vscode-containers.config.template.composePull.template": "The command template.",
"vscode-containers.config.template.composePull.label": "The label displayed to the user.",
"vscode-containers.config.template.composePull.match": "The regular expression for choosing the right template. Checked against compose YAML files, folder name, etc.",
"vscode-containers.config.template.composePull.description": "Command templates for compose pull commands.",
"vscode-containers.config.containers.containers.groupBy": "The property to use to group containers in Containers view: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, State, Status, Tag, or None",
"vscode-containers.config.containers.containers.groupByLabel": "The items will be grouped by the value of this container label (e.g. `com.microsoft.created-by`)",
"vscode-containers.config.containers.containers.description": "Any secondary properties to display for a container (an array). Possible elements include: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, State, Status, and Tag",
Expand Down Expand Up @@ -230,6 +234,7 @@
"vscode-containers.commands.compose.up": "Compose Up",
"vscode-containers.commands.compose.up.subset": "Compose Up - Select Services",
"vscode-containers.commands.compose.down.subset": "Compose Down - Select Services",
"vscode-containers.commands.compose.pull": "Compose Pull",
"vscode-containers.commands.configure": "Add Docker Files to Workspace...",
"vscode-containers.commands.configureCompose": "Add Compose Files to Workspace...",
"vscode-containers.commands.containers.attachShell": "Attach Shell",
Expand All @@ -256,6 +261,7 @@
"vscode-containers.commands.containers.composeGroup.stop": "Compose Stop",
"vscode-containers.commands.containers.composeGroup.restart": "Compose Restart",
"vscode-containers.commands.containers.composeGroup.down": "Compose Down",
"vscode-containers.commands.containers.composeGroup.pull": "Compose Pull",
"vscode-containers.commands.debugging.initializeForDebugging": "Initialize for container debugging",
"vscode-containers.commands.help": "Container Help",
"vscode-containers.commands.help.reportIssue": "Report Issue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { quickPickWorkspaceFolder } from '../../utils/quickPickWorkspaceFolder';
import { selectComposeCommand } from '../selectCommandTemplate';
import { getComposeProfileList, getComposeProfilesOrServices, getComposeServiceList, getDefaultCommandComposeProfilesOrServices } from './getComposeSubsetList';

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> {
async function compose(context: IActionContext, commands: ('up' | 'down' | 'upSubset' | 'downSubset' | 'pull')[], 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 @@ -106,6 +106,10 @@ export async function composeRestart(context: IActionContext, dockerComposeFileU
return await compose(context, ['down', 'up'], vscode.l10n.t('Choose compose file to restart'), dockerComposeFileUri, selectedComposeFileUris);
}

export async function composePull(context: IActionContext, dockerComposeFileUri?: vscode.Uri, selectedComposeFileUris?: vscode.Uri[]): Promise<void> {
return await compose(context, ['pull'], vscode.l10n.t('Choose compose file to pull'), dockerComposeFileUri, selectedComposeFileUris);
}

const serviceListPlaceholder = /\${serviceList}/i;
const profileListPlaceholder = /\${profileList}/i;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ext } from '../../extensionVariables';
import { TaskCommandRunnerFactory } from '../../runtimes/runners/TaskCommandRunnerFactory';
import { ContainerGroupTreeItem } from '../../tree/containers/ContainerGroupTreeItem';
import { ContainerTreeItem } from '../../tree/containers/ContainerTreeItem';
import { selectComposeLogsCommand } from '../selectCommandTemplate';
import { selectComposeLogsCommand, selectComposeCommand } from '../selectCommandTemplate';

export async function composeGroupLogs(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup<LogsCommandOptions>(context, async (client, options) => {
Expand Down Expand Up @@ -45,6 +45,21 @@ export async function composeGroupDown(context: IActionContext, node: ContainerG
return composeGroup(context, (client, options) => client.down(options), node);
}

export async function composeGroupPull(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, async (_client, options) => {
const labels = await getComposeGroupLabels(node);
const workingDirectory = labels && getComposeWorkingDirectory(labels);

if (!workingDirectory) {
context.errorHandling.suppressReportIssue = true;
throw new Error(l10n.t('Unable to determine compose project info for container group \'{0}\'.', node.label));
}

const folder = workspace.getWorkspaceFolder(Uri.file(workingDirectory)) ?? Uri.file(workingDirectory);
return selectComposeCommand(context, folder, 'pull', options.files?.map(f => `-f "${f}"`).join(' '));
}, node);
}

type AdditionalOptions<TOptions extends CommonOrchestratorCommandOptions> = Omit<TOptions, keyof CommonOrchestratorCommandOptions>;

async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { scaffold } from "../scaffolding/scaffold";
import { scaffoldCompose } from "../scaffolding/scaffoldCompose";
import { scaffoldDebugConfig } from "../scaffolding/scaffoldDebugConfig";
import { chooseContainerRuntime } from "./chooseContainerRuntime";
import { composeDown, composeDownSubset, composeRestart, composeUp, composeUpSubset } from "./compose/compose";
import { composeDown, composeDownSubset, composeRestart, composeUp, composeUpSubset, composePull } from "./compose/compose";
import { askCopilot } from "./containers/askCopilot";
import { attachShellContainer } from "./containers/attachShellContainer";
import { browseContainerExternal, browseContainerIntegrated } from "./containers/browseContainer";
import { composeGroupDown, composeGroupLogs, composeGroupRestart, composeGroupStart, composeGroupStop } from "./containers/composeGroup";
import { composeGroupDown, composeGroupLogs, composeGroupPull, composeGroupRestart, composeGroupStart, composeGroupStop } from "./containers/composeGroup";
import { configureContainersExplorer } from "./containers/configureContainersExplorer";
import { downloadContainerFile } from "./containers/files/downloadContainerFile";
import { openContainerFile } from "./containers/files/openContainerFile";
Expand Down Expand Up @@ -124,6 +124,7 @@ export function registerCommands(): void {
registerWorkspaceCommand('vscode-containers.compose.up', composeUp);
registerWorkspaceCommand('vscode-containers.compose.up.subset', composeUpSubset);
registerWorkspaceCommand('vscode-containers.compose.down.subset', composeDownSubset);
registerWorkspaceCommand('vscode-containers.compose.pull', composePull);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're adding compose pull, can we also wire it up for the compose group tree item? The group currently has logs/start/stop/restart/down (registered just below at 147–151), and pull is arguably most useful there — on a project you already have running.

registerCommand('vscode-containers.pruneSystem', pruneSystem);

registerWorkspaceCommand('vscode-containers.containers.attachShell', attachShellContainer);
Expand All @@ -149,6 +150,7 @@ export function registerCommands(): void {
registerWorkspaceCommand('vscode-containers.containers.composeGroup.stop', composeGroupStop);
registerWorkspaceCommand('vscode-containers.containers.composeGroup.restart', composeGroupRestart);
registerWorkspaceCommand('vscode-containers.containers.composeGroup.down', composeGroupDown);
registerWorkspaceCommand('vscode-containers.containers.composeGroup.pull', composeGroupPull);

registerWorkspaceCommand('vscode-containers.images.build', buildImage);
registerCommand('vscode-containers.images.configureExplorer', configureImagesExplorer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ext } from '../extensionVariables';
import { isComposeV2ableOrchestratorClient } from '../runtimes/OrchestratorRuntimeManager';
import { resolveVariables } from '../utils/resolveVariables';

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

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

Expand Down Expand Up @@ -110,7 +110,7 @@ export async function selectComposeLogsCommand(context: IActionContext, folder:
);
}

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

switch (composeCommand) {
Expand All @@ -123,6 +123,9 @@ export async function selectComposeCommand(context: IActionContext, folder: vsco
case 'downSubset':
template = 'composeDownSubset';
break;
case 'pull':
template = 'composePull';
break;
case 'upSubset':
default:
template = 'composeUpSubset';
Expand All @@ -140,12 +143,15 @@ export async function selectComposeCommand(context: IActionContext, folder: vsco
fullComposeCommand = orchestratorClient.commandName;
}

const folderName = folder instanceof vscode.Uri ? path.basename(folder.fsPath) : folder.name;
const formattedConfigFile = !configurationFile ? '' : configurationFile.startsWith('-f ') ? configurationFile : `-f "${configurationFile}"`;

return await selectCommandTemplate(
context,
template,
[folder.name, configurationFile],
[folderName, configurationFile],
folder,
{ 'configurationFile': configurationFile ? `-f "${configurationFile}"` : '', 'detached': detached ? '-d' : '', 'build': build ? '--build' : '', 'composeCommand': fullComposeCommand }
{ 'configurationFile': formattedConfigFile, 'detached': detached ? '-d' : '', 'build': build ? '--build' : '', 'composeCommand': fullComposeCommand }
);
}

Expand Down
Loading