Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
duniter-core
Commits
df4fa9e0
Commit
df4fa9e0
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
fix(conf): load module conf from env var must use uppercased module name
parent
3e703a23
No related branches found
No related tags found
No related merge requests found
Pipeline
#12179
passed
4 years ago
Stage: tests
Stage: quality
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+1
-0
1 addition, 0 deletions
Cargo.lock
conf/Cargo.toml
+1
-0
1 addition, 0 deletions
conf/Cargo.toml
conf/src/lib.rs
+20
-14
20 additions, 14 deletions
conf/src/lib.rs
with
22 additions
and
14 deletions
Cargo.lock
+
1
−
0
View file @
df4fa9e0
...
@@ -788,6 +788,7 @@ dependencies = [
...
@@ -788,6 +788,7 @@ dependencies = [
"dubp",
"dubp",
"envy",
"envy",
"futures-util",
"futures-util",
"log",
"serde",
"serde",
"serde_json",
"serde_json",
]
]
...
...
This diff is collapsed.
Click to expand it.
conf/Cargo.toml
+
1
−
0
View file @
df4fa9e0
...
@@ -10,5 +10,6 @@ anyhow = "1.0.34"
...
@@ -10,5 +10,6 @@ anyhow = "1.0.34"
dubp
=
{
version
=
"0.53.1"
,
features
=
[
"duniter"
]
}
dubp
=
{
version
=
"0.53.1"
,
features
=
[
"duniter"
]
}
envy
=
"0.4.2"
envy
=
"0.4.2"
futures-util
=
"0.3"
futures-util
=
"0.3"
log
=
"0.4"
serde
=
{
version
=
"1.0.105"
,
features
=
[
"derive"
]
}
serde
=
{
version
=
"1.0.105"
,
features
=
[
"derive"
]
}
serde_json
=
"1.0.53"
serde_json
=
"1.0.53"
This diff is collapsed.
Click to expand it.
conf/src/lib.rs
+
20
−
14
View file @
df4fa9e0
...
@@ -57,9 +57,14 @@ pub fn load_module_conf<C: Default + DeserializeOwned>(
...
@@ -57,9 +57,14 @@ pub fn load_module_conf<C: Default + DeserializeOwned>(
profile_path_opt
:
&
Option
<
PathBuf
>
,
profile_path_opt
:
&
Option
<
PathBuf
>
,
)
->
anyhow
::
Result
<
C
>
{
)
->
anyhow
::
Result
<
C
>
{
if
let
Some
(
ref
profile_path
)
=
profile_path_opt
{
if
let
Some
(
ref
profile_path
)
=
profile_path_opt
{
if
let
Ok
(
conf
)
=
envy
::
prefixed
(
format!
(
"DUNITER_{}_"
,
module_name
))
.from_env
::
<
C
>
()
{
match
envy
::
prefixed
(
format!
(
"DUNITER_{}_"
,
module_name
.to_uppercase
()))
.from_env
::
<
C
>
()
{
Ok
(
conf
)
Ok
(
conf
)
=>
Ok
(
conf
),
}
else
{
Err
(
e
)
=>
{
log
::
debug!
(
"load_module_conf(module_name: {}): envy error={}"
,
module_name
,
e
);
let
conf_file_path
=
find_module_conf_file_path
(
module_name
,
profile_path
)
?
;
let
conf_file_path
=
find_module_conf_file_path
(
module_name
,
profile_path
)
?
;
if
conf_file_path
.exists
()
{
if
conf_file_path
.exists
()
{
let
mut
file
=
std
::
fs
::
File
::
open
(
conf_file_path
)
?
;
let
mut
file
=
std
::
fs
::
File
::
open
(
conf_file_path
)
?
;
...
@@ -73,6 +78,7 @@ pub fn load_module_conf<C: Default + DeserializeOwned>(
...
@@ -73,6 +78,7 @@ pub fn load_module_conf<C: Default + DeserializeOwned>(
Ok
(
C
::
default
())
Ok
(
C
::
default
())
}
}
}
}
}
}
else
{
}
else
{
Ok
(
C
::
default
())
Ok
(
C
::
default
())
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment