mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user