mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37:02 +00:00
Undexport GetConfigFile
It was exported in previous commit, but we have GetConfigFileUsed -- so use that.
This commit is contained in:
parent
00ed41cdba
commit
b5e8006cbe
2 changed files with 9 additions and 9 deletions
14
viper.go
14
viper.go
|
@ -268,7 +268,7 @@ func (v *Viper) WatchConfig() {
|
|||
defer watcher.Close()
|
||||
|
||||
// we have to watch the entire directory to pick up renames/atomic saves in a cross-platform way
|
||||
filename, err := v.GetConfigFile()
|
||||
filename, err := v.getConfigFile()
|
||||
if err != nil {
|
||||
log.Println("error:", err)
|
||||
return
|
||||
|
@ -1131,7 +1131,7 @@ func (v *Viper) Set(key string, value interface{}) {
|
|||
func ReadInConfig() error { return v.ReadInConfig() }
|
||||
func (v *Viper) ReadInConfig() error {
|
||||
jww.INFO.Println("Attempting to read in config file")
|
||||
filename, err := v.GetConfigFile()
|
||||
filename, err := v.getConfigFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1161,7 +1161,7 @@ func (v *Viper) ReadInConfig() error {
|
|||
func MergeInConfig() error { return v.MergeInConfig() }
|
||||
func (v *Viper) MergeInConfig() error {
|
||||
jww.INFO.Println("Attempting to merge in config file")
|
||||
filename, err := v.GetConfigFile()
|
||||
filename, err := v.getConfigFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ func (v *Viper) MergeConfig(in io.Reader) error {
|
|||
// WriteConfig writes the current configuration to a file.
|
||||
func WriteConfig() error { return v.WriteConfig() }
|
||||
func (v *Viper) WriteConfig() error {
|
||||
filename, err := v.GetConfigFile()
|
||||
filename, err := v.getConfigFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1213,7 +1213,7 @@ func (v *Viper) WriteConfig() error {
|
|||
// SafeWriteConfig writes current configuration to file only if the file does not exist.
|
||||
func SafeWriteConfig() error { return v.SafeWriteConfig() }
|
||||
func (v *Viper) SafeWriteConfig() error {
|
||||
filename, err := v.GetConfigFile()
|
||||
filename, err := v.getConfigFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1705,7 +1705,7 @@ func (v *Viper) getConfigType() string {
|
|||
return v.configType
|
||||
}
|
||||
|
||||
cf, err := v.GetConfigFile()
|
||||
cf, err := v.getConfigFile()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
@ -1719,7 +1719,7 @@ func (v *Viper) getConfigType() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (v *Viper) GetConfigFile() (string, error) {
|
||||
func (v *Viper) getConfigFile() (string, error) {
|
||||
if v.configFile == "" {
|
||||
cf, err := v.findConfigFile()
|
||||
if err != nil {
|
||||
|
|
|
@ -244,7 +244,7 @@ func (s *stringValue) String() string {
|
|||
|
||||
func TestBasics(t *testing.T) {
|
||||
SetConfigFile("/tmp/config.yaml")
|
||||
filename, err := v.GetConfigFile()
|
||||
filename, err := v.getConfigFile()
|
||||
assert.Equal(t, "/tmp/config.yaml", filename)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ func TestUnmarshalingWithAliases(t *testing.T) {
|
|||
func TestSetConfigNameClearsFileCache(t *testing.T) {
|
||||
SetConfigFile("/tmp/config.yaml")
|
||||
SetConfigName("default")
|
||||
f, err := v.GetConfigFile()
|
||||
f, err := v.getConfigFile()
|
||||
if err == nil {
|
||||
t.Fatalf("config file cache should have been cleared")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue