(cmd *cobra.Command, args []string)
| 200 | } |
| 201 | |
| 202 | func runStorageShow(cmd *cobra.Command, args []string) error { |
| 203 | ctx := context.Background() |
| 204 | nodeName := args[0] |
| 205 | storageName := args[1] |
| 206 | |
| 207 | session, err := initCLISession(cmd) |
| 208 | if err != nil { |
| 209 | return printError(err) |
| 210 | } |
| 211 | |
| 212 | if session == nil { |
| 213 | return nil |
| 214 | } |
| 215 | |
| 216 | client, err := session.clientForNode(ctx, nodeName) |
| 217 | if err != nil { |
| 218 | return printError(err) |
| 219 | } |
| 220 | |
| 221 | storages, err := client.GetNodeStorages(nodeName) |
| 222 | if err != nil { |
| 223 | return printError(fmt.Errorf("failed to get storages for node %s: %w", nodeName, err)) |
| 224 | } |
| 225 | |
| 226 | for _, s := range storages { |
| 227 | if s == nil || s.Name != storageName { |
| 228 | continue |
| 229 | } |
| 230 | |
| 231 | row := storageListRow{ |
| 232 | Name: s.Name, |
| 233 | Node: nodeName, |
| 234 | Type: s.Plugintype, |
| 235 | Content: s.Content, |
| 236 | Used: s.Disk, |
| 237 | Total: s.MaxDisk, |
| 238 | Active: true, |
| 239 | } |
| 240 | |
| 241 | format := getOutputFormat(cmd) |
| 242 | if format == outputTable { |
| 243 | printTable([]string{"FIELD", "VALUE"}, [][]string{ |
| 244 | {"name", row.Name}, |
| 245 | {"node", row.Node}, |
| 246 | {"type", row.Type}, |
| 247 | {"content", row.Content}, |
| 248 | {"used", formatBytes(row.Used)}, |
| 249 | {"total", formatBytes(row.Total)}, |
| 250 | {"active", strconv.FormatBool(row.Active)}, |
| 251 | }) |
| 252 | return nil |
| 253 | } |
| 254 | |
| 255 | return printJSON(row) |
| 256 | } |
| 257 | |
| 258 | return printError(fmt.Errorf("storage %q not found on node %s", storageName, nodeName)) |
| 259 | } |
nothing calls this directly
no test coverage detected