Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Channel refactoring #2852

Merged
merged 10 commits into from
Sep 26, 2023
22 changes: 10 additions & 12 deletions libmamba/include/mamba/core/channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "mamba/specs/conda_url.hpp"


namespace mamba
{
class Context;
Expand Down Expand Up @@ -46,9 +45,11 @@ namespace mamba
const std::string& name() const;
const std::string& canonical_name() const;
const std::vector<std::string>& platforms() const;
const std::optional<std::string>& auth() const;
const std::optional<std::string>& token() const;
const std::optional<std::string>& package_filename() const;
std::optional<std::string> auth() const;
std::optional<std::string> user() const;
std::optional<std::string> password() const;
std::optional<std::string> token() const;
std::optional<std::string> package_filename() const;
const validation::RepoChecker&
repo_checker(Context& context, MultiPackageCache& caches) const;

Expand All @@ -62,24 +63,21 @@ namespace mamba
private:

Channel(
std::string scheme,
std::string_view scheme,
std::string location,
std::string name,
std::string canonical_name,
std::optional<std::string> auth = {},
std::optional<std::string> token = {},
std::optional<std::string> package_filename = {}
std::string_view user = {},
std::string_view password = {},
std::string_view token = {},
std::string_view package_filename = {}
);

specs::CondaURL m_url;
std::string m_scheme;
std::string m_location;
std::string m_name;
std::string m_canonical_name;
std::vector<std::string> m_platforms;
std::optional<std::string> m_auth;
std::optional<std::string> m_token;
std::optional<std::string> m_package_filename;

// This is used to make sure that there is a unique repo for every channel
mutable std::unique_ptr<validation::RepoChecker> p_repo_checker;
Expand Down
7 changes: 6 additions & 1 deletion libmamba/include/mamba/specs/conda_url.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ namespace mamba::specs
/** Return the Conda token, as delimited with "/t/", or empty if there isn't any. */
[[nodiscard]] auto token() const -> std::string_view;

/** Set a token if the URL already contains one, or throw an error. */
/**
* Set a token.
*
* If the URL already contains one replace it at the same location, otherwise, add it at
* the begining of the path.
*/
void set_token(std::string_view token);

/** Clear the token and return ``true`` if it exists, otherwise return ``false``. */
Expand Down
3 changes: 3 additions & 0 deletions libmamba/include/mamba/specs/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace mamba::specs
win_32,
win_64,
win_arm64,
zos_z,

// For reflexion purposes only
count_,
Expand Down Expand Up @@ -120,6 +121,8 @@ namespace mamba::specs
return "win-64";
case Platform::win_arm64:
return "win-arm64";
case Platform::zos_z:
return "zos-z";
default:
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/util/url.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace mamba::util
auto clear_fragment() -> std::string;

/** Return the full, exact, encoded URL. */
[[nodiscard]] auto str() -> std::string;
[[nodiscard]] auto str() const -> std::string;

/**
* Return the full decoded url.
Expand Down
Loading