diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-03-05 17:59:43 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-03-07 09:34:01 +0100 |
commit | ab16e5f688a6460e68859c5c3869ea579b3a63d7 (patch) | |
tree | 88f9c849b0b5481e61e4ecfce84b759878c9b77b | |
parent | 56f5f380c3b3409eb5f14ac8dc5251d28aff63bb (diff) | |
download | justbuild-ab16e5f688a6460e68859c5c3869ea579b3a63d7.tar.gz |
just-mr: Correctly pass client-side auth args to 'just'...
...also for 'analyse' and 'describe'.
-rw-r--r-- | src/other_tools/just_mr/launch.cpp | 48 | ||||
-rw-r--r-- | src/other_tools/just_mr/utils.hpp | 36 |
2 files changed, 30 insertions, 54 deletions
diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp index 7a7975e7..12c9155c 100644 --- a/src/other_tools/just_mr/launch.cpp +++ b/src/other_tools/just_mr/launch.cpp @@ -54,8 +54,6 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, bool supports_remote_properties{false}; bool supports_serve{false}; bool supports_dispatch{false}; - bool supports_cacert{false}; - bool supports_client_auth{false}; std::optional<std::filesystem::path> mr_config_path{std::nullopt}; std::optional<LockFile> lock{}; @@ -95,9 +93,6 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, kKnownJustSubcommands.at(*subcommand).remote_props; supports_serve = kKnownJustSubcommands.at(*subcommand).serve; supports_dispatch = kKnownJustSubcommands.at(*subcommand).dispatch; - supports_cacert = kKnownJustSubcommands.at(*subcommand).cacert; - supports_client_auth = - kKnownJustSubcommands.at(*subcommand).client_auth; } // build just command std::vector<std::string> cmd = {common_args.just_path->string()}; @@ -163,28 +158,19 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, cmd.emplace_back(overlay_config.ToString()); } } - // forward remote execution arguments - if (supports_remote and (common_args.compatible == true)) { - cmd.emplace_back("--compatible"); - } - if (supports_remote and common_args.remote_execution_address) { - cmd.emplace_back("-r"); - cmd.emplace_back(*common_args.remote_execution_address); - } - if (supports_dispatch and just_cmd_args.endpoint_configuration) { - cmd.emplace_back("--endpoint-configuration"); - cmd.emplace_back(*just_cmd_args.endpoint_configuration); - } - if (supports_serve and common_args.remote_serve_address) { - cmd.emplace_back("-R"); - cmd.emplace_back(*common_args.remote_serve_address); - } - // forward mutual TLS arguments - if (supports_cacert and auth_args.tls_ca_cert) { - cmd.emplace_back("--tls-ca-cert"); - cmd.emplace_back(auth_args.tls_ca_cert->string()); - } - if (supports_client_auth) { + // forward remote execution and mutual TLS arguments + if (supports_remote) { + if (common_args.compatible == true) { + cmd.emplace_back("--compatible"); + } + if (common_args.remote_execution_address) { + cmd.emplace_back("-r"); + cmd.emplace_back(*common_args.remote_execution_address); + } + if (auth_args.tls_ca_cert) { + cmd.emplace_back("--tls-ca-cert"); + cmd.emplace_back(auth_args.tls_ca_cert->string()); + } if (auth_args.tls_client_cert) { cmd.emplace_back("--tls-client-cert"); cmd.emplace_back(auth_args.tls_client_cert->string()); @@ -194,6 +180,14 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, cmd.emplace_back(auth_args.tls_client_key->string()); } } + if (supports_dispatch and just_cmd_args.endpoint_configuration) { + cmd.emplace_back("--endpoint-configuration"); + cmd.emplace_back(*just_cmd_args.endpoint_configuration); + } + if (supports_serve and common_args.remote_serve_address) { + cmd.emplace_back("-R"); + cmd.emplace_back(*common_args.remote_serve_address); + } // forward-only arguments, still to come before the just-arguments if (supports_remote_properties) { for (auto const& prop : launch_fwd.remote_execution_properties) { diff --git a/src/other_tools/just_mr/utils.hpp b/src/other_tools/just_mr/utils.hpp index 30e7a913..f35495c8 100644 --- a/src/other_tools/just_mr/utils.hpp +++ b/src/other_tools/just_mr/utils.hpp @@ -49,12 +49,10 @@ struct JustSubCmdFlags { bool build_root; // supports the local build root arg bool launch; // supports the local launcher arg bool defines; // supports defines arg - bool remote; // supports remote exec args + bool remote; // supports remote exec args, including client-side auth bool remote_props; // supports remote-execution properties bool serve; // supports a serve endpoint bool dispatch; // supports dispatching of the remote-execution endpoint - bool cacert; // supports CA cert arg - bool client_auth; // supports client auth args }; // ordered, so that we have replicability @@ -67,9 +65,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = false, .remote_props = false, .serve = false, - .dispatch = false, - .cacert = false, - .client_auth = false}}, + .dispatch = false}}, {"describe", {.config = true, .build_root = true, @@ -78,9 +74,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = true, .remote_props = false, .serve = true, - .dispatch = false, - .cacert = false, - .client_auth = false}}, + .dispatch = false}}, {"analyse", {.config = true, .build_root = true, @@ -89,9 +83,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = true, .remote_props = true, .serve = true, - .dispatch = true, - .cacert = false, - .client_auth = false}}, + .dispatch = true}}, {"build", {.config = true, .build_root = true, @@ -100,9 +92,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = true, .remote_props = true, .serve = true, - .dispatch = true, - .cacert = true, - .client_auth = true}}, + .dispatch = true}}, {"install", {.config = true, .build_root = true, @@ -111,9 +101,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = true, .remote_props = true, .serve = true, - .dispatch = true, - .cacert = true, - .client_auth = true}}, + .dispatch = true}}, {"rebuild", {.config = true, .build_root = true, @@ -122,9 +110,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = true, .remote_props = true, .serve = true, - .dispatch = true, - .cacert = true, - .client_auth = true}}, + .dispatch = true}}, {"install-cas", {.config = false, .build_root = true, @@ -133,9 +119,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = true, .remote_props = false, .serve = false, - .dispatch = false, - .cacert = true, - .client_auth = true}}, + .dispatch = false}}, {"gc", {.config = false, .build_root = true, @@ -144,9 +128,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{ .remote = false, .remote_props = false, .serve = false, - .dispatch = false, - .cacert = false, - .client_auth = false}}}; + .dispatch = false}}}; nlohmann::json const kDefaultConfigLocations = nlohmann::json::array( {{{"root", "workspace"}, {"path", "repos.json"}}, |