stream lined datastrutures and fixed linting

This commit is contained in:
Christian Goll
2022-04-12 17:43:20 +02:00
parent 4641b947db
commit 944dc9f126
3 changed files with 5 additions and 126 deletions

View File

@@ -40,6 +40,10 @@ func saveConf(conf interface{}) {
os.Exit(1) os.Exit(1)
} }
err = ioutil.WriteFile(confFile, out, info.Mode()) err = ioutil.WriteFile(confFile, out, info.Mode())
if err != nil {
fmt.Printf("Could not write file: %s\n", err)
os.Exit(1)
}
} }
} }

View File

@@ -5,7 +5,7 @@ package vers42
******/ ******/
//type nodeYaml struct { //type nodeYaml struct {
type NodeYaml struct { type NodeYaml struct { // <-Needs to be exported
NodeProfiles map[string]*NodeConf NodeProfiles map[string]*NodeConf
Nodes map[string]*NodeConf Nodes map[string]*NodeConf
} }
@@ -44,54 +44,3 @@ type NetDevs struct {
Netmask string Netmask string
Gateway string `yaml:"gateway,omitempty"` Gateway string `yaml:"gateway,omitempty"`
} }
/******
* Internal code data representations
******/
type Entry struct {
value string
altvalue string
bool bool
altbool bool
from string
def string
}
type NodeInfo struct {
Id Entry
Cid Entry
Comment Entry
ClusterName Entry
ContainerName Entry
Ipxe Entry
KernelVersion Entry
KernelArgs Entry
IpmiIpaddr Entry
IpmiNetmask Entry
IpmiPort Entry
IpmiGateway Entry
IpmiUserName Entry
IpmiPassword Entry
IpmiInterface Entry
RuntimeOverlay Entry
SystemOverlay Entry
Root Entry
Discoverable Entry
Init Entry //TODO: Finish adding this...
Profiles []string
GroupProfiles []string
NetDevs map[string]*NetDevEntry
Keys map[string]*Entry
}
type NetDevEntry struct {
Type Entry `yaml:"type,omitempty"`
Default Entry `yaml:"default"`
Hwaddr Entry
Ipaddr Entry
IpCIDR Entry
Prefix Entry
Netmask Entry
Gateway Entry `yaml:"gateway,omitempty"`
}

View File

@@ -63,77 +63,3 @@ type NetDevs struct {
Default string `yaml:"default,omitempty"` Default string `yaml:"default,omitempty"`
Tags map[string]string `yaml:"tags,omitempty"` Tags map[string]string `yaml:"tags,omitempty"`
} }
/******
* Internal code data representations
******/
/*
Holds string values, when accessed via Get, its value
is returned which is the default or if set the value
from the profile or if set the value of the node itself
*/
type Entry struct {
value []string
altvalue []string
from string
def []string
}
/*
NodeInfo is the in memory datastructure, which can containe
a default value, which is overwritten by the overlay from the
overlay (altvalue) which is overwitten by the value of the
node itself, for all values of type Entry.
*/
type NodeInfo struct {
Id Entry
Cid Entry
Comment Entry
ClusterName Entry
ContainerName Entry
Ipxe Entry
RuntimeOverlay Entry
SystemOverlay Entry
Root Entry
Discoverable Entry
Init Entry //TODO: Finish adding this...
AssetKey Entry
Kernel *KernelEntry
Ipmi *IpmiEntry
Profiles []string
GroupProfiles []string
NetDevs map[string]*NetDevEntry
Tags map[string]*Entry
}
type IpmiEntry struct {
Ipaddr Entry
Netmask Entry
Port Entry
Gateway Entry
UserName Entry
Password Entry
Interface Entry
Write Entry
}
type KernelEntry struct {
Version Entry
Override Entry
Args Entry
}
type NetDevEntry struct {
Type Entry
OnBoot Entry
Device Entry
Hwaddr Entry
Ipaddr Entry
Ipaddr6 Entry
IpCIDR Entry
Prefix Entry
Netmask Entry
Gateway Entry
Default Entry
Tags map[string]*Entry
}