{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/28611470","id":28611470,"diff_hunk":"@@ -147,18 +152,58 @@ func decodeAuth(authStr string) (string, string, error) {\n \n // load up the auth config information and return values\n // FIXME: use the internal golang config parser\n-func LoadConfig(rootPath string) (*ConfigFile, error) {\n-\tconfigFile := ConfigFile{Configs: make(map[string]AuthConfig), rootPath: rootPath}\n-\tconfFile := path.Join(rootPath, CONFIGFILE)\n+func LoadConfig(configDir string) (*ConfigFile, error) {\n+\tif configDir == \"\" {\n+\t\tconfigDir = filepath.Join(homedir.Get(), \".docker\")\n+\t}\n+\n+\tconfigFile := ConfigFile{\n+\t\tAuthConfigs: make(map[string]AuthConfig),\n+\t\tfilename:    filepath.Join(configDir, CONFIGFILE),\n+\t}\n+\n+\t// Try happy path first - latest config file\n+\tif _, err := os.Stat(configFile.filename); err == nil {\n+\t\tdata, err := ioutil.ReadFile(configFile.filename)\n+\t\tif err != nil {\n+\t\t\treturn &configFile, err\n+\t\t}\n+\n+\t\terr = json.Unmarshal(data, &configFile)\n+\t\tif err != nil {\n+\t\t\treturn &configFile, err\n+\t\t}\n+\n+\t\tfor addr, ac := range configFile.AuthConfigs {\n+\t\t\tac.Username, ac.Password, err = decodeAuth(ac.Auth)\n+\t\t\tif err != nil {\n+\t\t\t\treturn &configFile, err\n+\t\t\t}\n+\t\t\tac.Auth = \"\"\n+\t\t\tac.ServerAddress = addr\n+\t\t\tconfigFile.AuthConfigs[addr] = ac\n+\t\t}\n+\n+\t\treturn &configFile, nil\n+\t} else if !os.IsNotExist(err) {\n+\t\t// if file is there but we can't stat it for any reason other\n+\t\t// than it doesn't exist then stop\n+\t\treturn &configFile, err\n+\t}\n+\n+\t// Can't find latest config file so check for the old one\n+\tconfFile := filepath.Join(homedir.Get(), OLD_CONFIGFILE)\n+\n \tif _, err := os.Stat(confFile); err != nil {\n \t\treturn &configFile, nil //missing file is not an error\n \t}\n+\n \tb, err := ioutil.ReadFile(confFile)\n \tif err != nil {\n \t\treturn &configFile, err\n \t}\n \n-\tif err := json.Unmarshal(b, &configFile.Configs); err != nil {\n+\tif err := json.Unmarshal(b, &configFile.AuthConfigs); err != nil {","path":"registry/auth.go","position":103,"original_position":103,"commit_id":"738065324eb4080019ca6bf5195f744ca9733898","original_commit_id":"738065324eb4080019ca6bf5195f744ca9733898","user":{"login":"tiborvass","id":827131,"avatar_url":"https://avatars.githubusercontent.com/u/827131?v=3","gravatar_id":"","url":"https://api.github.com/users/tiborvass","html_url":"https://github.com/tiborvass","followers_url":"https://api.github.com/users/tiborvass/followers","following_url":"https://api.github.com/users/tiborvass/following{/other_user}","gists_url":"https://api.github.com/users/tiborvass/gists{/gist_id}","starred_url":"https://api.github.com/users/tiborvass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiborvass/subscriptions","organizations_url":"https://api.github.com/users/tiborvass/orgs","repos_url":"https://api.github.com/users/tiborvass/repos","events_url":"https://api.github.com/users/tiborvass/events{/privacy}","received_events_url":"https://api.github.com/users/tiborvass/received_events","type":"User","site_admin":false},"body":"os.Open + json.NewDecoder","created_at":"2015-04-17T17:03:33Z","updated_at":"2015-04-17T17:03:33Z","html_url":"https://github.com/docker/docker/pull/12009#discussion_r28611470","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/12009","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/28611470"},"html":{"href":"https://github.com/docker/docker/pull/12009#discussion_r28611470"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/12009"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/12009","id":32472146,"html_url":"https://github.com/docker/docker/pull/12009","diff_url":"https://github.com/docker/docker/pull/12009.diff","patch_url":"https://github.com/docker/docker/pull/12009.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/12009","number":12009,"state":"open","locked":false,"title":"Migrate .dockercfg to .docker/config.json and support for HTTP Headers","user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"body":"This PR does the following:\r\n- migrated ~/.dockerfg to ~/.docker/config.json. The data is migrated\r\n  but the old file remains in case its needed\r\n- moves the auth json in that fie into an \"auth\" property so we can add new\r\n  top-level properties w/o messing with the auth stuff\r\n- adds support for an HttpHeaders property in ~/.docker/config.json\r\n  which adds these http headers to all msgs from the cli\r\n\r\nIn a follow-on PR I'll move the config file process out from under\r\n\"registry\" since it not specific to that any more. I didn't do it here\r\nbecause I wanted the diff to be smaller so people can make sure I didn't\r\nbreak/miss any auth code during my edits.\r\n\r\nSigned-off-by: Doug Davis <dug@us.ibm.com>","created_at":"2015-04-01T23:50:58Z","updated_at":"2015-04-17T17:03:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7929dad7d0679771159e444a7e7acfe844c5ea8b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/12009/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/12009/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/12009/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/738065324eb4080019ca6bf5195f744ca9733898","head":{"label":"duglin:AddConfig","ref":"AddConfig","sha":"738065324eb4080019ca6bf5195f744ca9733898","user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"repo":{"id":22769065,"name":"docker","full_name":"duglin/docker","owner":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/duglin/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/duglin/docker","forks_url":"https://api.github.com/repos/duglin/docker/forks","keys_url":"https://api.github.com/repos/duglin/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duglin/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duglin/docker/teams","hooks_url":"https://api.github.com/repos/duglin/docker/hooks","issue_events_url":"https://api.github.com/repos/duglin/docker/issues/events{/number}","events_url":"https://api.github.com/repos/duglin/docker/events","assignees_url":"https://api.github.com/repos/duglin/docker/assignees{/user}","branches_url":"https://api.github.com/repos/duglin/docker/branches{/branch}","tags_url":"https://api.github.com/repos/duglin/docker/tags","blobs_url":"https://api.github.com/repos/duglin/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duglin/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duglin/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/duglin/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duglin/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/duglin/docker/languages","stargazers_url":"https://api.github.com/repos/duglin/docker/stargazers","contributors_url":"https://api.github.com/repos/duglin/docker/contributors","subscribers_url":"https://api.github.com/repos/duglin/docker/subscribers","subscription_url":"https://api.github.com/repos/duglin/docker/subscription","commits_url":"https://api.github.com/repos/duglin/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/duglin/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/duglin/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/duglin/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/duglin/docker/contents/{+path}","compare_url":"https://api.github.com/repos/duglin/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duglin/docker/merges","archive_url":"https://api.github.com/repos/duglin/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duglin/docker/downloads","issues_url":"https://api.github.com/repos/duglin/docker/issues{/number}","pulls_url":"https://api.github.com/repos/duglin/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/duglin/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/duglin/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duglin/docker/labels{/name}","releases_url":"https://api.github.com/repos/duglin/docker/releases{/id}","created_at":"2014-08-08T19:24:58Z","updated_at":"2015-04-16T20:53:50Z","pushed_at":"2015-04-17T00:06:35Z","git_url":"git://github.com/duglin/docker.git","ssh_url":"git@github.com:duglin/docker.git","clone_url":"https://github.com/duglin/docker.git","svn_url":"https://github.com/duglin/docker","homepage":"http://www.docker.com","size":51426,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"e3dd323336904c02aaf57a1ffe3dcc8cb666fc78","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":7691631,"name":"docker","full_name":"docker/docker","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/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-04-17T16:55:56Z","pushed_at":"2015-04-17T17:02:30Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":178829,"stargazers_count":20929,"watchers_count":20929,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4794,"mirror_url":null,"open_issues_count":896,"forks":4794,"open_issues":896,"watchers":20929,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/12009"},"html":{"href":"https://github.com/docker/docker/pull/12009"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/12009"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/12009/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/12009/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/12009/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/738065324eb4080019ca6bf5195f744ca9733898"}}}}