From 62d204ff4cc94c12c1635f189255710901682825 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 12 Jul 2024 16:09:28 +0200 Subject: Remove the RemoteExecutionConfig singleton ...and replace it with passed instances created early via a builder pattern. Tests are also updated accordingly. --- src/other_tools/just_mr/setup_utils.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/other_tools/just_mr/setup_utils.cpp') diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index ae6f5a28..4e5e5ad3 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -233,23 +233,23 @@ auto CreateLocalExecutionConfig(MultiRepoCommonArguments const& cargs) noexcept return std::nullopt; } -void SetupRemoteConfig( +auto CreateRemoteExecutionConfig( std::optional const& remote_exec_addr, - std::optional const& remote_serve_addr) noexcept { + std::optional const& remote_serve_addr) noexcept + -> std::optional { // if only a serve endpoint address is given, we assume it is one that acts // also as remote-execution auto remote_addr = remote_exec_addr ? remote_exec_addr : remote_serve_addr; - if (not remote_addr) { - return; - } - // setup remote - if (not RemoteExecutionConfig::SetRemoteAddress(*remote_addr)) { - Logger::Log(LogLevel::Error, - "setting remote execution address '{}' failed.", - *remote_addr); - std::exit(kExitConfigError); + RemoteExecutionConfig::Builder builder; + auto config = builder.SetRemoteAddress(remote_addr).Build(); + + if (config) { + return *std::move(config); } + + Logger::Log(LogLevel::Error, config.error()); + return std::nullopt; } auto CreateServeConfig( -- cgit v1.2.3