Automatically group Docker Swarm stack containers#506
Automatically group Docker Swarm stack containers#506bwateratmsft with Copilot wants to merge 4 commits into
Conversation
|
Fue un instinto de mi curioaidad |
|
@copilot resolve the merge conflicts in this pull request |
Merged |
There was a problem hiding this comment.
Changelog is curated, please revert
There was a problem hiding this comment.
Pull request overview
Updates the Containers explorer “Compose Project Name” grouping so Docker Swarm stack containers (which use com.docker.stack.namespace) are grouped automatically like Compose projects, while ensuring Compose-only group commands only appear for real Compose projects.
Changes:
- Add
getComposeProjectGroup()to derive a group name fromcom.docker.compose.projectwith a fallback tocom.docker.stack.namespace. - Gate
composeGroupcontext to real Compose projects to avoid showing Compose-only commands for Swarm stacks. - Add unit tests for compose/swarm/both/standalone grouping behavior and document the change in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extensions/vscode-containers/src/tree/containers/ContainerProperties.ts | Adds Swarm stack label fallback for “Compose Project Name” grouping and updates the property description. |
| extensions/vscode-containers/src/tree/containers/ContainerGroupTreeItem.ts | Gates Compose-only commands via contextValue based on whether the group is actually a Compose project. |
| extensions/vscode-containers/src/test/tree/containers/ContainerProperties.test.ts | Adds unit coverage for the new grouping helper across label combinations. |
| extensions/vscode-containers/CHANGELOG.md | Notes the new automatic Swarm stack grouping behavior under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private isComposeProjectGroup(): boolean { | ||
| return (this.ChildTreeItems as ContainerTreeItem[]).some(c => !!c.labels?.[composeProjectLabel]); | ||
| } |
| import { getCommonGroupIcon } from "../settings/CommonProperties"; | ||
| import { ContainerProperty, getContainerStateIcon, NonComposeGroupName } from "./ContainerProperties"; | ||
| import { ContainerProperty, composeProjectLabel, getContainerStateIcon, NonComposeGroupName } from "./ContainerProperties"; | ||
| import { ContainerTreeItem } from "./ContainerTreeItem"; |
Docker Swarm stack containers carry the
com.docker.stack.namespacelabel but lackcom.docker.compose.project, so they appeared as ungrouped "individual containers" instead of grouping by stack like Compose projects do. Users had to manually configuregroupBy: Label+groupByLabel: com.docker.stack.namespaceas a workaround.Changes
Grouping (
ContainerProperties.ts): The defaultCompose Project Namegrouping now falls back to the Swarm stack namespace label, so stack containers group under their stack name with no configuration. Extracted into agetComposeProjectGrouphelper:Group commands (
ContainerGroupTreeItem.ts): Compose-only commands (start/stop/restart/down/logs) require compose files that Swarm stacks don't have.contextValuenow gates thecomposeGroupcontext onisComposeProjectGroup(), so these commands surface only for real Compose projects; stack groups still expand by default and keep the orchestration icon.Updated the
Compose Project Nameproperty description, added unit tests for the grouping cases (compose / swarm / both / standalone), and added a CHANGELOG entry.Note
The issue also mentioned stack-name prefixes in container names feeling redundant. This mirrors Compose exactly (e.g.
project-service-1grouped underproject), which the extension intentionally does not strip, so naming is left unchanged for consistency.