From 9ab21a7f3d7e349b05ceaad5862d7e72a6d7e7b4 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 1 Jul 2024 14:56:32 +0200 Subject: Pass Auth::TLS instance to BazelApi and ServeApi --- src/other_tools/just_mr/setup.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/other_tools/just_mr/setup.cpp') diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index dacbfec6..70c74eb0 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -18,9 +18,11 @@ #include #include #include +#include #include #include "nlohmann/json.hpp" +#include "src/buildtool/auth/authentication.hpp" #include "src/buildtool/execution_api/common/api_bundle.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/file_system/symlinks_map/resolve_symlinks_map.hpp" @@ -110,25 +112,32 @@ auto MultiRepoSetup(std::shared_ptr const& config, JustMR::Utils::ReachableRepositories(repos, *main, setup_repos); } - // setup the APIs for archive fetches; only happens if in native mode // setup the APIs for archive fetches; only happens if in native mode JustMR::Utils::SetupRemoteConfig(common_args.remote_execution_address, - common_args.remote_serve_address, - auth_args); + common_args.remote_serve_address); + + // setup authentication + JustMR::Utils::SetupAuthConfig(auth_args); + std::optional auth = {}; + if (Auth::Instance().GetAuthMethod() == AuthMethod::kTLS) { + auth = Auth::TLS::Instance(); + } + + ApiBundle const apis{/*repo_config=*/nullptr, + auth ? &*auth : nullptr, + RemoteExecutionConfig::RemoteAddress()}; - ApiBundle const apis{nullptr, RemoteExecutionConfig::RemoteAddress()}; bool const has_remote_api = apis.local != apis.remote and not common_args.compatible; // setup the API for serving roots - auto serve_config = JustMR::Utils::CreateServeConfig( - common_args.remote_serve_address, auth_args); + auto serve_config = + JustMR::Utils::CreateServeConfig(common_args.remote_serve_address); if (not serve_config) { return std::nullopt; } auto serve = ServeApi::Create(*serve_config, &apis); - // check configuration of the serve endpoint provided if (serve) { // if we have a remote endpoint explicitly given by the user, it must -- cgit v1.2.3