Refactor wwctl <node|profile> edit and fix bugs
`wwctl node edit` appears to not be working properly since MergeNode. This refactor, partly towards #918, resolves the issues with `node edit` and updates `profile edit` to match. Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
@@ -136,10 +136,8 @@ func (config *NodesYaml) PersistToFile(configFile string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
Dump returns a YAML document representing the nodeDb
|
||||
instance. Passes through any errors generated by yaml.Marshal.
|
||||
*/
|
||||
// Dump returns a YAML document representing the nodeDb instance. Passes through any errors
|
||||
// generated by yaml encoding.
|
||||
func (config *NodesYaml) Dump() ([]byte, error) {
|
||||
// flatten out profiles and nodes
|
||||
for _, val := range config.NodeProfiles {
|
||||
@@ -148,10 +146,5 @@ func (config *NodesYaml) Dump() ([]byte, error) {
|
||||
for _, val := range config.Nodes {
|
||||
val.Flatten()
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
// Run through encoder
|
||||
yamlEncoder := yaml.NewEncoder(&buf)
|
||||
yamlEncoder.SetIndent(2)
|
||||
err := yamlEncoder.Encode(config)
|
||||
return buf.Bytes(), err //yaml.Marshal(config)
|
||||
return util.EncodeYaml(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user