using tag instead of key

This commit is contained in:
Christian Goll
2022-08-03 11:56:51 +02:00
parent 96731a4b87
commit ed5b2bbf35
3 changed files with 8 additions and 15 deletions

View File

@@ -69,7 +69,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
if len(subkeys) >= 2 {
switch subkeys[0] {
case "key":
fieldName = "key:" + subkeys[1]
fieldName = "tag:" + subkeys[1]
case "IpmiEntry":
fieldName = ipmiLopt[subkeys[1]]
case "KernelEntry":

View File

@@ -85,6 +85,11 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.Id.Set(nodename)
nodeInfoType := reflect.TypeOf(&n)
nodeInfoVal := reflect.ValueOf(&n)
// backward compatibilty
for keyname, key := range node.Keys {
node.Tags[keyname] = key
delete(node.Keys, keyname)
}
nodeConfVal := reflect.ValueOf(node)
// now iterate of every field
for i := 0; i < nodeInfoType.Elem().NumField(); i++ {
@@ -168,18 +173,6 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
if len(node.Tags) == 0 {
node.Tags = make(map[string]string)
}
for keyname, key := range node.Keys {
node.Tags[keyname] = key
delete(node.Keys, keyname)
}
for keyname, key := range node.Tags {
if _, ok := n.Tags[keyname]; !ok {
var key Entry
n.Tags[keyname] = &key
}
n.Tags[keyname].Set(key)
}
for _, p := range n.Profiles {
if _, ok := config.NodeProfiles[p]; !ok {

View File

@@ -48,7 +48,7 @@ type NodeConf struct {
Discoverable string `yaml:"discoverable,omitempty" lopt:"discoverable" comment:"Make discoverable in given network (yes/no)"`
Profiles []string `yaml:"profiles,omitempty" lopt:"profile" sopt:"P" comment:"Set the node's profile members (comma separated)"`
NetDevs map[string]*NetDevs `yaml:"network devices,omitempty"`
Tags map[string]string `yaml:"tags,omitempty" lopt:"keys" comment:"base key"`
Tags map[string]string `yaml:"tags,omitempty" lopt:"tag" comment:"base key"`
Keys map[string]string `yaml:"keys,omitempty"` // Reverse compatibility
}
@@ -61,7 +61,7 @@ type IpmiConf struct {
Gateway string `yaml:"gateway,omitempty" lopt:"ipmigateway" comment:"Set the IPMI gateway"`
Interface string `yaml:"interface,omitempty" lopt:"ipmiinterface" comment:"Set the node's IPMI interface (defaults: 'lan')"`
Write string `yaml:"write,omitempty" lopt:"ipmiwrite" comment:"Enable the write of impi configuration (yes/no)"`
Tags map[string]string `yaml:"tags,omitempty" lopt:"impitag" comment:"ipmi keys"`
Tags map[string]string `yaml:"tags,omitempty" lopt:"ipmitag" comment:"ipmi keys"`
}
type KernelConf struct {
Version string `yaml:"version,omitempty"`