From 944dc9f126dc66d4700c351d24c4888d99ab9898 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Tue, 12 Apr 2022 17:43:20 +0200 Subject: [PATCH] stream lined datastrutures and fixed linting --- .../update_configuration.go | 4 + .../vers42/datastructure.go | 53 +------------ .../vers43/datastructure.go | 74 ------------------- 3 files changed, 5 insertions(+), 126 deletions(-) diff --git a/cmd/update_configuration/update_configuration.go b/cmd/update_configuration/update_configuration.go index 2c7e69a2..853cc320 100644 --- a/cmd/update_configuration/update_configuration.go +++ b/cmd/update_configuration/update_configuration.go @@ -40,6 +40,10 @@ func saveConf(conf interface{}) { os.Exit(1) } err = ioutil.WriteFile(confFile, out, info.Mode()) + if err != nil { + fmt.Printf("Could not write file: %s\n", err) + os.Exit(1) + } } } diff --git a/cmd/update_configuration/vers42/datastructure.go b/cmd/update_configuration/vers42/datastructure.go index b1321786..787cc5ce 100644 --- a/cmd/update_configuration/vers42/datastructure.go +++ b/cmd/update_configuration/vers42/datastructure.go @@ -5,7 +5,7 @@ package vers42 ******/ //type nodeYaml struct { -type NodeYaml struct { +type NodeYaml struct { // <-Needs to be exported NodeProfiles map[string]*NodeConf Nodes map[string]*NodeConf } @@ -44,54 +44,3 @@ type NetDevs struct { Netmask string 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"` -} diff --git a/cmd/update_configuration/vers43/datastructure.go b/cmd/update_configuration/vers43/datastructure.go index 48b48988..eda98449 100644 --- a/cmd/update_configuration/vers43/datastructure.go +++ b/cmd/update_configuration/vers43/datastructure.go @@ -63,77 +63,3 @@ type NetDevs struct { Default string `yaml:"default,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 -}