Documentation
¶
Overview ¶
Package tree groups containers into projects and tracks the cursor and expand/collapse state of the project/container tree. It has no UI or Docker dependencies so it can be tested in isolation.
Index ¶
- Constants
- type Container
- type Health
- type Project
- type Row
- type Tree
- func (t *Tree) Bottom()
- func (t *Tree) Collapse()
- func (t *Tree) Container(r Row) *Container
- func (t *Tree) Cursor() int
- func (t *Tree) Down()
- func (t *Tree) Expand()
- func (t *Tree) Filter() string
- func (t *Tree) FirstContainer()
- func (t *Tree) IsCollapsed(project string) bool
- func (t *Tree) Matching(r Row) int
- func (t *Tree) Project(r Row) *Project
- func (t *Tree) Projects() []Project
- func (t *Tree) Rows() []Row
- func (t *Tree) Selected() (Row, bool)
- func (t *Tree) SelectedContainer() *Container
- func (t *Tree) Set(cs []Container)
- func (t *Tree) SetFilter(q string)
- func (t *Tree) Toggle()
- func (t *Tree) Top()
- func (t *Tree) Up()
Constants ¶
const Standalone = "(standalone)"
Standalone is the synthetic project for containers without a compose project label. It always sorts last.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
ID string
Name string
Project string // compose project, "" for standalone containers
Service string // compose service, "" for standalone containers
Image string
State string // running, exited, paused, restarting, created, dead, removing
Status string // human readable status from Docker, e.g. "Up 2 hours (healthy)"
Ports string
WorkingDir string // compose project directory
ConfigFiles []string // compose files, absolute paths
Networks []string
Volumes []string // named volumes
HostPorts []int // published host ports
}
Container is the subset of container information the tree and UI need.
func (Container) DisplayName ¶
DisplayName is the service name inside a compose project (the project is already shown on the parent row), otherwise the container name.
func (Container) HealthCheck ¶
HealthCheck is the healthcheck result reported in the status text: "healthy", "unhealthy", "starting", or "" when there is no healthcheck.
type Project ¶
Project is a named group of containers.
func Group ¶
Group groups containers by compose project. Projects are sorted alphabetically with Standalone last; containers by display name.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is the navigable project/container tree.
func (*Tree) Collapse ¶
func (t *Tree) Collapse()
Collapse collapses the selected project, or moves to the parent project when a container is selected.
func (*Tree) Expand ¶
func (t *Tree) Expand()
Expand expands the selected project. It is a no-op on container rows.
func (*Tree) FirstContainer ¶
func (t *Tree) FirstContainer()
FirstContainer moves the cursor to the first container row, if any.
func (*Tree) IsCollapsed ¶
func (*Tree) Matching ¶
Matching is the number of containers in the row's project that match the active filter.
func (*Tree) SelectedContainer ¶
SelectedContainer returns the container under the cursor, or nil when the cursor is on a project row or the tree is empty.
func (*Tree) Set ¶
Set replaces the containers while preserving the cursor and collapse state. If the selected container disappeared, the cursor moves to its neighbour in the same project, then to the project row, then to the nearest row.
func (*Tree) SetFilter ¶
SetFilter shows only containers whose shown name, container name or project name contains q (case-insensitive). An empty q clears the filter.