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
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,46 @@
"advanced"
]
},
"containers.commands.composeLogs": {
"oneOf": [
{
"type": "array",
"items": {
"properties": {
"template": {
"type": "string",
"description": "%vscode-containers.config.template.composeLogs.template%"
},
"label": {
"type": "string",
"description": "%vscode-containers.config.template.composeLogs.label%"
},
"match": {
"type": "string",
"description": "%vscode-containers.config.template.composeLogs.match%"
}
},
"required": [
"label",
"template"
]
}
},
{
"type": "string"
}
],
"default": [
{
"label": "Compose Logs",
"template": "${composeCommand} ${configurationFile} ${projectName} logs --tail 1000 -f"
}
],
"description": "%vscode-containers.config.template.composeLogs.description%",
"tags": [
"advanced"
]
},
"containers.commands.composeUp": {
"oneOf": [
{
Expand Down
4 changes: 4 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
"vscode-containers.config.template.logs.label": "The label displayed to the user.",
"vscode-containers.config.template.logs.match": "The regular expression for choosing the right template. Checked against container name, container's image name, etc.",
"vscode-containers.config.template.logs.description": "Command templates for container logs commands.",
"vscode-containers.config.template.composeLogs.template": "The command template.",
"vscode-containers.config.template.composeLogs.label": "The label displayed to the user.",
"vscode-containers.config.template.composeLogs.match": "The regular expression for choosing the right template. Checked against compose YAML files, folder name, etc.",
"vscode-containers.config.template.composeLogs.description": "Command templates for compose logs commands.",
"vscode-containers.config.template.composeUp.template": "The command template.",
"vscode-containers.config.template.composeUp.label": "The label displayed to the user.",
"vscode-containers.config.template.composeUp.match": "The regular expression for choosing the right template. Checked against compose YAML files, folder name, etc.",
Expand Down
13 changes: 10 additions & 3 deletions src/commands/containers/composeGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
import { IActionContext } from '@microsoft/vscode-azext-utils';
import { CommonOrchestratorCommandOptions, IContainerOrchestratorClient, LogsCommandOptions, VoidCommandResponse } from '@microsoft/vscode-container-client';
import * as path from 'path';
import { l10n } from 'vscode';
import { l10n, Uri, workspace } from 'vscode';
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';

export async function composeGroupLogs(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
// Since we're not interested in the output, we can pretend this is a `VoidCommandResponse`
return composeGroup<LogsCommandOptions>(context, (client, options) => client.logs(options) as Promise<VoidCommandResponse>, node, { follow: true, tail: 1000 });
return composeGroup<LogsCommandOptions>(context, (client, options) => {
const workingDirectory = getComposeWorkingDirectory(node);
let folder;
if (workingDirectory) {
folder = workspace.getWorkspaceFolder(Uri.file(workingDirectory));
}
return selectComposeLogsCommand(context, folder, options.files?.join('" -f "'), options.projectName, options.environmentFile);
}, node, { follow: true, tail: 1000 });
}

export async function composeGroupStart(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
Expand Down
25 changes: 24 additions & 1 deletion src/commands/selectCommandTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ext } from '../extensionVariables';
import { isComposeV2ableOrchestratorClient } from '../runtimes/clients/AutoConfigurableDockerComposeClient';
import { resolveVariables } from '../utils/resolveVariables';

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

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

Expand Down Expand Up @@ -78,6 +78,29 @@ export async function selectLogsCommand(context: IActionContext, containerName:
);
}

export async function selectComposeLogsCommand(context: IActionContext, folder: vscode.WorkspaceFolder, configurationFile?: string, projectName?: string, envFile?: string): Promise<VoidCommandResponse> {
const orchestratorClient = await ext.orchestratorManager.getClient();
let fullComposeCommand: string;
if (isComposeV2ableOrchestratorClient(orchestratorClient) && orchestratorClient.composeV2) {
fullComposeCommand = `${orchestratorClient.commandName} compose`;
} else {
fullComposeCommand = orchestratorClient.commandName;
}

return await selectCommandTemplate(
context,
'composeLogs',
[folder.name, configurationFile],
folder,
{
'configurationFile': configurationFile ? `-f "${configurationFile}"` : '',
'projectName': projectName ? `-p "${projectName}"` : '',
'environmentFile': envFile ? `--env-file "${envFile}"` : '',
'composeCommand': fullComposeCommand
}
);
}

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;

Expand Down