Fix linting issues

This commit is contained in:
WestleyR
2021-09-06 12:03:04 -07:00
parent 31e9929984
commit 4edc16953e
71 changed files with 470 additions and 363 deletions

View File

@@ -7,13 +7,14 @@ import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
var containers []string
if BuildAll == true {
if BuildAll {
containers, _ = container.ListSources()
} else {
containers = args
@@ -25,7 +26,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, c := range containers {
if container.ValidSource(c) == false {
if !container.ValidSource(c) {
wwlog.Printf(wwlog.ERROR, "VNFS name does not exist: %s\n", c)
os.Exit(1)
}
@@ -34,12 +35,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", c, err)
os.Exit(1)
} else {
//fmt.Printf("%-20s: %s\n", c, output)
}
}
if SetDefault == true {
if SetDefault {
if len(containers) != 1 {
wwlog.Printf(wwlog.ERROR, "Can only set default for one container\n")
} else {
@@ -56,70 +55,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if profile.Id.Get() == "default" {
wwlog.Printf(wwlog.DEBUG, "Found profile default, setting container name to: %s\n", containers[0])
profile.ContainerName.Set(containers[0])
nodeDB.ProfileUpdate(profile)
err := nodeDB.ProfileUpdate(profile)
if err != nil {
return errors.Wrap(err, "failed to update node profile")
}
}
}
nodeDB.Persist()
err = nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
fmt.Printf("Set default profile to container: %s\n", containers[0])
}
}
/*
var nodes []node.NodeInfo
set := make(map[string]int)
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
os.Exit(1)
}
if len(args) == 1 && ByNode == true {
var err error
nodes, err = n.SearchByName(args[0])
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0])
os.Exit(1)
}
for _, node := range nodes {
if node.Vnfs.Defined() == true {
set[node.Vnfs.Get()]++
}
}
} else if BuildAll == true {
var err error
nodes, err = n.FindAllNodes()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err)
os.Exit(1)
}
for _, node := range nodes {
if node.Vnfs.Defined() == true {
wwlog.Printf(wwlog.VERBOSE, "Adding VNFS to list: %s (%s)\n", node.Vnfs.Get(), node.Id.Get())
set[node.Vnfs.Get()]++
}
}
} else if len(args) == 1 {
set[args[0]]++
} else {
cmd.Usage()
os.Exit(1)
}
for v := range set {
fmt.Printf("Building VNFS: %s\n", v)
err := container.Build(v, BuildForce)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
*/
return nil
}