{"action":"created","comment":{"url":"https://api.github.com/repos/projectatomic/libpod/pulls/comments/173190573","pull_request_review_id":102337945,"id":173190573,"diff_hunk":"@@ -0,0 +1,193 @@\n+package image\n+\n+import (\n+\t\"fmt\"\n+\t\"io\"\n+\t\"os\"\n+\n+\t\"github.com/containers/image/docker/reference\"\n+\t\"github.com/containers/storage\"\n+\t\"github.com/pkg/errors\"\n+\t\"github.com/projectatomic/libpod/libpod\"\n+\t\"github.com/projectatomic/libpod/pkg/inspect\"\n+)\n+\n+type Image struct {\n+\tinspect.ImageData\n+\tInputName string\n+\tLocal     bool\n+\tRuntime   *libpod.Runtime\n+\timage     *storage.Image\n+}\n+\n+// NewFromLocal creates a new image object that is intended\n+// to only deal with local images already in the store (or\n+// its aliases)\n+func NewFromLocal(name string, runtime *libpod.Runtime) (Image, error) {\n+\timage := Image{\n+\t\tInputName: name,\n+\t\tLocal:     true,\n+\t\tRuntime:   runtime,\n+\t}\n+\tlocalImage, err := image.GetLocalImage()\n+\tif err != nil {\n+\t\treturn Image{}, err\n+\t}\n+\timage.image = localImage\n+\treturn image, nil\n+}\n+\n+// New creates a new image object where the image could be local\n+// or remote\n+func New(name string, runtime *libpod.Runtime) (Image, error) {\n+\t// We don't know if the image is local or not ... check local first\n+\tnewImage := Image{\n+\t\tInputName: name,\n+\t\tLocal:     false,\n+\t\tRuntime:   runtime,\n+\t}\n+\tlocalImage, err := newImage.GetLocalImage()\n+\tif err == nil {\n+\t\tnewImage.Local = true\n+\t\tnewImage.image = localImage\n+\t\treturn newImage, nil\n+\t}\n+\n+\t// The image is not local\n+\tpullNames, err := newImage.createNamesToPull()\n+\tif err != nil {\n+\t\treturn newImage, err\n+\t}\n+\tif len(pullNames) == 0 {\n+\t\treturn newImage, errors.Errorf(\"unable to pull %s\", newImage.InputName)\n+\t}\n+\tvar writer io.Writer\n+\twriter = os.Stderr\n+\tfor _, p := range pullNames {\n+\t\timageName, err := newImage.pull(p, writer, runtime)\n+\t\tif err == nil {\n+\t\t\timg, err := getLocalImage(runtime, imageName)\n+\t\t\tnewImage.image = img\n+\t\t\treturn newImage, err\n+\t\t}\n+\t}\n+\treturn newImage, errors.Errorf(\"unable to find %s\", name)\n+}\n+\n+func getLocalImage(r *libpod.Runtime, name string) (*storage.Image, error) {\n+\treturn r.GetImage(name)\n+}\n+\n+// GetLocalImage resolves an unknown input describing an image and\n+// returns a storage.Image or an error. It is used by NewFromLocal.\n+// TODO: I think this should be a local func only, forcing users to use NewFromLocal","path":"libpod/image/image.go","position":83,"original_position":83,"commit_id":"9b5263d811110c192c05e607c19250a22bbc7a21","original_commit_id":"9b5263d811110c192c05e607c19250a22bbc7a21","user":{"login":"baude","id":8824535,"avatar_url":"https://avatars3.githubusercontent.com/u/8824535?v=4","gravatar_id":"","url":"https://api.github.com/users/baude","html_url":"https://github.com/baude","followers_url":"https://api.github.com/users/baude/followers","following_url":"https://api.github.com/users/baude/following{/other_user}","gists_url":"https://api.github.com/users/baude/gists{/gist_id}","starred_url":"https://api.github.com/users/baude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baude/subscriptions","organizations_url":"https://api.github.com/users/baude/orgs","repos_url":"https://api.github.com/users/baude/repos","events_url":"https://api.github.com/users/baude/events{/privacy}","received_events_url":"https://api.github.com/users/baude/received_events","type":"User","site_admin":false},"body":"agree done","created_at":"2018-03-08T15:24:26Z","updated_at":"2018-03-08T15:24:26Z","html_url":"https://github.com/projectatomic/libpod/pull/463#discussion_r173190573","pull_request_url":"https://api.github.com/repos/projectatomic/libpod/pulls/463","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/projectatomic/libpod/pulls/comments/173190573"},"html":{"href":"https://github.com/projectatomic/libpod/pull/463#discussion_r173190573"},"pull_request":{"href":"https://api.github.com/repos/projectatomic/libpod/pulls/463"}},"in_reply_to_id":173052010},"pull_request":{"url":"https://api.github.com/repos/projectatomic/libpod/pulls/463","id":173628684,"html_url":"https://github.com/projectatomic/libpod/pull/463","diff_url":"https://github.com/projectatomic/libpod/pull/463.diff","patch_url":"https://github.com/projectatomic/libpod/pull/463.patch","issue_url":"https://api.github.com/repos/projectatomic/libpod/issues/463","number":463,"state":"open","locked":false,"title":"Image Resolution Stage 1","user":{"login":"baude","id":8824535,"avatar_url":"https://avatars3.githubusercontent.com/u/8824535?v=4","gravatar_id":"","url":"https://api.github.com/users/baude","html_url":"https://github.com/baude","followers_url":"https://api.github.com/users/baude/followers","following_url":"https://api.github.com/users/baude/following{/other_user}","gists_url":"https://api.github.com/users/baude/gists{/gist_id}","starred_url":"https://api.github.com/users/baude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baude/subscriptions","organizations_url":"https://api.github.com/users/baude/orgs","repos_url":"https://api.github.com/users/baude/repos","events_url":"https://api.github.com/users/baude/events{/privacy}","received_events_url":"https://api.github.com/users/baude/received_events","type":"User","site_admin":false},"body":"This is the stage 1 effort for an image library that can be eventually used by buildah and\r\npodman alike.  In eventuality, the main goal of the library (package) is to:\r\n\r\n* provide a consistent approach to resolving image names in various forms (from users).\r\n* based on the result of the above, provide image methods that in a singular spot but separate from the runtime.\r\n* reduce the cruft and bloat in the current podman runtime.\r\n\r\nThe goal of stage 1 is to demonstrate fast, accurate image resolution for both local and remote images resulting in an image object as part of the return.\r\n\r\nSigned-off-by: baude <bbaude@redhat.com>","created_at":"2018-03-08T02:24:50Z","updated_at":"2018-03-08T15:24:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cfc8ee994dc70d0fbc07b31af450866e73d4d05a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/projectatomic/libpod/pulls/463/commits","review_comments_url":"https://api.github.com/repos/projectatomic/libpod/pulls/463/comments","review_comment_url":"https://api.github.com/repos/projectatomic/libpod/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projectatomic/libpod/issues/463/comments","statuses_url":"https://api.github.com/repos/projectatomic/libpod/statuses/9b5263d811110c192c05e607c19250a22bbc7a21","head":{"label":"baude:imagestage1","ref":"imagestage1","sha":"9b5263d811110c192c05e607c19250a22bbc7a21","user":{"login":"baude","id":8824535,"avatar_url":"https://avatars3.githubusercontent.com/u/8824535?v=4","gravatar_id":"","url":"https://api.github.com/users/baude","html_url":"https://github.com/baude","followers_url":"https://api.github.com/users/baude/followers","following_url":"https://api.github.com/users/baude/following{/other_user}","gists_url":"https://api.github.com/users/baude/gists{/gist_id}","starred_url":"https://api.github.com/users/baude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baude/subscriptions","organizations_url":"https://api.github.com/users/baude/orgs","repos_url":"https://api.github.com/users/baude/repos","events_url":"https://api.github.com/users/baude/events{/privacy}","received_events_url":"https://api.github.com/users/baude/received_events","type":"User","site_admin":false},"repo":{"id":109146017,"name":"libpod","full_name":"baude/libpod","owner":{"login":"baude","id":8824535,"avatar_url":"https://avatars3.githubusercontent.com/u/8824535?v=4","gravatar_id":"","url":"https://api.github.com/users/baude","html_url":"https://github.com/baude","followers_url":"https://api.github.com/users/baude/followers","following_url":"https://api.github.com/users/baude/following{/other_user}","gists_url":"https://api.github.com/users/baude/gists{/gist_id}","starred_url":"https://api.github.com/users/baude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baude/subscriptions","organizations_url":"https://api.github.com/users/baude/orgs","repos_url":"https://api.github.com/users/baude/repos","events_url":"https://api.github.com/users/baude/events{/privacy}","received_events_url":"https://api.github.com/users/baude/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/baude/libpod","description":"libpod is a library used to create container pods.","fork":true,"url":"https://api.github.com/repos/baude/libpod","forks_url":"https://api.github.com/repos/baude/libpod/forks","keys_url":"https://api.github.com/repos/baude/libpod/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baude/libpod/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baude/libpod/teams","hooks_url":"https://api.github.com/repos/baude/libpod/hooks","issue_events_url":"https://api.github.com/repos/baude/libpod/issues/events{/number}","events_url":"https://api.github.com/repos/baude/libpod/events","assignees_url":"https://api.github.com/repos/baude/libpod/assignees{/user}","branches_url":"https://api.github.com/repos/baude/libpod/branches{/branch}","tags_url":"https://api.github.com/repos/baude/libpod/tags","blobs_url":"https://api.github.com/repos/baude/libpod/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baude/libpod/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baude/libpod/git/refs{/sha}","trees_url":"https://api.github.com/repos/baude/libpod/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baude/libpod/statuses/{sha}","languages_url":"https://api.github.com/repos/baude/libpod/languages","stargazers_url":"https://api.github.com/repos/baude/libpod/stargazers","contributors_url":"https://api.github.com/repos/baude/libpod/contributors","subscribers_url":"https://api.github.com/repos/baude/libpod/subscribers","subscription_url":"https://api.github.com/repos/baude/libpod/subscription","commits_url":"https://api.github.com/repos/baude/libpod/commits{/sha}","git_commits_url":"https://api.github.com/repos/baude/libpod/git/commits{/sha}","comments_url":"https://api.github.com/repos/baude/libpod/comments{/number}","issue_comment_url":"https://api.github.com/repos/baude/libpod/issues/comments{/number}","contents_url":"https://api.github.com/repos/baude/libpod/contents/{+path}","compare_url":"https://api.github.com/repos/baude/libpod/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baude/libpod/merges","archive_url":"https://api.github.com/repos/baude/libpod/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baude/libpod/downloads","issues_url":"https://api.github.com/repos/baude/libpod/issues{/number}","pulls_url":"https://api.github.com/repos/baude/libpod/pulls{/number}","milestones_url":"https://api.github.com/repos/baude/libpod/milestones{/number}","notifications_url":"https://api.github.com/repos/baude/libpod/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baude/libpod/labels{/name}","releases_url":"https://api.github.com/repos/baude/libpod/releases{/id}","deployments_url":"https://api.github.com/repos/baude/libpod/deployments","created_at":"2017-11-01T15:05:39Z","updated_at":"2017-11-01T15:01:27Z","pushed_at":"2018-03-08T02:24:24Z","git_url":"git://github.com/baude/libpod.git","ssh_url":"git@github.com:baude/libpod.git","clone_url":"https://github.com/baude/libpod.git","svn_url":"https://github.com/baude/libpod","homepage":null,"size":9226,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"projectatomic:master","ref":"master","sha":"4344639508ccd16041d1ec7fd531b6427f930374","user":{"login":"projectatomic","id":6852258,"avatar_url":"https://avatars1.githubusercontent.com/u/6852258?v=4","gravatar_id":"","url":"https://api.github.com/users/projectatomic","html_url":"https://github.com/projectatomic","followers_url":"https://api.github.com/users/projectatomic/followers","following_url":"https://api.github.com/users/projectatomic/following{/other_user}","gists_url":"https://api.github.com/users/projectatomic/gists{/gist_id}","starred_url":"https://api.github.com/users/projectatomic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectatomic/subscriptions","organizations_url":"https://api.github.com/users/projectatomic/orgs","repos_url":"https://api.github.com/users/projectatomic/repos","events_url":"https://api.github.com/users/projectatomic/events{/privacy}","received_events_url":"https://api.github.com/users/projectatomic/received_events","type":"Organization","site_admin":false},"repo":{"id":109145553,"name":"libpod","full_name":"projectatomic/libpod","owner":{"login":"projectatomic","id":6852258,"avatar_url":"https://avatars1.githubusercontent.com/u/6852258?v=4","gravatar_id":"","url":"https://api.github.com/users/projectatomic","html_url":"https://github.com/projectatomic","followers_url":"https://api.github.com/users/projectatomic/followers","following_url":"https://api.github.com/users/projectatomic/following{/other_user}","gists_url":"https://api.github.com/users/projectatomic/gists{/gist_id}","starred_url":"https://api.github.com/users/projectatomic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectatomic/subscriptions","organizations_url":"https://api.github.com/users/projectatomic/orgs","repos_url":"https://api.github.com/users/projectatomic/repos","events_url":"https://api.github.com/users/projectatomic/events{/privacy}","received_events_url":"https://api.github.com/users/projectatomic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projectatomic/libpod","description":"libpod is a library used to create container pods.","fork":false,"url":"https://api.github.com/repos/projectatomic/libpod","forks_url":"https://api.github.com/repos/projectatomic/libpod/forks","keys_url":"https://api.github.com/repos/projectatomic/libpod/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projectatomic/libpod/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projectatomic/libpod/teams","hooks_url":"https://api.github.com/repos/projectatomic/libpod/hooks","issue_events_url":"https://api.github.com/repos/projectatomic/libpod/issues/events{/number}","events_url":"https://api.github.com/repos/projectatomic/libpod/events","assignees_url":"https://api.github.com/repos/projectatomic/libpod/assignees{/user}","branches_url":"https://api.github.com/repos/projectatomic/libpod/branches{/branch}","tags_url":"https://api.github.com/repos/projectatomic/libpod/tags","blobs_url":"https://api.github.com/repos/projectatomic/libpod/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projectatomic/libpod/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projectatomic/libpod/git/refs{/sha}","trees_url":"https://api.github.com/repos/projectatomic/libpod/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projectatomic/libpod/statuses/{sha}","languages_url":"https://api.github.com/repos/projectatomic/libpod/languages","stargazers_url":"https://api.github.com/repos/projectatomic/libpod/stargazers","contributors_url":"https://api.github.com/repos/projectatomic/libpod/contributors","subscribers_url":"https://api.github.com/repos/projectatomic/libpod/subscribers","subscription_url":"https://api.github.com/repos/projectatomic/libpod/subscription","commits_url":"https://api.github.com/repos/projectatomic/libpod/commits{/sha}","git_commits_url":"https://api.github.com/repos/projectatomic/libpod/git/commits{/sha}","comments_url":"https://api.github.com/repos/projectatomic/libpod/comments{/number}","issue_comment_url":"https://api.github.com/repos/projectatomic/libpod/issues/comments{/number}","contents_url":"https://api.github.com/repos/projectatomic/libpod/contents/{+path}","compare_url":"https://api.github.com/repos/projectatomic/libpod/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projectatomic/libpod/merges","archive_url":"https://api.github.com/repos/projectatomic/libpod/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projectatomic/libpod/downloads","issues_url":"https://api.github.com/repos/projectatomic/libpod/issues{/number}","pulls_url":"https://api.github.com/repos/projectatomic/libpod/pulls{/number}","milestones_url":"https://api.github.com/repos/projectatomic/libpod/milestones{/number}","notifications_url":"https://api.github.com/repos/projectatomic/libpod/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projectatomic/libpod/labels{/name}","releases_url":"https://api.github.com/repos/projectatomic/libpod/releases{/id}","deployments_url":"https://api.github.com/repos/projectatomic/libpod/deployments","created_at":"2017-11-01T15:01:27Z","updated_at":"2018-03-06T21:01:24Z","pushed_at":"2018-03-08T09:21:31Z","git_url":"git://github.com/projectatomic/libpod.git","ssh_url":"git@github.com:projectatomic/libpod.git","clone_url":"https://github.com/projectatomic/libpod.git","svn_url":"https://github.com/projectatomic/libpod","homepage":null,"size":9173,"stargazers_count":58,"watchers_count":58,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":37,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":34,"open_issues":37,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projectatomic/libpod/pulls/463"},"html":{"href":"https://github.com/projectatomic/libpod/pull/463"},"issue":{"href":"https://api.github.com/repos/projectatomic/libpod/issues/463"},"comments":{"href":"https://api.github.com/repos/projectatomic/libpod/issues/463/comments"},"review_comments":{"href":"https://api.github.com/repos/projectatomic/libpod/pulls/463/comments"},"review_comment":{"href":"https://api.github.com/repos/projectatomic/libpod/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projectatomic/libpod/pulls/463/commits"},"statuses":{"href":"https://api.github.com/repos/projectatomic/libpod/statuses/9b5263d811110c192c05e607c19250a22bbc7a21"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"baude"}}