From af6c91ade3faeb3522795827b707aa6e2af778ea Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 14 Apr 2023 17:34:36 -0600 Subject: [PATCH] Rename BaseConf.Initialized to BaseConf.InitializedFromFile Initialized could be interpreted to mean dynamically initialized as well. This new name removes that ambiguity. Signed-off-by: Jonathon Anderson --- internal/app/wwctl/root.go | 2 +- internal/pkg/config/root.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/app/wwctl/root.go b/internal/app/wwctl/root.go index c9d56480..4d40ccde 100644 --- a/internal/app/wwctl/root.go +++ b/internal/app/wwctl/root.go @@ -77,7 +77,7 @@ func rootPersistentPreRunE(cmd *cobra.Command, args []string) (err error) { wwlog.SetLogLevel(LogLevel) } conf := warewulfconf.Get() - if !AllowEmptyConf && !conf.Initialized() { + if !AllowEmptyConf && !conf.InitializedFromFile() { if WarewulfConfArg != "" { err = conf.ReadConf(WarewulfConfArg) } else if os.Getenv("WAREWULFCONF") != "" { diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index e654f291..374f7d7c 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -45,7 +45,8 @@ type RootConf struct { Nfs *NfsConf `yaml:"nfs"` MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"` Paths *BuildConfig `yaml:"paths"` - readConf bool + + fromFile bool } @@ -68,7 +69,7 @@ func Get() (RootConf) { // so using wwlog.Verbose or wwlog.Debug won't work if reflect.ValueOf(cachedConf).IsZero() { cachedConf = New() - cachedConf.readConf = false + cachedConf.fromFile = false } return cachedConf } @@ -106,7 +107,7 @@ func (conf *RootConf) Read(data []byte) (err error) { conf.Tftp.IpxeBinaries = defIpxe } cachedConf = *conf - cachedConf.readConf = true + cachedConf.fromFile = true return } @@ -179,10 +180,10 @@ func (conf *RootConf) SetDynamicDefaults() (err error) { } -// Initialized returns true if [RootConf] memory was read from disk, -// or false otherwise. -func (conf *RootConf) Initialized() bool { - return conf.readConf +// InitializedFromFile returns true if [RootConf] memory was read from +// a file, or false otherwise. +func (conf *RootConf) InitializedFromFile() bool { + return conf.fromFile }