@@ -43,7 +43,7 @@ ParseResult ConfigReader::ProcessOptionValue(
43
43
simdjson::ondemand::value& ondemand_value,
44
44
options_parser::OptionType option_type,
45
45
std::vector<std::string>* output,
46
- std::unordered_set<std::string>* unique_options) {
46
+ std::unordered_set<std::string>* unique_options = nullptr ) {
47
47
switch (option_type) {
48
48
case options_parser::OptionType::kBoolean : {
49
49
bool result;
@@ -142,7 +142,9 @@ ParseResult ConfigReader::ProcessOptionValue(
142
142
default :
143
143
UNREACHABLE ();
144
144
}
145
- unique_options->insert (option_name);
145
+ if (unique_options != nullptr ) {
146
+ unique_options->insert (option_name);
147
+ }
146
148
return ParseResult::Valid;
147
149
}
148
150
@@ -189,7 +191,14 @@ return ParseResult::Valid;
189
191
ParseResult ConfigReader::ParseNamespaceOptions (
190
192
simdjson::ondemand::object* options_object,
191
193
const std::string& namespace_name) {
194
+ // MapOptions could send also options non settable via nodeOptions
192
195
auto options_map = options_parser::MapOptionsByNamespace (namespace_name);
196
+
197
+ if (!env_options_initialized_) {
198
+ env_options_map_ = options_parser::MapEnvOptionsFlagInputType ();
199
+ env_options_initialized_ = true ;
200
+ }
201
+
193
202
simdjson::ondemand::value ondemand_value;
194
203
std::string_view key;
195
204
@@ -210,14 +219,32 @@ ParseResult ConfigReader::ParseNamespaceOptions(
210
219
it->first .c_str ());
211
220
return ParseResult::InvalidContent;
212
221
}
213
- ParseResult result = ProcessOptionValue (key,
214
- it->first ,
215
- ondemand_value,
216
- it->second ,
217
- &namespace_options_,
218
- &unique_namespace_options_);
219
- if (result != ParseResult::Valid) {
220
- return result;
222
+
223
+ bool is_allowed_in_envvar =
224
+ env_options_map_.find (it->first ) != env_options_map_.end ();
225
+ if (is_allowed_in_envvar) {
226
+ // Process the option for env options
227
+ ParseResult result = ProcessOptionValue (key,
228
+ it->first ,
229
+ ondemand_value,
230
+ it->second ,
231
+ &namespace_options_,
232
+ &unique_namespace_options_);
233
+ if (result != ParseResult::Valid) {
234
+ return result;
235
+ }
236
+ } else {
237
+ // Process the option for non-env options (don't add to
238
+ // unique_namespace_options_)
239
+ ParseResult result = ProcessOptionValue (key,
240
+ it->first ,
241
+ ondemand_value,
242
+ it->second ,
243
+ &namespace_non_env_options_,
244
+ nullptr );
245
+ if (result != ParseResult::Valid) {
246
+ return result;
247
+ }
221
248
}
222
249
} else {
223
250
FPrintF (stderr,
@@ -337,6 +364,10 @@ std::string ConfigReader::AssignNodeOptions() {
337
364
return acc;
338
365
}
339
366
367
+ std::vector<std::string> ConfigReader::AssignNodeNonEnvOptions () {
368
+ return namespace_non_env_options_;
369
+ }
370
+
340
371
size_t ConfigReader::GetFlagsSize () {
341
372
return node_options_.size () + namespace_options_.size ();
342
373
}
0 commit comments