21 #include "configdefinition.h" 38 typedef std::vector<std::tuple<std::string, std::string, ConfigType, MandatoryFlag>> ConfigItems;
40 const MandatoryFlag Mandatory =
true;
41 const MandatoryFlag Optional =
false;
43 const int ITEM_INDEX_GROUP = 0;
44 const int ITEM_INDEX_KEY = 1;
45 const int ITEM_INDEX_TYPE = 2;
46 const int ITEM_INDEX_MANDATORY = 3;
50 const std::string ConfigDefinition::SC_CONFIG_PATH_INITIAL_VALUE =
"";
51 const int ConfigDefinition::SHUTDOWN_TIMEOUT_INITIAL_VALUE = -2;
52 const std::string ConfigDefinition::SERVICE_MANIFEST_DIR_INITIAL_VALUE =
"";
53 const std::string ConfigDefinition::DEFAULT_SERVICE_MANIFEST_DIR_INITIAL_VALUE =
"";
54 const bool ConfigDefinition::USE_SESSION_BUS_INITIAL_VALUE =
false;
57 const std::string ConfigDefinition::SC_GROUP =
"SoftwareContainer";
60 const std::string ConfigDefinition::SC_USE_SESSION_BUS_KEY =
"use-session-bus";
61 const std::string ConfigDefinition::SC_SHUTDOWN_TIMEOUT_KEY =
"shutdown-timeout";
62 const std::string ConfigDefinition::SC_SHARED_MOUNTS_DIR_KEY =
"shared-mounts-dir";
63 const std::string ConfigDefinition::SC_LXC_CONFIG_PATH_KEY =
"deprecated-lxc-config-path";
64 const std::string ConfigDefinition::SC_SERVICE_MANIFEST_DIR_KEY =
"service-manifest-dir";
65 const std::string ConfigDefinition::SC_DEFAULT_SERVICE_MANIFEST_DIR_KEY =
"default-service-manifest-dir";
67 #ifdef ENABLE_NETWORKGATEWAY 68 const std::string ConfigDefinition::SC_CREATE_BRIDGE_KEY =
"create-bridge";
69 const std::string ConfigDefinition::SC_BRIDGE_DEVICE_KEY =
"bridge-device";
70 const std::string ConfigDefinition::SC_BRIDGE_IP_KEY =
"bridge-ip";
71 const std::string ConfigDefinition::SC_BRIDGE_NETADDR_KEY =
"bridge-netaddr";
72 const std::string ConfigDefinition::SC_BRIDGE_NETMASK_KEY =
"bridge-netmask";
73 const std::string ConfigDefinition::SC_BRIDGE_NETMASK_BITLENGTH_KEY =
"bridge-netmask-bitlength";
83 const ConfigItems CONFIGS
85 #ifdef ENABLE_NETWORKGATEWAY 86 std::make_tuple(ConfigDefinition::SC_GROUP,
87 ConfigDefinition::SC_CREATE_BRIDGE_KEY,
89 ConfigDefinition::convertDefineToFlag(
90 SC_CREATE_BRIDGE_MANDATORY_FLAG )),
91 std::make_tuple(ConfigDefinition::SC_GROUP,
92 ConfigDefinition::SC_BRIDGE_DEVICE_KEY,
94 ConfigDefinition::convertDefineToFlag(
95 SC_BRIDGE_DEVICE_MANDATORY_FLAG )),
96 std::make_tuple(ConfigDefinition::SC_GROUP,
97 ConfigDefinition::SC_BRIDGE_IP_KEY,
99 ConfigDefinition::convertDefineToFlag(
100 SC_BRIDGE_IP_MANDATORY_FLAG )),
101 std::make_tuple(ConfigDefinition::SC_GROUP,
102 ConfigDefinition::SC_BRIDGE_NETMASK_BITLENGTH_KEY,
104 ConfigDefinition::convertDefineToFlag(
105 SC_BRIDGE_NETMASK_BITLENGTH_MANDATORY_FLAG )),
106 std::make_tuple(ConfigDefinition::SC_GROUP,
107 ConfigDefinition::SC_BRIDGE_NETMASK_KEY,
109 ConfigDefinition::convertDefineToFlag(
110 SC_BRIDGE_NETMASK_MANDATORY_FLAG )),
111 std::make_tuple(ConfigDefinition::SC_GROUP,
112 ConfigDefinition::SC_BRIDGE_NETADDR_KEY,
114 ConfigDefinition::convertDefineToFlag(
115 SC_BRIDGE_NETADDR_MANDATORY_FLAG )),
116 #endif // ENABLE_NETWORKGATEWAY 117 std::make_tuple(ConfigDefinition::SC_GROUP,
118 ConfigDefinition::SC_USE_SESSION_BUS_KEY,
121 std::make_tuple(ConfigDefinition::SC_GROUP,
122 ConfigDefinition::SC_SHUTDOWN_TIMEOUT_KEY,
125 std::make_tuple(ConfigDefinition::SC_GROUP,
126 ConfigDefinition::SC_SHARED_MOUNTS_DIR_KEY,
129 std::make_tuple(ConfigDefinition::SC_GROUP,
130 ConfigDefinition::SC_LXC_CONFIG_PATH_KEY,
133 std::make_tuple(ConfigDefinition::SC_GROUP,
134 ConfigDefinition::SC_SERVICE_MANIFEST_DIR_KEY,
137 std::make_tuple(ConfigDefinition::SC_GROUP,
138 ConfigDefinition::SC_DEFAULT_SERVICE_MANIFEST_DIR_KEY,
143 MandatoryFlag ConfigDefinition::convertDefineToFlag(
bool defined)
145 return defined ? Mandatory : Optional;
148 MandatoryConfigs ConfigDefinition::mandatory()
150 MandatoryConfigs mandatoryConfigs = MandatoryConfigs();
152 for (
auto config : CONFIGS) {
153 std::string group = std::get<ITEM_INDEX_GROUP>(config);
154 std::string key = std::get<ITEM_INDEX_KEY>(config);
155 MandatoryFlag mandatoryFlag = std::get<ITEM_INDEX_MANDATORY>(config);
157 if (Mandatory == mandatoryFlag) {
158 mandatoryConfigs.push_back(UniqueKey(group, key));
162 return mandatoryConfigs;
165 TypeMap ConfigDefinition::typeMap()
167 TypeMap typeMap = TypeMap();
169 for (
auto config : CONFIGS) {
170 std::string group = std::get<ITEM_INDEX_GROUP>(config);
171 std::string key = std::get<ITEM_INDEX_KEY>(config);
172 ConfigType configType = std::get<ITEM_INDEX_TYPE>(config);
174 typeMap[UniqueKey(group, key)] = configType;
ConfigType
Represents the type of a config value.
Developers guide to adding a config item: