package main import ( "cmp" "fmt" "isle/daemon/daecommon" "slices" ) var subCmdStorageAllocationList = subCmd{ name: "list-allocation", plural: "s", descr: "Lists all storage which is currently allocated on this host", do: doWithOutput(func(ctx subCmdCtx) (any, error) { ctx, err := ctx.withParsedFlags() if err != nil { return nil, fmt.Errorf("parsing flags: %w", err) } config, err := ctx.getDaemonRPC().GetConfig(ctx) if err != nil { return nil, fmt.Errorf("getting network config: %w", err) } type alloc struct { Index int `yaml:"index"` daecommon.ConfigStorageAllocation `yaml:",inline"` } slices.SortFunc( config.Storage.Allocations, func(i, j daecommon.ConfigStorageAllocation) int { return cmp.Compare(i.RPCPort, j.RPCPort) }, ) allocs := make([]alloc, len(config.Storage.Allocations)) for i := range config.Storage.Allocations { allocs[i] = alloc{i, config.Storage.Allocations[i]} } return allocs, nil }), } var subCmdStorage = subCmd{ name: "storage", descr: "Sub-commands having to do with configuration of storage on this host", do: func(ctx subCmdCtx) error { return ctx.doSubCmd( subCmdStorageAllocationList, ) }, }