diff options
Diffstat (limited to 'src/other_tools/just_mr/mirrors.hpp')
-rw-r--r-- | src/other_tools/just_mr/mirrors.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/mirrors.hpp b/src/other_tools/just_mr/mirrors.hpp index 47fc98be..7480a839 100644 --- a/src/other_tools/just_mr/mirrors.hpp +++ b/src/other_tools/just_mr/mirrors.hpp @@ -34,6 +34,7 @@ struct Mirrors { nlohmann::json local_mirrors; // maps URLs to list of local mirrors nlohmann::json preferred_hostnames; // list of mirror hostnames + nlohmann::json extra_inherit_env; }; using MirrorsPtr = std::shared_ptr<Mirrors>; @@ -105,6 +106,36 @@ namespace MirrorsUtils { }; } +/// \brief Get the list of extra variables to inherit. +[[nodiscard]] static inline auto GetInheritEnv( + MirrorsPtr const& additional_mirrors, + std::vector<std::string> const& base) noexcept -> std::vector<std::string> { + try { + std::vector<std::string> res(base); + res.reserve(additional_mirrors->extra_inherit_env.size() + base.size()); + for (auto const& [_, val] : + additional_mirrors->extra_inherit_env.items()) { + if (val.is_string()) { + res.emplace_back(val.get<std::string>()); + } + else { + Logger::Log( + LogLevel::Warning, + "Retrieving extra variables to inherit: found non-string " + "list entry {}", + val.dump()); + } + } + return res; + } catch (std::exception const& ex) { + Logger::Log(LogLevel::Warning, + "Retrieving extra environment variables to inherit failed " + "with:\n{}", + ex.what()); + return {}; + }; +} + /// \brief Sort mirrors by the order of given hostnames. [[nodiscard]] static inline auto SortByHostname( std::vector<std::string> const& mirrors, |