Files
warewulf/internal/app/wwctl/container/list/main.go
Jonathon Anderson 22910958b5 Replace all instances of wwlog.Printf
wwlog provides named loggers for each level, which requires
less code and is clearer than wwlog.Printf. The code has
included a mix of both, but this commit consolidates existing
code on the per-level functions.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2022-09-11 08:00:23 -06:00

28 lines
595 B
Go

package list
import (
"fmt"
"github.com/hpcng/warewulf/internal/pkg/api/container"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
containerInfo, err := container.ContainerList()
if err != nil {
wwlog.Error("%s\n", err)
return
}
fmt.Printf("%-25s %-6s %-6s\n", "CONTAINER NAME", "NODES", "KERNEL VERSION")
for i := 0; i < len(containerInfo); i++ {
fmt.Printf("%-25s %-6d %-6s\n",
containerInfo[i].Name,
containerInfo[i].NodeCount,
containerInfo[i].KernelVersion)
}
return
}