Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
437b212e
Commit
437b212e
authored
Jun 08, 2021
by
Sietse Ringers
Committed by
Ivar Derksen
Jun 10, 2021
Browse files
feat: check existence of server configuration file, if specified
parent
d6cf7ff0
Changes
1
Hide whitespace changes
Inline
Side-by-side
irma/cmd/config.go
View file @
437b212e
...
...
@@ -93,6 +93,17 @@ func readConfig(cmd *cobra.Command, name, logname string, configpaths []string,
// Locate and read configuration file
confpath
:=
viper
.
GetString
(
"config"
)
if
confpath
!=
""
{
info
,
err
:=
os
.
Stat
(
confpath
)
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
die
(
"specified configuration file does not exist"
,
nil
)
}
else
{
die
(
"failed to stat configuration file"
,
err
)
}
}
if
info
.
IsDir
()
{
die
(
"specified configuration file is a directory"
,
nil
)
}
dir
,
file
:=
filepath
.
Dir
(
confpath
),
filepath
.
Base
(
confpath
)
viper
.
SetConfigName
(
strings
.
TrimSuffix
(
file
,
filepath
.
Ext
(
file
)))
viper
.
AddConfigPath
(
dir
)
...
...
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