summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_engine
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-02 16:47:13 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-04 16:05:08 +0200
commitc2f7ead468d5e65c57e7ecb49d7fbba4254c46b7 (patch)
treeb96ce2e63d9d6a2d486cb4133c290187156b97ac /src/buildtool/execution_engine
parent0d60cd9ba4a5c18b01b6ef996434953071f0576e (diff)
downloadjustbuild-c2f7ead468d5e65c57e7ecb49d7fbba4254c46b7.tar.gz
Replace the Auth and Auth::TLS singletons
Use a builder pattern for creation and validation, in a manner that allows also other authentication methods to be added in the future besides the current TLS/SSL. The main Auth instances are built early and then passed by not_null const pointers, to avoid passing temporaries, replacing the previous Auth::TLS instances passed by simple nullable const pointers. Where needed, these passed Auth instances are also stored, by const ref. Tests also build Auth instances as needed, either with the default 'no certification' or from the test environment arguments.
Diffstat (limited to 'src/buildtool/execution_engine')
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 89a384b8..8b94a016 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -61,7 +61,7 @@ class ExecutorImpl {
std::map<std::string, std::string> const& properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> const& dispatch_list,
- Auth::TLS const* auth,
+ gsl::not_null<Auth const*> const& auth,
std::chrono::milliseconds const& timeout,
IExecutionAction::CacheFlag cache_flag,
gsl::not_null<Statistics*> const& stats,
@@ -668,7 +668,7 @@ class ExecutorImpl {
const std::map<std::string, std::string>& properties,
const std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>>& dispatch_list,
- const Auth::TLS* auth) -> std::unique_ptr<BazelApi> {
+ const gsl::not_null<Auth const*>& auth) -> std::unique_ptr<BazelApi> {
for (auto const& [pred, endpoint] : dispatch_list) {
bool match = true;
for (auto const& [k, v] : pred) {
@@ -708,7 +708,7 @@ class Executor {
std::map<std::string, std::string> properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
- Auth::TLS const* auth,
+ gsl::not_null<Auth const*> const& auth,
gsl::not_null<Statistics*> const& stats,
gsl::not_null<Progress*> const& progress,
Logger const* logger = nullptr, // log in caller logger, if given
@@ -718,7 +718,7 @@ class Executor {
remote_api_{*remote_api},
properties_{std::move(properties)},
dispatch_list_{std::move(dispatch_list)},
- auth_{auth},
+ auth_{*auth},
stats_{stats},
progress_{progress},
logger_{logger},
@@ -741,7 +741,7 @@ class Executor {
Impl::MergeProperties(properties_,
action->ExecutionProperties()),
dispatch_list_,
- auth_,
+ &auth_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput,
stats_,
@@ -760,7 +760,7 @@ class Executor {
remote_api_,
Impl::MergeProperties(properties_, action->ExecutionProperties()),
dispatch_list_,
- auth_,
+ &auth_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput,
stats_,
@@ -798,7 +798,7 @@ class Executor {
std::map<std::string, std::string> properties_;
std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>>
dispatch_list_;
- Auth::TLS const* auth_;
+ Auth const& auth_;
gsl::not_null<Statistics*> stats_;
gsl::not_null<Progress*> progress_;
Logger const* logger_;
@@ -824,7 +824,7 @@ class Rebuilder {
std::map<std::string, std::string> properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
- Auth::TLS const* auth,
+ gsl::not_null<Auth const*> const& auth,
gsl::not_null<Statistics*> const& stats,
gsl::not_null<Progress*> const& progress,
std::chrono::milliseconds timeout = IExecutionAction::kDefaultTimeout)
@@ -834,7 +834,7 @@ class Rebuilder {
api_cached_{*api_cached},
properties_{std::move(properties)},
dispatch_list_{std::move(dispatch_list)},
- auth_{auth},
+ auth_{*auth},
stats_{stats},
progress_{progress},
timeout_{timeout} {}
@@ -850,7 +850,7 @@ class Rebuilder {
remote_api_,
Impl::MergeProperties(properties_, action->ExecutionProperties()),
dispatch_list_,
- auth_,
+ &auth_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
CF::PretendCached,
stats_,
@@ -867,7 +867,7 @@ class Rebuilder {
api_cached_,
Impl::MergeProperties(properties_, action->ExecutionProperties()),
dispatch_list_,
- auth_,
+ &auth_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
CF::FromCacheOnly,
stats_,
@@ -916,7 +916,7 @@ class Rebuilder {
std::map<std::string, std::string> properties_;
std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>>
dispatch_list_;
- Auth::TLS const* auth_;
+ Auth const& auth_;
gsl::not_null<Statistics*> stats_;
gsl::not_null<Progress*> progress_;
std::chrono::milliseconds timeout_;