removed optionStrMap in favor of NodeConf

openStrMap is a map[string]string which is sent arround. This is now
done by using a unmarshalled NodeConf instead.
This commit is contained in:
Christian Goll
2022-08-17 16:41:20 +02:00
parent 2016588f36
commit b485ea999f
18 changed files with 1161 additions and 875 deletions

View File

@@ -1,32 +1,39 @@
package set
import (
"errors"
"fmt"
"os"
apinode "github.com/hpcng/warewulf/internal/pkg/api/node"
"github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1"
"github.com/hpcng/warewulf/internal/pkg/api/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
OptionStrMap, netWithoutName := apinode.AddNetname(OptionStrMap)
if netWithoutName {
return errors.New("a netname must be given for any network related configuration")
}
realMap := make(map[string]string)
// OptionStrMap, netWithoutName := apinode.AddNetname(OptionStrMap)
// if netWithoutName {
// return errors.New("a netname must be given for any network related configuration")
// }
// realMap := make(map[string]string)
for key, val := range OptionStrMap {
realMap[key] = *val
// for key, val := range OptionStrMap {
// realMap[key] = *val
// }
buffer, err := yaml.Marshal(nodeConf)
if err != nil {
wwlog.Error("Cant marshall nodeInfo", err)
os.Exit(1)
}
set := wwapiv1.NodeSetParameter{
OptionsStrMap: realMap,
NetdevDelete: SetNetDevDel,
AllNodes: SetNodeAll,
Force: SetForce,
NodeNames: args,
NodeConfYaml: string(buffer[:]),
NetdevDelete: SetNetDevDel,
AllNodes: SetNodeAll,
Force: SetForce,
NodeNames: args,
}
if !SetYes {