feat: ucind: implement cluster list command (#316)

* ucind: implement cluster list

I keep forgetting my ucind clusters, that add the missing list command:
```
% ./ucind cluster list
NAME    MACHINES
miek1   machine-1
```

Just the name would have been enough, but to actually make use of the
tui table a machines list is handy as well.
(There isn't much bubbletea in ucind, but I thought lets start now).

Signed-off-by: Miek Gieben <miek@miek.nl>

* Filter directly when listing

Filter on ucind managed while listing clusters

Signed-off-by: Miek Gieben <miek@miek.nl>

---------

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2026-04-21 19:43:04 +10:00
committed by GitHub
parent 6409a47c71
commit 7e1b91c372
3 changed files with 61 additions and 1 deletions
+20
View File
@@ -322,6 +322,26 @@ func (p *Provisioner) WaitClusterReady(ctx context.Context, c Cluster, timeout t
return nil
}
func (p *Provisioner) ListClusters(ctx context.Context) ([]Cluster, error) {
nets, err := p.dockerCli.NetworkList(ctx, network.ListOptions{
Filters: filters.NewArgs(
filters.Arg("label", ManagedLabel),
),
})
if err != nil {
return nil, err
}
clusters := []Cluster{}
for _, net := range nets {
cluster, err := p.InspectCluster(ctx, net.Name)
if err == nil {
clusters = append(clusters, cluster)
}
}
return clusters, nil
}
func (p *Provisioner) RemoveCluster(ctx context.Context, name string) error {
if _, err := p.InspectCluster(ctx, name); err != nil {
if errors.Is(err, ErrNotFound) {