Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
li mengdong
viper
Commits
00ed41cd
Unverified
Commit
00ed41cd
authored
7 years ago
by
Bjørn Erik Pedersen
Browse files
Options
Download
Email Patches
Plain Diff
Export and fix GetConfigFile
parent
aafc9e6b
master
adr
bugfix/watch-nil-pointer
dependabot/go_modules/github.com/fsnotify/fsnotify-1.5.4
dependabot/go_modules/github.com/mitchellh/mapstructure-1.5.0
dependabot/go_modules/github.com/pelletier/go-toml-1.9.5
mergefix/Issue284_Kubernetes_config
set-sast-config-1
set-sast-config-2
v1.11.0
v1.10.1
v1.10.0
v1.9.0
v1.8.1
v1.8.0
v1.7.1
v1.7.0
v1.6.3
v1.6.2
v1.6.1
v1.6.0
v1.5.0
v1.4.0
v1.3.2
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.1
v1.1.0
v1.0.3
v1.0.2
v1.0.1
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
nohup.out
+0
-1
nohup.out
viper.go
+14
-18
viper.go
viper_test.go
+2
-2
viper_test.go
with
16 additions
and
21 deletions
+16
-21
nohup.out
deleted
100644 → 0
+
0
-
1
View file @
aafc9e6b
QProcess::start: Process is already running
This diff is collapsed.
Click to expand it.
viper.go
+
14
-
18
View file @
00ed41cd
...
...
@@ -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
.
g
etConfigFile
()
filename
,
err
:=
v
.
G
etConfigFile
()
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
.
g
etConfigFile
()
filename
,
err
:=
v
.
G
etConfigFile
()
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
.
g
etConfigFile
()
filename
,
err
:=
v
.
G
etConfigFile
()
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
.
g
etConfigFile
()
filename
,
err
:=
v
.
G
etConfigFile
()
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
.
g
etConfigFile
()
filename
,
err
:=
v
.
G
etConfigFile
()
if
err
!=
nil
{
return
err
}
...
...
@@ -1705,7 +1705,7 @@ func (v *Viper) getConfigType() string {
return
v
.
configType
}
cf
,
err
:=
v
.
g
etConfigFile
()
cf
,
err
:=
v
.
G
etConfigFile
()
if
err
!=
nil
{
return
""
}
...
...
@@ -1719,19 +1719,15 @@ func (v *Viper) getConfigType() string {
return
""
}
func
(
v
*
Viper
)
getConfigFile
()
(
string
,
error
)
{
// if explicitly set, then use it
if
v
.
configFile
!=
""
{
return
v
.
configFile
,
nil
}
cf
,
err
:=
v
.
findConfigFile
()
if
err
!=
nil
{
return
""
,
err
func
(
v
*
Viper
)
GetConfigFile
()
(
string
,
error
)
{
if
v
.
configFile
==
""
{
cf
,
err
:=
v
.
findConfigFile
()
if
err
!=
nil
{
return
""
,
err
}
v
.
configFile
=
cf
}
v
.
configFile
=
cf
return
v
.
getConfigFile
()
return
v
.
configFile
,
nil
}
func
(
v
*
Viper
)
searchInPath
(
in
string
)
(
filename
string
)
{
...
...
This diff is collapsed.
Click to expand it.
viper_test.go
+
2
-
2
View file @
00ed41cd
...
...
@@ -244,7 +244,7 @@ func (s *stringValue) String() string {
func
TestBasics
(
t
*
testing
.
T
)
{
SetConfigFile
(
"/tmp/config.yaml"
)
filename
,
err
:=
v
.
g
etConfigFile
()
filename
,
err
:=
v
.
G
etConfigFile
()
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
.
g
etConfigFile
()
f
,
err
:=
v
.
G
etConfigFile
()
if
err
==
nil
{
t
.
Fatalf
(
"config file cache should have been cleared"
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help