From 76acd8ff8094ec6d7d14bf040a9dcdb9481f1836 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Sun, 3 Nov 2024 15:27:24 -0700 Subject: [PATCH] Rename RootConf to WarewulfYaml Matches the new name of NodesYaml Signed-off-by: Jonathon Anderson --- internal/pkg/config/root.go | 36 ++++++++++++++++---------------- internal/pkg/config/root_test.go | 4 ++-- internal/pkg/upgrade/conf.go | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index d5db4896..8c223707 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -20,12 +20,12 @@ import ( "gopkg.in/yaml.v3" ) -var cachedConf RootConf +var cachedConf WarewulfYaml -// RootConf is the main Warewulf configuration structure. It stores +// WarewulfYaml is the main Warewulf configuration structure. It stores // some information about the Warewulf server locally, and has // [WarewulfConf], [DHCPConf], [TFTPConf], and [NFSConf] sub-sections. -type RootConf struct { +type WarewulfYaml struct { Comment string `yaml:"comment,omitempty"` Ipaddr string `yaml:"ipaddr"` Ipaddr6 string `yaml:"ipaddr6,omitempty"` @@ -45,10 +45,10 @@ type RootConf struct { warewulfconf string } -// New caches and returns a new [RootConf] initialized with empty +// New caches and returns a new [WarewulfYaml] initialized with empty // values, clearing replacing any previously cached value. -func New() *RootConf { - cachedConf = RootConf{} +func New() *WarewulfYaml { + cachedConf = WarewulfYaml{} cachedConf.warewulfconf = "" cachedConf.Warewulf = new(WarewulfConf) cachedConf.DHCP = new(DHCPConf) @@ -62,9 +62,9 @@ func New() *RootConf { return &cachedConf } -// Get returns a previously cached [RootConf] if it exists, or returns -// a new RootConf. -func Get() *RootConf { +// Get returns a previously cached [WarewulfYaml] if it exists, or returns +// a new WarewulfYaml. +func Get() *WarewulfYaml { // NOTE: This function can be called before any log level is set // so using wwlog.Verbose or wwlog.Debug won't work if reflect.ValueOf(cachedConf).IsZero() { @@ -73,9 +73,9 @@ func Get() *RootConf { return &cachedConf } -// Read populates [RootConf] with the values from a configuration +// Read populates [WarewulfYaml] with the values from a configuration // file. -func (conf *RootConf) Read(confFileName string) error { +func (conf *WarewulfYaml) Read(confFileName string) error { wwlog.Debug("Reading warewulf.conf from: %s", confFileName) conf.warewulfconf = confFileName if data, err := os.ReadFile(confFileName); err != nil { @@ -87,8 +87,8 @@ func (conf *RootConf) Read(confFileName string) error { } } -// Parse populates [RootConf] with the values from a yaml document. -func (conf *RootConf) Parse(data []byte) error { +// Parse populates [WarewulfYaml] with the values from a yaml document. +func (conf *WarewulfYaml) Parse(data []byte) error { // ipxe binaries are merged not overwritten, store defaults separate defIpxe := make(map[string]string) for k, v := range conf.TFTP.IpxeBinaries { @@ -117,9 +117,9 @@ func (conf *RootConf) Parse(data []byte) error { return nil } -// SetDynamicDefaults populates [RootConf] with plausible defaults for +// SetDynamicDefaults populates [WarewulfYaml] with plausible defaults for // the runtime environment. -func (conf *RootConf) SetDynamicDefaults() (err error) { +func (conf *WarewulfYaml) SetDynamicDefaults() (err error) { if conf.Ipaddr == "" || conf.Netmask == "" || conf.Network == "" { var mask net.IPMask var network *net.IPNet @@ -197,12 +197,12 @@ func (conf *RootConf) SetDynamicDefaults() (err error) { return } -// InitializedFromFile returns true if [RootConf] memory was read from +// InitializedFromFile returns true if [WarewulfYaml] memory was read from // a file, or false otherwise. -func (conf *RootConf) InitializedFromFile() bool { +func (conf *WarewulfYaml) InitializedFromFile() bool { return conf.warewulfconf != "" } -func (conf *RootConf) GetWarewulfConf() string { +func (conf *WarewulfYaml) GetWarewulfConf() string { return conf.warewulfconf } diff --git a/internal/pkg/config/root_test.go b/internal/pkg/config/root_test.go index 9546fb04..df625a33 100644 --- a/internal/pkg/config/root_test.go +++ b/internal/pkg/config/root_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestDefaultRootConf(t *testing.T) { +func TestDefaultWarewulfYaml(t *testing.T) { conf := New() assert.Equal(t, 9873, conf.Warewulf.Port) @@ -69,7 +69,7 @@ func TestInitializedFromFile(t *testing.T) { assert.Equal(t, conf.GetWarewulfConf(), tempWarewulfConf.Name()) } -func TestExampleRootConf(t *testing.T) { +func TestExampleWarewulfYaml(t *testing.T) { example_warewulf_conf := ` ipaddr: 192.168.200.1 netmask: 255.255.255.0 diff --git a/internal/pkg/upgrade/conf.go b/internal/pkg/upgrade/conf.go index 13254dbf..24803844 100644 --- a/internal/pkg/upgrade/conf.go +++ b/internal/pkg/upgrade/conf.go @@ -1,6 +1,6 @@ package upgrade -type RootConf struct { +type WarewulfYaml struct { WWInternal int `yaml:"WW_INTERNAL"` Comment string `yaml:"comment,omitempty"` Ipaddr string `yaml:"ipaddr"`