{"action":"created","comment":{"url":"https://api.github.com/repos/docker/distribution/pulls/comments/50207391","id":50207391,"diff_hunk":"@@ -0,0 +1,370 @@\n+// Package hdfsweb provides a storagedriver.StorageDriver implementation to\n+// store blobs in Hadoop HDFS cloud storage.\n+//\n+// This package leverages the vladimirvivien/gowfs client functions for\n+// interfacing with Hadoop HDFS.\n+package hdfsweb\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"os\"\n+\t\"os/user\"\n+\t\"path\"\n+\t\"path/filepath\"\n+\t\"reflect\"\n+\t\"time\"\n+\n+\t\"github.com/docker/distribution/context\"\n+\tstoragedriver \"github.com/docker/distribution/registry/storage/driver\"\n+\t\"github.com/docker/distribution/registry/storage/driver/base\"\n+\t\"github.com/docker/distribution/registry/storage/driver/factory\"\n+)\n+\n+const (\n+\tdriverName         = \"hdfsweb\"\n+\tdefaultBufferSize  = 4096\n+\tdefaultBlockSize   = 64 << 20\n+\tdefaultReplication = 1\n+)\n+\n+//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set\n+type DriverParameters struct {\n+\tNameNodeHost  string\n+\tNameNodePort  string\n+\tRootDirectory string\n+\tBlockSize     int\n+\tBufferSize    int\n+\tReplication   int\n+}\n+\n+func init() {\n+\tfactory.Register(driverName, &hdfsDriverFactory{})\n+}\n+\n+// hdfsDriverFactory implements the factory.StorageDriverFactory interface\n+type hdfsDriverFactory struct{}\n+\n+func (factory *hdfsDriverFactory) Create(parameters map[string]interface{}) (storagedriver.StorageDriver, error) {\n+\treturn FromParameters(parameters)\n+}\n+\n+type driver struct {\n+\tfs             *FileSystem\n+\tRootDirectory  string\n+\tLocalDirectory string\n+}\n+\n+type baseEmbed struct {\n+\tbase.Base\n+}\n+\n+// Driver is a storagedriver.StorageDriver implementation backed by a local\n+// hdfs. All provided paths will be subpaths of the RootDirectory.\n+type Driver struct {\n+\tbaseEmbed\n+}\n+\n+// FromParameters constructs a new Driver with a given parameters map\n+// Optional Parameters:\n+func FromParameters(parameters map[string]interface{}) (*Driver, error) {\n+\tparams := DriverParameters{\n+\t\tBlockSize:   defaultBlockSize,\n+\t\tBufferSize:  defaultBufferSize,\n+\t\tReplication: defaultReplication,\n+\t}\n+\n+\tif parameters != nil {\n+\t\tif v, ok := parameters[\"namenodehost\"]; ok {\n+\t\t\tparams.NameNodeHost = fmt.Sprint(v)\n+\t\t} else {\n+\t\t\treturn nil, fmt.Errorf(\"parameter doesn't provided\")\n+\t\t}\n+\n+\t\tif v, ok := parameters[\"namenodeport\"]; ok {\n+\t\t\tparams.NameNodePort = fmt.Sprint(v)\n+\t\t} else {\n+\t\t\treturn nil, fmt.Errorf(\"parameter doesn't provided\")\n+\t\t}\n+\n+\t\tif v, ok := parameters[\"rootdirectory\"]; ok {\n+\t\t\tparams.RootDirectory = fmt.Sprint(v)\n+\t\t} else {\n+\t\t\treturn nil, fmt.Errorf(\"parameter doesn't provided\")\n+\t\t}\n+\n+\t\tif v, ok := parameters[\"blocksize\"]; ok {\n+\t\t\tparams.BlockSize = v.(int)\n+\t\t}\n+\n+\t\tif v, ok := parameters[\"buffersize\"]; ok {\n+\t\t\tparams.BufferSize = v.(int)\n+\t\t}\n+\n+\t\tif v, ok := parameters[\"replication\"]; ok {\n+\t\t\tparams.Replication = v.(int)\n+\t\t}\n+\n+\t}\n+\treturn New(params)\n+}\n+\n+// New constructs a new Driver with given parameters\n+func New(params DriverParameters) (*Driver, error) {\n+\tusr, err := user.Current()\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\ttempDir := filepath.Join(os.TempDir(), \"v2\")\n+\tif !checkFileExist(tempDir) {\n+\t\terr := os.MkdirAll(tempDir, 0777)\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t}\n+\n+\treturn &Driver{\n+\t\tbaseEmbed: baseEmbed{\n+\t\t\tBase: base.Base{\n+\t\t\t\tStorageDriver: &driver{\n+\t\t\t\t\tfs: &FileSystem{\n+\t\t\t\t\t\tNameNodeHost: params.NameNodeHost,\n+\t\t\t\t\t\tNameNodePort: params.NameNodePort,\n+\t\t\t\t\t\tUsername:     usr.Username,","path":"registry/storage/driver/hdfsweb/hdfs.go","position":136,"original_position":136,"commit_id":"6f3986d1335c888df7e6664f436801fb8e50f0d3","original_commit_id":"6f3986d1335c888df7e6664f436801fb8e50f0d3","user":{"login":"xiekeyang","id":9944031,"avatar_url":"https://avatars.githubusercontent.com/u/9944031?v=3","gravatar_id":"","url":"https://api.github.com/users/xiekeyang","html_url":"https://github.com/xiekeyang","followers_url":"https://api.github.com/users/xiekeyang/followers","following_url":"https://api.github.com/users/xiekeyang/following{/other_user}","gists_url":"https://api.github.com/users/xiekeyang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiekeyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiekeyang/subscriptions","organizations_url":"https://api.github.com/users/xiekeyang/orgs","repos_url":"https://api.github.com/users/xiekeyang/repos","events_url":"https://api.github.com/users/xiekeyang/events{/privacy}","received_events_url":"https://api.github.com/users/xiekeyang/received_events","type":"User","site_admin":false},"body":"@aaronlehmann  You are right! I didn't consider this. So I would add user to configuration.","created_at":"2016-01-20T02:22:33Z","updated_at":"2016-01-20T02:22:33Z","html_url":"https://github.com/docker/distribution/pull/1123#discussion_r50207391","pull_request_url":"https://api.github.com/repos/docker/distribution/pulls/1123","_links":{"self":{"href":"https://api.github.com/repos/docker/distribution/pulls/comments/50207391"},"html":{"href":"https://github.com/docker/distribution/pull/1123#discussion_r50207391"},"pull_request":{"href":"https://api.github.com/repos/docker/distribution/pulls/1123"}}},"pull_request":{"url":"https://api.github.com/repos/docker/distribution/pulls/1123","id":48675108,"html_url":"https://github.com/docker/distribution/pull/1123","diff_url":"https://github.com/docker/distribution/pull/1123.diff","patch_url":"https://github.com/docker/distribution/pull/1123.patch","issue_url":"https://api.github.com/repos/docker/distribution/issues/1123","number":1123,"state":"open","locked":false,"title":"add hdfs storage driver","user":{"login":"xiekeyang","id":9944031,"avatar_url":"https://avatars.githubusercontent.com/u/9944031?v=3","gravatar_id":"","url":"https://api.github.com/users/xiekeyang","html_url":"https://github.com/xiekeyang","followers_url":"https://api.github.com/users/xiekeyang/followers","following_url":"https://api.github.com/users/xiekeyang/following{/other_user}","gists_url":"https://api.github.com/users/xiekeyang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiekeyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiekeyang/subscriptions","organizations_url":"https://api.github.com/users/xiekeyang/orgs","repos_url":"https://api.github.com/users/xiekeyang/repos","events_url":"https://api.github.com/users/xiekeyang/events{/privacy}","received_events_url":"https://api.github.com/users/xiekeyang/received_events","type":"User","site_admin":false},"body":"This is for issue #1086 .\r\n\r\nThis PR build `hdfs` package as HDFS Driver Factory,\r\nto presents HDFS Storage Driver to distribution.\r\n\r\nThis allows distribution client to access Apache Hadoop\r\nDistributed File System server. The connection protocal\r\nis `WebHDFS REST API`, provided by Apache official.\r\n\r\nSigned-off-by: xiekeyang <xiekeyang@huawei.com>","created_at":"2015-10-25T09:39:22Z","updated_at":"2016-01-20T02:22:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e15a66f9c28dbaf56f2a8a16ce1da23f0d18ed5f","assignee":null,"milestone":{"url":"https://api.github.com/repos/docker/distribution/milestones/12","html_url":"https://github.com/docker/distribution/milestones/Registry/2.3","labels_url":"https://api.github.com/repos/docker/distribution/milestones/12/labels","id":1223114,"number":12,"title":"Registry/2.3","description":"","creator":{"login":"dmp42","id":332946,"avatar_url":"https://avatars.githubusercontent.com/u/332946?v=3","gravatar_id":"","url":"https://api.github.com/users/dmp42","html_url":"https://github.com/dmp42","followers_url":"https://api.github.com/users/dmp42/followers","following_url":"https://api.github.com/users/dmp42/following{/other_user}","gists_url":"https://api.github.com/users/dmp42/gists{/gist_id}","starred_url":"https://api.github.com/users/dmp42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmp42/subscriptions","organizations_url":"https://api.github.com/users/dmp42/orgs","repos_url":"https://api.github.com/users/dmp42/repos","events_url":"https://api.github.com/users/dmp42/events{/privacy}","received_events_url":"https://api.github.com/users/dmp42/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":9,"state":"open","created_at":"2015-07-24T01:24:13Z","updated_at":"2016-01-19T19:00:47Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/docker/distribution/pulls/1123/commits","review_comments_url":"https://api.github.com/repos/docker/distribution/pulls/1123/comments","review_comment_url":"https://api.github.com/repos/docker/distribution/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/distribution/issues/1123/comments","statuses_url":"https://api.github.com/repos/docker/distribution/statuses/6f3986d1335c888df7e6664f436801fb8e50f0d3","head":{"label":"xiekeyang:drv-hdfs","ref":"drv-hdfs","sha":"6f3986d1335c888df7e6664f436801fb8e50f0d3","user":{"login":"xiekeyang","id":9944031,"avatar_url":"https://avatars.githubusercontent.com/u/9944031?v=3","gravatar_id":"","url":"https://api.github.com/users/xiekeyang","html_url":"https://github.com/xiekeyang","followers_url":"https://api.github.com/users/xiekeyang/followers","following_url":"https://api.github.com/users/xiekeyang/following{/other_user}","gists_url":"https://api.github.com/users/xiekeyang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiekeyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiekeyang/subscriptions","organizations_url":"https://api.github.com/users/xiekeyang/orgs","repos_url":"https://api.github.com/users/xiekeyang/repos","events_url":"https://api.github.com/users/xiekeyang/events{/privacy}","received_events_url":"https://api.github.com/users/xiekeyang/received_events","type":"User","site_admin":false},"repo":{"id":29467212,"name":"distribution","full_name":"xiekeyang/distribution","owner":{"login":"xiekeyang","id":9944031,"avatar_url":"https://avatars.githubusercontent.com/u/9944031?v=3","gravatar_id":"","url":"https://api.github.com/users/xiekeyang","html_url":"https://github.com/xiekeyang","followers_url":"https://api.github.com/users/xiekeyang/followers","following_url":"https://api.github.com/users/xiekeyang/following{/other_user}","gists_url":"https://api.github.com/users/xiekeyang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiekeyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiekeyang/subscriptions","organizations_url":"https://api.github.com/users/xiekeyang/orgs","repos_url":"https://api.github.com/users/xiekeyang/repos","events_url":"https://api.github.com/users/xiekeyang/events{/privacy}","received_events_url":"https://api.github.com/users/xiekeyang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xiekeyang/distribution","description":"The Docker toolset to pack, ship, store, and deliver content","fork":true,"url":"https://api.github.com/repos/xiekeyang/distribution","forks_url":"https://api.github.com/repos/xiekeyang/distribution/forks","keys_url":"https://api.github.com/repos/xiekeyang/distribution/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiekeyang/distribution/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiekeyang/distribution/teams","hooks_url":"https://api.github.com/repos/xiekeyang/distribution/hooks","issue_events_url":"https://api.github.com/repos/xiekeyang/distribution/issues/events{/number}","events_url":"https://api.github.com/repos/xiekeyang/distribution/events","assignees_url":"https://api.github.com/repos/xiekeyang/distribution/assignees{/user}","branches_url":"https://api.github.com/repos/xiekeyang/distribution/branches{/branch}","tags_url":"https://api.github.com/repos/xiekeyang/distribution/tags","blobs_url":"https://api.github.com/repos/xiekeyang/distribution/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiekeyang/distribution/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiekeyang/distribution/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiekeyang/distribution/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiekeyang/distribution/statuses/{sha}","languages_url":"https://api.github.com/repos/xiekeyang/distribution/languages","stargazers_url":"https://api.github.com/repos/xiekeyang/distribution/stargazers","contributors_url":"https://api.github.com/repos/xiekeyang/distribution/contributors","subscribers_url":"https://api.github.com/repos/xiekeyang/distribution/subscribers","subscription_url":"https://api.github.com/repos/xiekeyang/distribution/subscription","commits_url":"https://api.github.com/repos/xiekeyang/distribution/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiekeyang/distribution/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiekeyang/distribution/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiekeyang/distribution/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiekeyang/distribution/contents/{+path}","compare_url":"https://api.github.com/repos/xiekeyang/distribution/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiekeyang/distribution/merges","archive_url":"https://api.github.com/repos/xiekeyang/distribution/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiekeyang/distribution/downloads","issues_url":"https://api.github.com/repos/xiekeyang/distribution/issues{/number}","pulls_url":"https://api.github.com/repos/xiekeyang/distribution/pulls{/number}","milestones_url":"https://api.github.com/repos/xiekeyang/distribution/milestones{/number}","notifications_url":"https://api.github.com/repos/xiekeyang/distribution/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiekeyang/distribution/labels{/name}","releases_url":"https://api.github.com/repos/xiekeyang/distribution/releases{/id}","created_at":"2015-01-19T11:13:26Z","updated_at":"2016-01-16T10:58:34Z","pushed_at":"2016-01-19T10:01:49Z","git_url":"git://github.com/xiekeyang/distribution.git","ssh_url":"git@github.com:xiekeyang/distribution.git","clone_url":"https://github.com/xiekeyang/distribution.git","svn_url":"https://github.com/xiekeyang/distribution","homepage":null,"size":7928,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"3cb403ae5b7e7dde77caf41695ff5342f7b9a475","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":28366058,"name":"distribution","full_name":"docker/distribution","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/distribution","description":"The Docker toolset to pack, ship, store, and deliver content","fork":false,"url":"https://api.github.com/repos/docker/distribution","forks_url":"https://api.github.com/repos/docker/distribution/forks","keys_url":"https://api.github.com/repos/docker/distribution/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/distribution/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/distribution/teams","hooks_url":"https://api.github.com/repos/docker/distribution/hooks","issue_events_url":"https://api.github.com/repos/docker/distribution/issues/events{/number}","events_url":"https://api.github.com/repos/docker/distribution/events","assignees_url":"https://api.github.com/repos/docker/distribution/assignees{/user}","branches_url":"https://api.github.com/repos/docker/distribution/branches{/branch}","tags_url":"https://api.github.com/repos/docker/distribution/tags","blobs_url":"https://api.github.com/repos/docker/distribution/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/distribution/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/distribution/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/distribution/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/distribution/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/distribution/languages","stargazers_url":"https://api.github.com/repos/docker/distribution/stargazers","contributors_url":"https://api.github.com/repos/docker/distribution/contributors","subscribers_url":"https://api.github.com/repos/docker/distribution/subscribers","subscription_url":"https://api.github.com/repos/docker/distribution/subscription","commits_url":"https://api.github.com/repos/docker/distribution/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/distribution/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/distribution/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/distribution/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/distribution/contents/{+path}","compare_url":"https://api.github.com/repos/docker/distribution/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/distribution/merges","archive_url":"https://api.github.com/repos/docker/distribution/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/distribution/downloads","issues_url":"https://api.github.com/repos/docker/distribution/issues{/number}","pulls_url":"https://api.github.com/repos/docker/distribution/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/distribution/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/distribution/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/distribution/labels{/name}","releases_url":"https://api.github.com/repos/docker/distribution/releases{/id}","created_at":"2014-12-22T23:49:26Z","updated_at":"2016-01-19T22:25:36Z","pushed_at":"2016-01-19T19:21:59Z","git_url":"git://github.com/docker/distribution.git","ssh_url":"git@github.com:docker/distribution.git","clone_url":"https://github.com/docker/distribution.git","svn_url":"https://github.com/docker/distribution","homepage":null,"size":10692,"stargazers_count":1608,"watchers_count":1608,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":611,"mirror_url":null,"open_issues_count":167,"forks":611,"open_issues":167,"watchers":1608,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/distribution/pulls/1123"},"html":{"href":"https://github.com/docker/distribution/pull/1123"},"issue":{"href":"https://api.github.com/repos/docker/distribution/issues/1123"},"comments":{"href":"https://api.github.com/repos/docker/distribution/issues/1123/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/distribution/pulls/1123/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/distribution/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/distribution/pulls/1123/commits"},"statuses":{"href":"https://api.github.com/repos/docker/distribution/statuses/6f3986d1335c888df7e6664f436801fb8e50f0d3"}}}}