@@ -260,7 +260,7 @@ void RunServer(std::optional<std::string> host, std::optional<int> port,
260
260
CTL_WRN (" Require API key to access /v1/configs" );
261
261
return false ;
262
262
}
263
-
263
+
264
264
// If API key is not set, skip validation
265
265
if (api_keys.empty ()) {
266
266
return true ;
@@ -383,6 +383,7 @@ void print_help() {
383
383
" ~/cortexcpp)\n " ;
384
384
std::cout << " --host Host name (default: 127.0.0.1)\n " ;
385
385
std::cout << " --port Port number (default: 39281)\n " ;
386
+ std::cout << " --api_configs Keys to acess API endpoints\n " ;
386
387
std::cout << " --ignore_cout Ignore cout output\n " ;
387
388
std::cout << " --loglevel Set log level\n " ;
388
389
@@ -411,6 +412,7 @@ int main(int argc, char* argv[]) {
411
412
412
413
std::optional<std::string> server_host;
413
414
std::optional<int > server_port;
415
+ std::optional<std::string> api_keys;
414
416
bool ignore_cout_log = false ;
415
417
#if defined(_WIN32)
416
418
for (int i = 0 ; i < argc; i++) {
@@ -427,6 +429,8 @@ int main(int argc, char* argv[]) {
427
429
server_host = cortex::wc::WstringToUtf8 (argv[i + 1 ]);
428
430
} else if (command == L" --port" ) {
429
431
server_port = std::stoi (argv[i + 1 ]);
432
+ } else if (command == L" --api_keys" ) {
433
+ api_keys = cortex::wc::WstringToUtf8 (argv[i + 1 ]);
430
434
} else if (command == L" --ignore_cout" ) {
431
435
ignore_cout_log = true ;
432
436
} else if (command == L" --loglevel" ) {
@@ -447,6 +451,8 @@ int main(int argc, char* argv[]) {
447
451
server_host = argv[i + 1 ];
448
452
} else if (strcmp (argv[i], " --port" ) == 0 ) {
449
453
server_port = std::stoi (argv[i + 1 ]);
454
+ } else if (strcmp (argv[i], " --api_keys" ) == 0 ) {
455
+ api_keys = argv[i + 1 ];
450
456
} else if (strcmp (argv[i], " --ignore_cout" ) == 0 ) {
451
457
ignore_cout_log = true ;
452
458
} else if (strcmp (argv[i], " --loglevel" ) == 0 ) {
@@ -482,6 +488,15 @@ int main(int argc, char* argv[]) {
482
488
}
483
489
}
484
490
491
+ if (api_keys) {
492
+ auto config = file_manager_utils::GetCortexConfig ();
493
+ config.apiKeys = string_utils::SplitBy (*api_keys, " ," );
494
+ auto result = file_manager_utils::UpdateCortexConfig (config);
495
+ if (result.has_error ()) {
496
+ CTL_ERR (result.error ());
497
+ }
498
+ }
499
+
485
500
// check if migration is needed
486
501
if (auto res = cortex::migr::MigrationManager (
487
502
cortex::db::Database::GetInstance ().db ())
0 commit comments