Files
warewulf/internal/app/wwctl/container/show/main.go
Christian Goll e57ea10df5 fix index
2022-02-01 16:36:39 +01:00

37 lines
861 B
Go

package show
import (
"fmt"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
containerName := args[0]
if !container.ValidName(containerName) {
return fmt.Errorf("%s is not a valid container", containerName)
}
if !ShowAll {
fmt.Printf("%s\n", container.RootFsDir(containerName))
} else {
fmt.Printf("Name: %s\n", containerName)
fmt.Printf("Rootfs: %s\n", container.RootFsDir(containerName))
nodeDB, _ := node.New()
nodes, _ := nodeDB.FindAllNodes()
var nodeList []string
for _, n := range nodes {
if n.ContainerName.Get() == containerName {
nodeList = append(nodeList, n.Id.Get())
}
}
fmt.Printf("Nr nodes: %d\n", len(nodeList))
fmt.Printf("Nodes: %s\n", nodeList)
}
return nil
}