Skip to content

Commit

Permalink
Add Channel::resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Nov 15, 2023
1 parent 891a4bb commit c85659f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions libmamba/include/mamba/core/channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace mamba

using platform_list = util::flat_set<std::string>;

[[nodiscard]] static auto resolve(specs::ChannelSpec spec, ResolveParams params) -> Channel;

Channel(specs::CondaURL url, std::string display_name, util::flat_set<std::string> platforms = {});

[[nodiscard]] auto url() const -> const specs::CondaURL&;
Expand Down
28 changes: 16 additions & 12 deletions libmamba/src/core/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,8 @@ namespace mamba
}
}

Channel ChannelContext::from_value(const std::string& in_value)
auto Channel::resolve(specs::ChannelSpec spec, ResolveParams params) -> Channel
{
auto spec = specs::ChannelSpec::parse(in_value);
const auto platforms = [](const auto& plats) {
return Channel::ResolveParams::platform_list(plats.cbegin(), plats.cend());
}(m_context.platforms());
auto params = Channel::ResolveParams{
/* .platforms */ platforms,
/* .channel_alias */ m_channel_alias,
/* .custom_channels */ m_custom_channels,
/* .auth_db */ m_context.authentication_info(),
};

switch (spec.type())
{
case specs::ChannelSpec::Type::PackagePath:
Expand All @@ -383,6 +372,21 @@ namespace mamba
throw std::invalid_argument("Invalid ChannelSpec::Type");
}

Channel ChannelContext::from_value(const std::string& in_value)
{
auto spec = specs::ChannelSpec::parse(in_value);
const auto platforms = [](const auto& plats) {
return Channel::ResolveParams::platform_list(plats.cbegin(), plats.cend());
}(m_context.platforms());
auto params = Channel::ResolveParams{
/* .platforms */ platforms,
/* .channel_alias */ m_channel_alias,
/* .custom_channels */ m_custom_channels,
/* .auth_db */ m_context.authentication_info(),
};
return Channel::resolve(std::move(spec), params);
}

const Channel& ChannelContext::make_channel(const std::string& value)
{
if (const auto it = m_channel_cache.find(value); it != m_channel_cache.end())
Expand Down

0 comments on commit c85659f

Please sign in to comment.