mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
Implementation of new config definition + methods + UT Steps that still need to be implemented: - Make ClioConfigDefinition and it's method to be as constexpr as possible - Getting User Config file and populating the values in ConfigDefinition while checking for constraints on user values - Replacing all the places where we fetch config values (by using config.valueOr/MaybeValue) to instead get it from Config Definition - Generate markdown file using Clio Config Description
96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of clio: https://github.com/XRPLF/clio
|
|
Copyright (c) 2024, the clio developers.
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#pragma once
|
|
|
|
#include "util/newconfig/Array.hpp"
|
|
#include "util/newconfig/ConfigDefinition.hpp"
|
|
#include "util/newconfig/ConfigValue.hpp"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
using namespace util::config;
|
|
|
|
inline ClioConfigDefinition
|
|
generateConfig()
|
|
{
|
|
return ClioConfigDefinition{
|
|
{"header.text1", ConfigValue{ConfigType::String}.defaultValue("value")},
|
|
{"header.port", ConfigValue{ConfigType::Integer}.defaultValue(123)},
|
|
{"header.admin", ConfigValue{ConfigType::Boolean}.defaultValue(true)},
|
|
{"header.sub.sub2Value", ConfigValue{ConfigType::String}.defaultValue("TSM")},
|
|
{"ip", ConfigValue{ConfigType::Double}.defaultValue(444.22)},
|
|
{"array.[].sub",
|
|
Array{
|
|
ConfigValue{ConfigType::Double}.defaultValue(111.11), ConfigValue{ConfigType::Double}.defaultValue(4321.55)
|
|
}},
|
|
{"array.[].sub2",
|
|
Array{
|
|
ConfigValue{ConfigType::String}.defaultValue("subCategory"),
|
|
ConfigValue{ConfigType::String}.defaultValue("temporary")
|
|
}},
|
|
{"higher.[].low.section", Array{ConfigValue{ConfigType::String}.defaultValue("true")}},
|
|
{"higher.[].low.admin", Array{ConfigValue{ConfigType::Boolean}.defaultValue(false)}},
|
|
{"dosguard.whitelist.[]",
|
|
Array{
|
|
ConfigValue{ConfigType::String}.defaultValue("125.5.5.2"),
|
|
ConfigValue{ConfigType::String}.defaultValue("204.2.2.2")
|
|
}},
|
|
{"dosguard.port", ConfigValue{ConfigType::Integer}.defaultValue(55555)}
|
|
};
|
|
}
|
|
|
|
/* The config definition above would look like this structure in config.json:
|
|
"header": {
|
|
"text1": "value",
|
|
"port": 123,
|
|
"admin": true,
|
|
"sub": {
|
|
"sub2Value": "TSM"
|
|
}
|
|
},
|
|
"ip": 444.22,
|
|
"array": [
|
|
{
|
|
"sub": 111.11,
|
|
"sub2": "subCategory"
|
|
},
|
|
{
|
|
"sub": 4321.55,
|
|
"sub2": "temporary"
|
|
}
|
|
],
|
|
"higher": [
|
|
{
|
|
"low": {
|
|
"section": "true",
|
|
"admin": false
|
|
}
|
|
}
|
|
],
|
|
"dosguard": {
|
|
"whitelist": [
|
|
"125.5.5.2", "204.2.2.2"
|
|
],
|
|
"port" : 55555
|
|
},
|
|
|
|
|
|
*/
|