summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-10-01 08:56:21 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-10-25 13:00:43 +0200
commit6afa59eb57896aed9b7f96d37c86702d3bdb0a58 (patch)
treeb09115ff490dbda92cbba68ff6065abfef53e7ea /src
parent9dfa79780768c43292673b7d60c69aec5bfdd12c (diff)
downloadjustbuild-6afa59eb57896aed9b7f96d37c86702d3bdb0a58.tar.gz
just-mr: Use explicit naming in default instantiated storage
As just-mr will always create Git roots, be explicit in the names of variables to state that the default storage created is native.
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/fetch.cpp29
-rw-r--r--src/other_tools/just_mr/main.cpp37
-rw-r--r--src/other_tools/just_mr/setup.cpp45
-rw-r--r--src/other_tools/just_mr/setup.hpp4
-rw-r--r--src/other_tools/just_mr/update.cpp6
-rw-r--r--src/other_tools/just_mr/update.hpp2
-rw-r--r--src/other_tools/ops_maps/git_update_map.hpp3
7 files changed, 65 insertions, 61 deletions
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index 658e9988..5ad1a1f1 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -54,8 +54,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
MultiRepoFetchArguments const& fetch_args,
MultiRepoRemoteAuthArguments const& auth_args,
RetryArguments const& retry_args,
- StorageConfig const& storage_config,
- Storage const& storage,
+ StorageConfig const& native_storage_config,
+ Storage const& native_storage,
std::string multi_repository_tool_name) -> int {
// provide report
Logger::Log(LogLevel::Info, "Performing repositories fetch");
@@ -322,10 +322,11 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
return kExitConfigError;
}
- // pack the local context instances to be passed to ApiBundle
- LocalContext const local_context{.exec_config = &*local_exec_config,
- .storage_config = &storage_config,
- .storage = &storage};
+ // set up the native local context
+ LocalContext const native_local_context{
+ .exec_config = &*local_exec_config,
+ .storage_config = &native_storage_config,
+ .storage = &native_storage};
// setup authentication config
auto auth_config = JustMR::Utils::CreateAuthConfig(auth_args);
@@ -352,7 +353,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
.exec_config = &*remote_exec_config};
// setup the APIs for archive fetches; only happens if in native mode
- auto const apis = ApiBundle::Create(&local_context,
+ auto const apis = ApiBundle::Create(&native_local_context,
&remote_context,
/*repo_config=*/nullptr);
@@ -366,8 +367,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
return kExitConfigError;
}
- auto serve =
- ServeApi::Create(*serve_config, &local_context, &remote_context, &apis);
+ auto serve = ServeApi::Create(
+ *serve_config, &native_local_context, &remote_context, &apis);
// check configuration of the serve endpoint provided
if (serve) {
// if we have a remote endpoint explicitly given by the user, it must
@@ -408,8 +409,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
common_args.ca_info,
&critical_git_op_map,
serve ? &*serve : nullptr,
- &storage_config,
- &storage,
+ &native_storage_config,
+ &native_storage,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
&progress,
@@ -418,7 +419,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
auto archive_fetch_map = CreateArchiveFetchMap(
&content_cas_map,
*fetch_dir,
- &storage,
+ &native_storage,
&(*apis.local),
(fetch_args.backup_to_remote and has_remote_api) ? &*apis.remote
: nullptr,
@@ -429,7 +430,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
CreateImportToGitMap(&critical_git_op_map,
common_args.git_path->string(),
*common_args.local_launcher,
- &storage_config,
+ &native_storage_config,
common_args.jobs);
auto git_tree_fetch_map =
@@ -438,7 +439,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
common_args.git_path->string(),
*common_args.local_launcher,
serve ? &*serve : nullptr,
- &storage_config,
+ &native_storage_config,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
fetch_args.backup_to_remote,
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index dfe705d2..bcc42bac 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -206,15 +206,14 @@ void SetupLogging(MultiRepoLogArguments const& clargs) {
}
}
-[[nodiscard]] auto CreateStorageConfig(
- MultiRepoCommonArguments const& args) noexcept
+[[nodiscard]] auto CreateStorageConfig(MultiRepoCommonArguments const& args,
+ HashFunction::Type hash_type) noexcept
-> std::optional<StorageConfig> {
StorageConfig::Builder builder;
if (args.just_mr_paths->root.has_value()) {
builder.SetBuildRoot(*args.just_mr_paths->root);
}
- // For now just-mr uses only the native storage.
- builder.SetHashType(HashFunction::Type::GitSHA1);
+ builder.SetHashType(hash_type);
// As just-mr does not require the TargetCache, we do not need to set any of
// the remote execution fields for the backend description.
@@ -317,9 +316,11 @@ auto main(int argc, char* argv[]) -> int {
arguments.common.explicit_distdirs.end());
// Setup LocalStorageConfig to store the local_build_root properly
- // and make the cas and git cache roots available
- auto const storage_config = CreateStorageConfig(arguments.common);
- if (not storage_config) {
+ // and make the cas and git cache roots available. A native storage is
+ // always instantiated, while a compatible one only if needed.
+ auto const native_storage_config =
+ CreateStorageConfig(arguments.common, HashFunction::Type::GitSHA1);
+ if (not native_storage_config) {
Logger::Log(LogLevel::Error,
"Failed to configure local build root.");
return kExitGenericFailure;
@@ -327,12 +328,12 @@ auto main(int argc, char* argv[]) -> int {
if (arguments.cmd == SubCommand::kGcRepo) {
return RepositoryGarbageCollector::TriggerGarbageCollection(
- *storage_config)
+ *native_storage_config)
? kExitSuccess
: kExitBuiltinCommandFailure;
}
- auto const storage = Storage::Create(&*storage_config);
+ auto const native_storage = Storage::Create(&*native_storage_config);
// check for conflicts in main repo name
if ((not arguments.setup.sub_all) and arguments.common.main and
@@ -379,17 +380,17 @@ auto main(int argc, char* argv[]) -> int {
arguments.auth,
arguments.retry,
arguments.launch_fwd,
- *storage_config,
- storage,
+ *native_storage_config,
+ native_storage,
forward_build_root,
my_name);
}
auto repo_lock =
- RepositoryGarbageCollector::SharedLock(*storage_config);
+ RepositoryGarbageCollector::SharedLock(*native_storage_config);
if (not repo_lock) {
return kExitGenericFailure;
}
- auto lock = GarbageCollector::SharedLock(*storage_config);
+ auto lock = GarbageCollector::SharedLock(*native_storage_config);
if (not lock) {
return kExitGenericFailure;
}
@@ -415,8 +416,8 @@ auto main(int argc, char* argv[]) -> int {
arguments.just_cmd,
arguments.auth,
arguments.retry,
- *storage_config,
- storage,
+ *native_storage_config,
+ native_storage,
/*interactive=*/(arguments.cmd == SubCommand::kSetupEnv),
my_name);
// dump resulting config to stdout
@@ -435,7 +436,7 @@ auto main(int argc, char* argv[]) -> int {
return MultiRepoUpdate(config,
arguments.common,
arguments.update,
- *storage_config,
+ *native_storage_config,
my_name);
}
@@ -464,8 +465,8 @@ auto main(int argc, char* argv[]) -> int {
arguments.fetch,
arguments.auth,
arguments.retry,
- *storage_config,
- storage,
+ *native_storage_config,
+ native_storage,
my_name);
}
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 5cb34084..0e11127e 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -61,8 +61,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
MultiRepoJustSubCmdsArguments const& just_cmd_args,
MultiRepoRemoteAuthArguments const& auth_args,
RetryArguments const& retry_args,
- StorageConfig const& storage_config,
- Storage const& storage,
+ StorageConfig const& native_storage_config,
+ Storage const& native_storage,
bool interactive,
std::string const& multi_repo_tool_name)
-> std::optional<std::filesystem::path> {
@@ -135,9 +135,10 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
}
// pack the local context instances to be passed to ApiBundle
- LocalContext const local_context{.exec_config = &*local_exec_config,
- .storage_config = &storage_config,
- .storage = &storage};
+ LocalContext const native_local_context{
+ .exec_config = &*local_exec_config,
+ .storage_config = &native_storage_config,
+ .storage = &native_storage};
// setup authentication config
auto auth_config = JustMR::Utils::CreateAuthConfig(auth_args);
@@ -163,7 +164,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
.retry_config = &*retry_config,
.exec_config = &*remote_exec_config};
- auto const apis = ApiBundle::Create(&local_context,
+ auto const apis = ApiBundle::Create(&native_local_context,
&remote_context,
/*repo_config=*/nullptr);
@@ -177,8 +178,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
return std::nullopt;
}
- auto serve =
- ServeApi::Create(*serve_config, &local_context, &remote_context, &apis);
+ auto serve = ServeApi::Create(
+ *serve_config, &native_local_context, &remote_context, &apis);
// check configuration of the serve endpoint provided
if (serve) {
@@ -220,8 +221,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
common_args.ca_info,
&critical_git_op_map,
serve ? &*serve : nullptr,
- &storage_config,
- &storage,
+ &native_storage_config,
+ &native_storage,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
&progress,
@@ -231,7 +232,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
CreateImportToGitMap(&critical_git_op_map,
common_args.git_path->string(),
*common_args.local_launcher,
- &storage_config,
+ &native_storage_config,
common_args.jobs);
auto git_tree_fetch_map =
@@ -240,7 +241,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
common_args.git_path->string(),
*common_args.local_launcher,
serve ? &*serve : nullptr,
- &storage_config,
+ &native_storage_config,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
false, /* backup_to_remote */
@@ -257,7 +258,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
common_args.git_path->string(),
*common_args.local_launcher,
serve ? &*serve : nullptr,
- &storage_config,
+ &native_storage_config,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
common_args.fetch_absent,
@@ -273,8 +274,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&resolve_symlinks_map,
&critical_git_op_map,
serve ? &*serve : nullptr,
- &storage_config,
- &storage,
+ &native_storage_config,
+ &native_storage,
has_remote_api ? &*apis.remote : nullptr,
common_args.fetch_absent,
&progress,
@@ -284,8 +285,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
CreateForeignFileGitMap(&content_cas_map,
&import_to_git_map,
serve ? &*serve : nullptr,
- &storage_config,
- &storage,
+ &native_storage_config,
+ &native_storage,
common_args.fetch_absent,
common_args.jobs);
@@ -295,7 +296,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&import_to_git_map,
&resolve_symlinks_map,
serve ? &*serve : nullptr,
- &storage_config,
+ &native_storage_config,
has_remote_api ? &*apis.remote : nullptr,
common_args.jobs,
multi_repo_tool_name,
@@ -307,8 +308,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&import_to_git_map,
&critical_git_op_map,
serve ? &*serve : nullptr,
- &storage_config,
- &storage,
+ &native_storage_config,
+ &native_storage,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
common_args.jobs);
@@ -319,7 +320,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&import_to_git_map,
common_args.fetch_absent,
serve ? &*serve : nullptr,
- &storage_config,
+ &native_storage_config,
&(*apis.local),
has_remote_api ? &*apis.remote : nullptr,
common_args.jobs);
@@ -457,5 +458,5 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
return std::nullopt;
}
// if successful, return the output config
- return StorageUtils::AddToCAS(storage, mr_config.dump(2));
+ return StorageUtils::AddToCAS(native_storage, mr_config.dump(2));
}
diff --git a/src/other_tools/just_mr/setup.hpp b/src/other_tools/just_mr/setup.hpp
index 953b20eb..28328b4b 100644
--- a/src/other_tools/just_mr/setup.hpp
+++ b/src/other_tools/just_mr/setup.hpp
@@ -34,8 +34,8 @@
MultiRepoJustSubCmdsArguments const& just_cmd_args,
MultiRepoRemoteAuthArguments const& auth_args,
RetryArguments const& retry_args,
- StorageConfig const& storage_config,
- Storage const& storage,
+ StorageConfig const& native_storage_config,
+ Storage const& native_storage,
bool interactive,
std::string const& multi_repo_tool_name)
-> std::optional<std::filesystem::path>;
diff --git a/src/other_tools/just_mr/update.cpp b/src/other_tools/just_mr/update.cpp
index ce804041..819ccf64 100644
--- a/src/other_tools/just_mr/update.cpp
+++ b/src/other_tools/just_mr/update.cpp
@@ -38,7 +38,7 @@
auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
MultiRepoCommonArguments const& common_args,
MultiRepoUpdateArguments const& update_args,
- StorageConfig const& storage_config,
+ StorageConfig const& native_storage_config,
std::string const& multi_repo_tool_name) -> int {
// provide report
Logger::Log(LogLevel::Info, "Performing repositories update");
@@ -193,7 +193,7 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
}
}
// Create fake repo for the anonymous remotes
- auto tmp_dir = storage_config.CreateTypedTmpDir("update");
+ auto tmp_dir = native_storage_config.CreateTypedTmpDir("update");
if (not tmp_dir) {
Logger::Log(LogLevel::Error, "Failed to create commit update tmp dir");
return kExitUpdateError;
@@ -227,7 +227,7 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
auto git_update_map = CreateGitUpdateMap(git_repo->GetGitCAS(),
common_args.git_path->string(),
*common_args.local_launcher,
- &storage_config,
+ &native_storage_config,
&stats,
&progress,
common_args.jobs);
diff --git a/src/other_tools/just_mr/update.hpp b/src/other_tools/just_mr/update.hpp
index 2836674f..3cc4ca11 100644
--- a/src/other_tools/just_mr/update.hpp
+++ b/src/other_tools/just_mr/update.hpp
@@ -25,7 +25,7 @@
[[nodiscard]] auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
MultiRepoCommonArguments const& common_args,
MultiRepoUpdateArguments const& update_args,
- StorageConfig const& storage_config,
+ StorageConfig const& native_storage_config,
std::string const& multi_repo_tool_name)
-> int;
diff --git a/src/other_tools/ops_maps/git_update_map.hpp b/src/other_tools/ops_maps/git_update_map.hpp
index 3c36a4b4..91377407 100644
--- a/src/other_tools/ops_maps/git_update_map.hpp
+++ b/src/other_tools/ops_maps/git_update_map.hpp
@@ -60,7 +60,8 @@ struct hash<RepoDescriptionForUpdating> {
GitCASPtr const& git_cas,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- gsl::not_null<StorageConfig const*> const& storage_config,
+ gsl::not_null<StorageConfig const*> const&
+ storage_config, // native storage config
gsl::not_null<JustMRStatistics*> const& stats,
gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> GitUpdateMap;