Repository: mesos
Updated Branches:
  refs/heads/master dcf88243e -> 73463b40b


Changed getManifest interface in registry client.

Review: https://reviews.apache.org/r/39839


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e071314b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e071314b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e071314b

Branch: refs/heads/master
Commit: e071314be47564af1f1a24bc8d1bf1f25b553e93
Parents: 3a9de5a
Author: Jojy Varghese <[email protected]>
Authored: Thu Nov 5 18:49:13 2015 -0800
Committer: Timothy Chen <[email protected]>
Committed: Thu Nov 5 22:28:05 2015 -0800

----------------------------------------------------------------------
 .../provisioner/docker/registry_client.cpp      | 23 +++++---------------
 .../provisioner/docker/registry_client.hpp      | 10 ++++-----
 .../containerizer/provisioner_docker_tests.cpp  |  4 +++-
 3 files changed, 13 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e071314b/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp
----------------------------------------------------------------------
diff --git 
a/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp 
b/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp
index e9fb776..0077bfd 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp
@@ -73,8 +73,7 @@ public:
       const Option<Credentials>& creds);
 
   Future<Manifest> getManifest(
-      const string& path,
-      const Option<string>& tag,
+      const Image::Name& imageName,
       const Duration& timeout);
 
   Future<size_t> getBlob(
@@ -148,8 +147,7 @@ RegistryClient::~RegistryClient()
 
 
 Future<Manifest> RegistryClient::getManifest(
-    const string& _path,
-    const Option<string>& _tag,
+    const Image::Name& imageName,
     const Option<Duration>& _timeout)
 {
   Duration timeout = _timeout.getOrElse(DEFAULT_MANIFEST_TIMEOUT_SECS);
@@ -157,8 +155,7 @@ Future<Manifest> RegistryClient::getManifest(
   return dispatch(
       process_.get(),
       &RegistryClientProcess::getManifest,
-      _path,
-      _tag,
+      imageName,
       timeout);
 }
 
@@ -453,22 +450,12 @@ Future<http::Response> RegistryClientProcess::doHttpGet(
 
 
 Future<Manifest> RegistryClientProcess::getManifest(
-    const string& path,
-    const Option<string>& tag,
+    const Image::Name& imageName,
     const Duration& timeout)
 {
-  if (strings::contains(path, " ")) {
-    return Failure("Invalid repository path: " + path);
-  }
-
-  string repoTag = tag.getOrElse("latest");
-  if (strings::contains(repoTag, " ")) {
-    return Failure("Invalid repository tag: " + repoTag);
-  }
-
   http::URL manifestURL(registryServer_);
   manifestURL.path =
-    "v2/" + path + "/manifests/" + repoTag;
+    "v2/" + imageName.repository() + "/manifests/" + imageName.tag();
 
   auto getManifest = [](const http::Response& httpResponse) -> Try<Manifest> {
     if (!httpResponse.headers.contains("Docker-Content-Digest")) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/e071314b/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp
----------------------------------------------------------------------
diff --git 
a/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp 
b/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp
index ad57d85..92edb17 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp
@@ -31,6 +31,8 @@
 #include <process/http.hpp>
 #include <process/process.hpp>
 
+#include "slave/containerizer/mesos/provisioner/docker/message.hpp"
+
 namespace mesos {
 namespace internal {
 namespace slave {
@@ -97,19 +99,17 @@ public:
   /**
    * Fetches manifest for a repository from the client's remote registry 
server.
    *
-   * @param path path of the repository on the registry.
-   * @param tag unique tag that identifies the repository. Will default to
-   *    latest.
+   * @param imageName Image information(Name, tag).
    * @param timeout Maximum time ater which the request will timeout and return
    *    a failure. Will default to RESPONSE_TIMEOUT.
    * @return JSON object on success.
    *         Failure on process failure.
    */
   process::Future<Manifest> getManifest(
-      const std::string& path,
-      const Option<std::string>& tag,
+      const Image::Name& imageName,
       const Option<Duration>& timeout);
 
+
   /**
    * Fetches blob for a repository from the client's remote registry server.
    *

http://git-wip-us.apache.org/repos/asf/mesos/blob/e071314b/src/tests/containerizer/provisioner_docker_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/provisioner_docker_tests.cpp 
b/src/tests/containerizer/provisioner_docker_tests.cpp
index 8d90894..67e190e 100644
--- a/src/tests/containerizer/provisioner_docker_tests.cpp
+++ b/src/tests/containerizer/provisioner_docker_tests.cpp
@@ -687,7 +687,9 @@ TEST_F(RegistryClientTest, SimpleGetManifest)
   ASSERT_SOME(registryClient);
 
   Future<Manifest> manifestResponseFuture =
-    registryClient.get()->getManifest("library/busybox", "latest", None());
+    registryClient.get()->getManifest(
+        parseImageName("library/busybox"),
+        None());
 
   const string unauthResponseHeaders = "Www-Authenticate: Bearer"
     " realm=\"https://auth.docker.io/token\",";

Reply via email to