Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
38f64d5b
Commit
38f64d5b
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Fix for updating config properties
parent
30c0eb71
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#11180
passed
5 years ago
Stage: all
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/common/cpp/include/ftl/configuration.hpp
+6
-6
6 additions, 6 deletions
components/common/cpp/include/ftl/configuration.hpp
components/common/cpp/src/configuration.cpp
+10
-3
10 additions, 3 deletions
components/common/cpp/src/configuration.cpp
with
16 additions
and
9 deletions
components/common/cpp/include/ftl/configuration.hpp
+
6
−
6
View file @
38f64d5b
...
...
@@ -37,7 +37,7 @@ bool update(const std::string &puri, const json_t &value);
* Resolve a JSON schema reference, but do not wait for a remote reference
* if it is not available. A null entity is returned if not resolved.
*/
json_t
&
resolve
(
const
std
::
string
&
);
json_t
&
resolve
(
const
std
::
string
&
,
bool
eager
=
true
);
/**
* Resolve a reference object, or if not a reference object it simply returns
...
...
@@ -85,17 +85,17 @@ using config::configure;
template
<
typename
T
,
typename
...
ARGS
>
T
*
ftl
::
config
::
create
(
json_t
&
link
,
ARGS
...
args
)
{
auto
&
r
=
link
;
// = ftl::config::resolve(link);
//
auto &r = link; // = ftl::config::resolve(link);
if
(
!
r
[
"$id"
].
is_string
())
{
LOG
(
FATAL
)
<<
"Entity does not have $id or parent: "
<<
r
;
if
(
!
link
[
"$id"
].
is_string
())
{
LOG
(
FATAL
)
<<
"Entity does not have $id or parent: "
<<
link
;
return
nullptr
;
}
ftl
::
Configurable
*
cfg
=
ftl
::
config
::
find
(
r
[
"$id"
].
get
<
std
::
string
>
());
ftl
::
Configurable
*
cfg
=
ftl
::
config
::
find
(
link
[
"$id"
].
get
<
std
::
string
>
());
if
(
!
cfg
)
{
// try {
cfg
=
new
T
(
r
,
args
...);
cfg
=
new
T
(
link
,
args
...);
//} catch(...) {
// LOG(FATAL) << "Could not construct " << link;
//}
...
...
This diff is collapsed.
Click to expand it.
components/common/cpp/src/configuration.cpp
+
10
−
3
View file @
38f64d5b
...
...
@@ -218,7 +218,8 @@ bool ftl::config::update(const std::string &puri, const json_t &value) {
cfg
->
set
<
json_t
>
(
tail
,
value
);
}
else
{
DLOG
(
1
)
<<
"Updating: "
<<
head
<<
"["
<<
tail
<<
"] = "
<<
value
;
auto
r
=
resolve
(
head
);
auto
&
r
=
resolve
(
head
,
false
);
if
(
!
r
.
is_structured
())
{
LOG
(
ERROR
)
<<
"Cannot update property '"
<<
tail
<<
"' of '"
<<
head
<<
"'"
;
return
false
;
...
...
@@ -229,7 +230,7 @@ bool ftl::config::update(const std::string &puri, const json_t &value) {
}
}
json_t
&
ftl
::
config
::
resolve
(
const
std
::
string
&
puri
)
{
json_t
&
ftl
::
config
::
resolve
(
const
std
::
string
&
puri
,
bool
eager
)
{
string
uri_str
=
puri
;
// TODO(Nick) Must support alternative root (last $id)
...
...
@@ -252,11 +253,13 @@ json_t &ftl::config::resolve(const std::string &puri) {
auto
ptr
=
nlohmann
::
json
::
json_pointer
(
"/"
+
uri
.
getFragment
());
try
{
return
resolve
((
*
ix
).
second
->
at
(
ptr
));
return
(
eager
)
?
resolve
((
*
ix
).
second
->
at
(
ptr
))
:
(
*
ix
).
second
->
at
(
ptr
)
;
}
catch
(...)
{
LOG
(
WARNING
)
<<
"Resolve failed for "
<<
puri
;
return
null_json
;
}
}
else
{
LOG
(
WARNING
)
<<
"Resolve failed for "
<<
puri
;
return
null_json
;
}
}
...
...
@@ -429,6 +432,10 @@ Configurable *ftl::config::configure(int argc, char **argv, const std::string &r
rootCFG
=
rootcfg
;
rootcfg
->
set
(
"paths"
,
paths
);
process_options
(
rootcfg
,
options
);
//LOG(INFO) << "CONFIG: " << config["vision_default"];
CHECK_EQ
(
&
config
,
config_index
[
"ftl://utu.fi"
]
);
return
rootcfg
;
}
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