Add a new template for formatting
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 2.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
I am using swarm to run the services/containers. So some text is prepended and appended to the actual container name.
of this sort stackname_containername.1.pmybkzo8ovlirri0rf1syyo4p
When I do a docker stats with --format option
docker stats --no-stream --format '{{.Name}}\t:\t{{.CPUPerc}}'
It prints -
<stackname>_<container-name>.1.<some-gibberish> 0.3%
...
I want to trim the gibberish on basis of regex. These are the valid templates provided -
https://github.com/docker/cli/blob/a32cd16160f1b41c1c4ae7bee4dac929d1484e59/templates/templates.go
so I tried to use split, and was able to remove the first for 'most' containers which were same. I can't try truncate as each container names differs and I can't calculate the length. I tried pipe and then split again but since the split returned []string, it didn't work.
Is there a way to get my outcome. Should I send a PR with a new template/formatter for such usecase? Is it even a valid usecase for people?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with templates/templates.go and the existing docker stats --format templates. Determine whether the requested regex-based name transformation fits the current template or formatter behavior; the issue does not identify a target implementation file, test, or concrete completion criterion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100