Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalClient
Commits
c3d0c1f6
Commit
c3d0c1f6
authored
Mar 19, 2018
by
Lukas Burgey
Browse files
Add thorough checks for config values
parent
b71a598b
Changes
1
Hide whitespace changes
Inline
Side-by-side
client.go
View file @
c3d0c1f6
...
...
@@ -196,22 +196,39 @@ func getConfig(configFile string) (c config, err error) {
return
}
err
=
c
.
fetchConfig
()
if
err
!=
nil
{
log
.
Fatalf
(
"[Conf] Error fetching remote config: %s"
,
err
)
return
// check the config values
if
c
.
Host
==
""
{
log
.
Fatalf
(
"[Conf] No 'host' in config"
)
}
if
c
.
Username
==
""
{
log
.
Fatalf
(
"[Conf] No 'user' in config"
)
}
if
c
.
Password
==
""
{
log
.
Fatalf
(
"[Conf] No 'password' in config"
)
}
if
c
.
FetchIntervalString
==
""
{
log
.
Fatalf
(
"[Conf] No 'fetch_interval' in config"
)
}
if
c
.
ReconnectTimeoutString
==
""
{
log
.
Fatalf
(
"[Conf] No 'reconnect_timeout' in config"
)
}
// parse som of the config values
if
c
.
FetchInterval
,
err
=
time
.
ParseDuration
(
c
.
FetchIntervalString
);
err
!=
nil
{
log
.
Printf
(
"[Conf] Error parsing fetch interval: %s"
,
err
)
return
}
log
.
Printf
(
"[Conf] Fetch interval set to %s"
,
c
.
FetchInterval
)
if
c
.
ReconnectTimeout
,
err
=
time
.
ParseDuration
(
c
.
ReconnectTimeoutString
);
err
!=
nil
{
log
.
Printf
(
"[Conf] Error parsing reconnect timeout: %s"
,
err
)
return
}
log
.
Printf
(
"[Conf] Reconnect timeout set to %s"
,
c
.
ReconnectTimeout
)
// fetch the remote configuration
err
=
c
.
fetchConfig
()
if
err
!=
nil
{
log
.
Fatalf
(
"[Conf] Error fetching remote config: %s"
,
err
)
return
}
// initialize the task queues
c
.
NewTasks
=
make
(
chan
task
)
...
...
Write
Preview
Markdown
is supported
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