-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to provide tokens for authentication with the remote image registry. * add `--token` and `--username` flags to `uenv image pull` * use the current user's username as the default if `--token` is set, but `--username` is not * add support for optional credentials to all oras calls fixes #34
- Loading branch information
Showing
10 changed files
with
210 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,54 @@ | ||
#pragma once | ||
|
||
#include <filesystem> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <fmt/core.h> | ||
|
||
#include <uenv/uenv.h> | ||
|
||
namespace uenv { | ||
namespace oras { | ||
|
||
struct credentials { | ||
std::string username; | ||
std::string token; | ||
}; | ||
|
||
bool pull(std::string rego, std::string nspace); | ||
|
||
util::expected<std::vector<std::string>, std::string> | ||
discover(const std::string& registry, const std::string& nspace, | ||
const uenv_record& uenv); | ||
const uenv_record& uenv, | ||
const std::optional<credentials> token = std::nullopt); | ||
|
||
util::expected<void, int> pull_digest(const std::string& registry, | ||
const std::string& nspace, | ||
const uenv_record& uenv, | ||
const std::string& digest, | ||
const std::filesystem::path& destination); | ||
util::expected<void, int> | ||
pull_digest(const std::string& registry, const std::string& nspace, | ||
const uenv_record& uenv, const std::string& digest, | ||
const std::filesystem::path& destination, | ||
const std::optional<credentials> token = std::nullopt); | ||
|
||
util::expected<void, int> pull_tag(const std::string& registry, | ||
const std::string& nspace, | ||
const uenv_record& uenv, | ||
const std::filesystem::path& destination); | ||
util::expected<void, int> | ||
pull_tag(const std::string& registry, const std::string& nspace, | ||
const uenv_record& uenv, const std::filesystem::path& destination, | ||
const std::optional<credentials> token = std::nullopt); | ||
|
||
} // namespace oras | ||
} // namespace uenv | ||
|
||
template <> class fmt::formatter<uenv::oras::credentials> { | ||
public: | ||
// parse format specification and store it: | ||
constexpr auto parse(format_parse_context& ctx) { | ||
return ctx.end(); | ||
} | ||
// format a value using stored specification: | ||
template <typename FmtContext> | ||
constexpr auto format(uenv::oras::credentials const& c, | ||
FmtContext& ctx) const { | ||
// replace token characters with 'X' | ||
return fmt::format_to(ctx.out(), "{{username: {}, token: {:X>{}}}}", | ||
c.username, "", c.token.size()); | ||
} | ||
}; |
Oops, something went wrong.