github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/singletons/config/config.go (about) 1 package config 2 3 import ( 4 "path/filepath" 5 "strings" 6 7 seer "github.com/taubyte/go-seer" 8 "github.com/taubyte/tau-cli/constants" 9 10 // Importing to run the common initialization 11 _ "github.com/taubyte/tau-cli/singletons/common" 12 ) 13 14 var _config *tauConfig 15 16 func Clear() { 17 _config = nil 18 } 19 20 func getOrCreateConfig() *tauConfig { 21 if _config == nil { 22 err := loadConfig() 23 if err != nil { 24 panic(err) 25 } 26 } 27 28 return _config 29 } 30 31 func (*tauConfig) Document() *seer.Query { 32 configBaseName := strings.TrimSuffix(filepath.Base(constants.TauConfigFileName), ".yaml") 33 return _config.root.Get(configBaseName).Document().Fork() 34 }