Repository: mesos Updated Branches: refs/heads/master 6b7cb57d6 -> f556d24f3
Moved docker registry related structs into the registry namespace. Review: https://reviews.apache.org/r/38941 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f556d24f Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f556d24f Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f556d24f Branch: refs/heads/master Commit: f556d24f345a8b4a484ff4affe65a92d76383380 Parents: 6b7cb57 Author: Jojy Varghese <[email protected]> Authored: Fri Oct 30 16:07:31 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Fri Oct 30 16:07:31 2015 -0700 ---------------------------------------------------------------------- .../provisioner/docker/registry_client.cpp | 15 ++-- .../provisioner/docker/registry_client.hpp | 74 +++++++++----------- .../containerizer/provisioner_docker_tests.cpp | 2 - 3 files changed, 42 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/f556d24f/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 d71e806..c260684 100644 --- a/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp +++ b/src/slave/containerizer/mesos/provisioner/docker/registry_client.cpp @@ -60,22 +60,21 @@ namespace slave { namespace docker { namespace registry { -using FileSystemLayerInfo = RegistryClient::FileSystemLayerInfo; -using ManifestResponse = RegistryClient::ManifestResponse; const Duration RegistryClient::DEFAULT_MANIFEST_TIMEOUT_SECS = Seconds(10); const size_t RegistryClient::DEFAULT_MANIFEST_MAXSIZE_BYTES = 4096; static const uint16_t DEFAULT_SSL_PORT = 443; + class RegistryClientProcess : public Process<RegistryClientProcess> { public: static Try<Owned<RegistryClientProcess>> create( const URL& registry, const URL& authServer, - const Option<RegistryClient::Credentials>& creds); + const Option<Credentials>& creds); - Future<RegistryClient::ManifestResponse> getManifest( + Future<ManifestResponse> getManifest( const string& path, const Option<string>& tag, const Duration& timeout); @@ -91,7 +90,7 @@ private: RegistryClientProcess( const URL& registryServer, const Owned<TokenManager>& tokenManager, - const Option<RegistryClient::Credentials>& creds); + const Option<Credentials>& creds); Future<http::Response> doHttpGet( const URL& url, @@ -105,7 +104,7 @@ private: const URL registryServer_; Owned<TokenManager> tokenManager_; - const Option<RegistryClient::Credentials> credentials_; + const Option<Credentials> credentials_; RegistryClientProcess(const RegistryClientProcess&) = delete; RegistryClientProcess& operator = (const RegistryClientProcess&) = delete; @@ -190,7 +189,7 @@ Future<size_t> RegistryClient::getBlob( Try<Owned<RegistryClientProcess>> RegistryClientProcess::create( const URL& registryServer, const URL& authServer, - const Option<RegistryClient::Credentials>& creds) + const Option<Credentials>& creds) { Try<Owned<TokenManager>> tokenMgr = TokenManager::create(authServer); if (tokenMgr.isError()) { @@ -205,7 +204,7 @@ Try<Owned<RegistryClientProcess>> RegistryClientProcess::create( RegistryClientProcess::RegistryClientProcess( const URL& registryServer, const Owned<TokenManager>& tokenMgr, - const Option<RegistryClient::Credentials>& creds) + const Option<Credentials>& creds) : registryServer_(registryServer), tokenManager_(tokenMgr), credentials_(creds) {} http://git-wip-us.apache.org/repos/asf/mesos/blob/f556d24f/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 1d3377e..c47b133 100644 --- a/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp +++ b/src/slave/containerizer/mesos/provisioner/docker/registry_client.hpp @@ -41,49 +41,45 @@ namespace registry { class RegistryClientProcess; -class RegistryClient +// TODO(bmahler): Replace these with the existing protobuf counterparts. + + +struct FileSystemLayerInfo { -public: - /** - * Encapsulates information about a file system layer. - */ - struct FileSystemLayerInfo { - // TODO(jojy): This string includes the checksum type also now. Need to - // separate this into checksum method and checksum. - const std::string checksumInfo; - const std::string layerId; - }; + // TODO(jojy): This includes both the checksum and + // the type of the checksum; separate these. + const std::string checksumInfo; + const std::string layerId; +}; - /** - * Encapsulates response of "GET Manifest" request. - * - * Reference: https://docs.docker.com/registry/spec/api - */ - struct ManifestResponse { - const std::string name; - const std::string digest; - const std::vector<FileSystemLayerInfo> fsLayerInfoList; - }; - /** - * Encapsulates auth credentials for the client sessions. - * TODO(jojy): Secure heap to protect the credentials. - */ - struct Credentials { - /** - * UserId for basic authentication. - */ - const Option<std::string> userId; - /** - * Password for basic authentication. - */ - const Option<std::string> password; - /** - * Account for fetching data from registry. - */ - const Option<std::string> account; - }; +/** + * Response for a "GET Manifest" request. + * + * Reference: https://docs.docker.com/registry/spec/api + */ +struct ManifestResponse +{ + const std::string name; + const std::string digest; + const std::vector<FileSystemLayerInfo> fsLayerInfos; +}; + +/** + * Authentication credentials for the client sessions. + */ +struct Credentials +{ + const Option<std::string> userId; + const Option<std::string> password; + const Option<std::string> account; +}; + + +class RegistryClient +{ +public: /** * Factory method for creating RegistryClient objects. * http://git-wip-us.apache.org/repos/asf/mesos/blob/f556d24f/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 7894368..99c2af7 100644 --- a/src/tests/containerizer/provisioner_docker_tests.cpp +++ b/src/tests/containerizer/provisioner_docker_tests.cpp @@ -64,8 +64,6 @@ using namespace mesos::internal::slave::docker; using namespace mesos::internal::slave::docker::paths; using namespace mesos::internal::slave::docker::registry; -using ManifestResponse = RegistryClient::ManifestResponse; - namespace mesos { namespace internal { namespace tests {
