[prev in list] [next in list] [prev in thread] [next in thread]
List: mesos-commits
Subject: [mesos] 03/06: Factored out common code for building URIs on a registry host.
From: asekretenko () apache ! org
Date: 2020-02-26 17:52:19
Message-ID: 20200226175216.4967F8DACE () gitbox ! apache ! org
[Download RAW message or body]
This is an automated email from the ASF dual-hosted git repository.
asekretenko pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit b465312d4609d7528afa9fffd1ec5ee661ef0657
Author: Andrei Sekretenko <asekretenko@mesosphere.com>
AuthorDate: Thu Jan 30 12:39:31 2020 +0100
Factored out common code for building URIs on a registry host.
This is a prerequisite for adding fallback authorization server URI
generation (see MESOS-10092) in the next patches, which will need one
more URI extractor similar to `getManifestUri()`/`getBlobUri()`.
Review: https://reviews.apache.org/r/72077
---
src/uri/fetchers/docker.cpp | 61 +++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 32 deletions(-)
diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
index 0ca980c..5fb0e93 100644
--- a/src/uri/fetchers/docker.cpp
+++ b/src/uri/fetchers/docker.cpp
@@ -438,6 +438,35 @@ static http::Headers getAuthHeaderBearer(
return headers;
}
+
+static URI constructRegistryUri(const URI& imageUri, string&& path)
+{
+ const string scheme = imageUri.has_fragment() ? imageUri.fragment() : "https";
+ return uri::construct(
+ scheme,
+ std::move(path),
+ imageUri.host(),
+ (imageUri.has_port() ? Option<int>(imageUri.port()) : None()));
+}
+
+
+static URI getManifestUri(const URI& imageUri)
+{
+ return constructRegistryUri(
+ imageUri,
+ strings::join(
+ "/", "/v2", imageUri.path(), "manifests", imageUri.query()));
+}
+
+
+static URI getBlobUri(const URI& imageUri)
+{
+ return constructRegistryUri(
+ imageUri,
+ strings::join("/", "/v2", imageUri.path(), "blobs", imageUri.query()));
+}
+
+
//-------------------------------------------------------------------
// DockerFetcherPlugin implementation.
//-------------------------------------------------------------------
@@ -510,9 +539,6 @@ private:
const http::Headers& basicAuthHeaders,
const http::Response& response);
- URI getManifestUri(const URI& uri);
- URI getBlobUri(const URI& uri);
-
// This is a lookup table for credentials in docker config file,
// keyed by registry URL.
// For example, "https://index.docker.io/v1/" -> spec::Config::Auth
@@ -1130,34 +1156,5 @@ Future<http::Headers> DockerFetcherPluginProcess::getAuthHeader(
}
-URI DockerFetcherPluginProcess::getManifestUri(const URI& uri)
-{
- string scheme = "https";
- if (uri.has_fragment()) {
- scheme = uri.fragment();
- }
-
- return uri::construct(
- scheme,
- strings::join("/", "/v2", uri.path(), "manifests", uri.query()),
- uri.host(),
- (uri.has_port() ? Option<int>(uri.port()) : None()));
-}
-
-
-URI DockerFetcherPluginProcess::getBlobUri(const URI& uri)
-{
- string scheme = "https";
- if (uri.has_fragment()) {
- scheme = uri.fragment();
- }
-
- return uri::construct(
- scheme,
- strings::join("/", "/v2", uri.path(), "blobs", uri.query()),
- uri.host(),
- (uri.has_port() ? Option<int>(uri.port()) : None()));
-}
-
} // namespace uri {
} // namespace mesos {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic