diff options
| author | Jeff Carr <[email protected]> | 2025-03-09 09:30:39 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-09 09:30:39 -0500 |
| commit | 2495995e6e50be78e8501eeeaf1a1b7cf067e6ae (patch) | |
| tree | cb4b867efc5402cfcab7ab9ffcfc315a5140aa73 /config.go | |
| parent | 66000419bf15cb255e436db44a2a74bf104484e3 (diff) | |
testing ConfigSave() and load
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -23,6 +23,34 @@ func (m *Portmaps) ConfigSave() error { return nil } +func ConfigLoad() *Portmaps { + if os.Getenv("CLOUD_HOME") == "" { + homeDir, _ := os.UserHomeDir() + fullpath := filepath.Join(homeDir, ".config/cloud") + os.Setenv("CLOUD_HOME", fullpath) + } + + var data []byte + var err error + if data, err = loadFile("gus.text"); err != nil { + log.Warn("gus.text failed to load", err) + // something went wrong loading the file + return nil + } + + if data == nil { + return nil + } + p := new(Portmaps) + if err = p.UnmarshalTEXT(data); err != nil { + log.Warn("unmarshal failed on gus.text config file", err) + return nil + } + + log.Log(INFO, "gus.ConfigLoad() has", p.Len(), "port mappings") + return p +} + func (m *Portmaps) ConfigLoad() error { if m == nil { return errors.New("It's not safe to run ConfigLoad() on a nil ?") |
