Refactor node

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-10-25 14:17:00 -06:00
parent e6f5c63c21
commit 0665d5dc88
35 changed files with 112 additions and 114 deletions

View File

@@ -12,7 +12,7 @@ import (
// Holds the variables which are needed in CobraRunE
type variables struct {
nodeConf node.NodeConf
nodeConf node.Node
nodeAdd node.NodeConfAdd
}

View File

@@ -18,7 +18,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
}
if !SetYes {
var nodeList []node.NodeConf
var nodeList []node.Node
// The checks run twice in the prompt case.
// Avoiding putting in a blocking prompt in an API.
nodeList, err = apiNode.NodeDeleteParameterCheck(&ndp, false)

View File

@@ -38,7 +38,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
Output: args,
}
nodeListMsg := apinode.FilteredNodes(&filterList)
nodeMap := make(map[string]*node.NodeConf)
nodeMap := make(map[string]*node.Node)
// got proper yaml back
_ = yaml.Unmarshal([]byte(nodeListMsg.NodeConfMapYaml), nodeMap)
file, err := os.CreateTemp(os.TempDir(), "ww4NodeEdit*.yaml")
@@ -50,7 +50,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
_ = file.Truncate(0)
_, _ = file.Seek(0, 0)
if !NoHeader {
yamlTemplate := node.UnmarshalConf(node.NodeConf{}, []string{"tagsdel"})
yamlTemplate := node.UnmarshalConf(node.Node{}, []string{"tagsdel"})
_, _ = file.WriteString("#nodename:\n# " + strings.Join(yamlTemplate, "\n# ") + "\n")
}
_, _ = file.WriteString(nodeListMsg.NodeConfMapYaml)
@@ -73,7 +73,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Debug("Hashes are before %s and after %s\n", sum1, sum2)
if sum1 != sum2 {
wwlog.Debug("Nodes were modified")
modifiedNodeMap := make(map[string]*node.NodeConf)
modifiedNodeMap := make(map[string]*node.Node)
_, _ = file.Seek(0, 0)
// ignore error as only may occurs under strange circumstances
buffer, _ := io.ReadAll(file)

View File

@@ -22,7 +22,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
defer file.Close()
importMap := make(map[string]*node.NodeConf)
importMap := make(map[string]*node.Node)
buffer, err := io.ReadAll(file)
if err != nil {
return fmt.Errorf("could not read: %s", err)
@@ -64,7 +64,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
continue
}
if importMap[line[0]] == nil {
importMap[line[0]] = new(node.NodeConf)
importMap[line[0]] = new(node.Node)
}
}
}

View File

@@ -496,6 +496,7 @@ nodes:
"Interface": "",
"EscapeChar": "",
"Write": "",
"Template": "",
"Tags": {}
},
"Init": "",
@@ -545,6 +546,7 @@ nodes:
"Interface": "",
"EscapeChar": "",
"Write": "",
"Template": "",
"Tags": {}
},
"Init": "",
@@ -578,6 +580,7 @@ nodes:
"Interface": "",
"EscapeChar": "",
"Write": "",
"Template": "",
"Tags": {}
},
"Init": "",

View File

@@ -14,7 +14,7 @@ type variables struct {
setNodeAll bool
setYes bool
setForce bool
nodeConf node.NodeConf
nodeConf node.Node
nodeDel node.NodeConfDel
nodeAdd node.NodeConfAdd
}