use yaml/v3 and don't export Nodes
introduced wwbool and don't export Nodes and NodeConfs. This requires new explict Yaml (un)marshaling as the standard marshaller won't touch these fields Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
ac6cd69ca6
commit
5bd4fd4712
@@ -5,6 +5,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwtype"
|
||||
)
|
||||
|
||||
type NodeConfDel struct {
|
||||
@@ -71,6 +72,8 @@ func recursiveCreateFlags(obj interface{}, baseCmd *cobra.Command) {
|
||||
recursiveCreateFlags(nodeInfoVal.Elem().Field(i).MapIndex(key).Interface(), baseCmd)
|
||||
} else if nodeInfoType.Elem().Field(i).Anonymous {
|
||||
recursiveCreateFlags(nodeInfoVal.Elem().Field(i).Addr().Interface(), baseCmd)
|
||||
} else if nodeInfoType.Elem().Field(i).Type.Kind() == reflect.Struct {
|
||||
recursiveCreateFlags(nodeInfoVal.Elem().Field(i).Addr().Interface(), baseCmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,6 +185,20 @@ func createFlags(baseCmd *cobra.Command,
|
||||
net.IPMask{}, // empty default!
|
||||
myType.Tag.Get("comment"))
|
||||
}
|
||||
} else if myType.Type == reflect.TypeOf(wwtype.WWbool{}) {
|
||||
ptr := myVal.Addr().Interface().(*wwtype.WWbool)
|
||||
if myType.Tag.Get("sopt") != "" {
|
||||
baseCmd.PersistentFlags().VarP(ptr,
|
||||
myType.Tag.Get("lopt"),
|
||||
myType.Tag.Get("sopt"),
|
||||
myType.Tag.Get("comment"))
|
||||
baseCmd.Flag(myType.Tag.Get("lopt")).NoOptDefVal = "true"
|
||||
} else {
|
||||
baseCmd.PersistentFlags().Var(ptr,
|
||||
myType.Tag.Get("lopt"),
|
||||
myType.Tag.Get("comment"))
|
||||
baseCmd.Flag(myType.Tag.Get("lopt")).NoOptDefVal = "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user