crunchloop / crunchloop/devcontainer

Surface a clean container display name (from devcontainer.json `name`) as first-class metadata

未关闭
#108 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
5
派生
0
平均合并
6 小时 17 分钟
30 天内合并 PR
15

描述

## Summary

Consumers of the runtime's `ListContainers` currently only receive the **raw Docker container name**, which for the Compose path is `dc---` and for the single-container path is `devcontainer-`. There is no clean, human-friendly name to display in a UI, so consumers are forced to either show the `dc-…` string or reverse-engineer it with regex.

Meanwhile, the library **already parses** the natural friendly name — the `name` property from `devcontainer.json` — but then discards it: it's resolved into `ResolvedConfig.Name` and never stamped onto the container or returned.

## Request

Surface a friendly display name as first-class metadata, without changing the load-bearing Compose project name. Two possible shapes (either or both):

1. **Stamp a label** on created containers, e.g. `dev.containers.displayName = ResolvedConfig.Name`. This composes with the existing label-based enumeration and is cheap for consumers to read via `ListContainers` (which already populates `Labels`).
2. **Add a field** to `runtime.Container` (e.g. `DisplayName string`) populated from the resolved config.

## Pointers (as of v0.4.0)

- `config/raw.go:16` + `config/resolve.go:52` — `devcontainer.json` `name` is parsed into `ResolvedConfig.Name` (optional / `omitempty`).
- `runtime/runtime.go:284` — `Container` struct exposes only `ID`, `Name` (raw Docker name), `Image`, `State`, `Labels`; no display name.
- `up.go:463-467` — Compose project name is hardcoded `"dc-" + DevcontainerID`, which becomes the container name prefix.
- `engine.go:149-152` — single-container name is `"devcontainer-" + id`.

## Important constraint

Please keep the Compose **project name** (`dc-`) unchanged — it is load-bearing (it is the `com.docker.compose.project` label used for enumeration and by `docker compose` itself). This request is only to add *separate*, display-oriented metadata; it should not rename the project or the containers.

## Fallback behavior

`devcontainer.json` `name` is optional. When absent, a sensible fallback would be the Compose service name for siblings and something stable (e.g. `devcontainer`) for the primary — but consumers can also handle fallback themselves as long as the field is nullable/empty when unset.

## Context

Downstream (DAP) we're shipping a temporary display-time strip to hide the `dc--` prefix in our Resources UI; this issue tracks the proper fix so we can drop the workaround.

贡献指南

打开贡献指南

调研方向

阅读 config/raw.go 和 config/resolve.go 以追踪 ResolvedConfig.Name,然后检查 runtime/runtime.go、up.go 和 engine.go,了解容器元数据和命名。确定如何公开可选名称,同时保持 Compose 项目名称不变;当 ListContainers 提供独立的面向显示的元数据而不改变承载功能的名称时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, docker-compose, go
领域
backend, devtools
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。