{"action":"created","comment":{"url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/comments/116008780","pull_request_review_id":37594441,"id":116008780,"diff_hunk":"@@ -155,114 +157,97 @@ func (d *Dao) BatchGetSpecs(dir string) ([]*apb.Spec, error) {\n \treturn specs, nil\n }\n \n+//GetServiceInstance - Retrieve specific service instance from the kvp API.\n func (d *Dao) GetServiceInstance(id string) (*apb.ServiceInstance, error) {\n-\tvar raw string\n-\tvar err error\n-\tif raw, err = d.GetRaw(serviceInstanceKey(id)); err != nil {\n-\t\treturn nil, err\n-\t}\n-\n \tspec := &apb.ServiceInstance{}\n-\terr = apb.LoadJSON(raw, spec)\n+\terr := d.getObject(serviceInstanceKey(id), spec)\n \tif err != nil {\n \t\treturn nil, err\n \t}\n-\n \treturn spec, nil\n }\n \n-func (d *Dao) SetServiceInstance(\n-\tid string, serviceInstance *apb.ServiceInstance,\n-) error {\n-\tpayload, err := apb.DumpJSON(serviceInstance)\n-\tif err != nil {\n-\t\treturn err\n-\t}\n-\n-\treturn d.SetRaw(serviceInstanceKey(id), payload)\n+//SetServiceInstance - Set service instance for an id in the kvp API.\n+func (d *Dao) SetServiceInstance(id string, serviceInstance *apb.ServiceInstance) error {\n+\treturn d.setObject(serviceInstanceKey(id), serviceInstance)\n }\n \n+//DeleteServiceInstance - Delete the service instance for an service instance id.\n func (d *Dao) DeleteServiceInstance(id string) error {\n \td.log.Debug(fmt.Sprintf(\"Dao::DeleteServiceInstance -> [ %s ]\", id))\n \t_, err := d.kapi.Delete(context.Background(), serviceInstanceKey(id), nil)\n \treturn err\n }\n \n+//GetBindInstance - Retrieve a specific bind instance from the kvp API\n func (d *Dao) GetBindInstance(id string) (*apb.BindInstance, error) {\n-\tvar raw string\n-\tvar err error\n-\tif raw, err = d.GetRaw(bindInstanceKey(id)); err != nil {\n-\t\treturn nil, err\n-\t}\n-\n \tspec := &apb.BindInstance{}\n-\terr = apb.LoadJSON(raw, spec)\n+\terr := d.getObject(bindInstanceKey(id), spec)\n \tif err != nil {\n \t\treturn nil, err\n \t}\n-\n \treturn spec, nil\n }\n \n-func (d *Dao) SetBindInstance(\n-\tid string, bindInstance *apb.BindInstance,\n-) error {\n-\tpayload, err := apb.DumpJSON(bindInstance)\n-\tif err != nil {\n-\t\treturn err\n-\t}\n-\n-\treturn d.SetRaw(bindInstanceKey(id), payload)\n+//SetBindInstance - Set the bind instance for id in the kvp API.\n+func (d *Dao) SetBindInstance(id string, bindInstance *apb.BindInstance) error {\n+\treturn d.setObject(bindInstanceKey(id), bindInstance)\n }\n \n+//GetExtractedCredentials - Get the extracted credentials for an id in the kvp API.\n func (d *Dao) GetExtractedCredentials(id string) (*apb.ExtractedCredentials, error) {\n-\traw, err := d.GetRaw(extractedCredentialsKey(id))\n+\textractedCredentials := &apb.ExtractedCredentials{}\n+\terr := d.getObject(extractedCredentialsKey(id), extractedCredentials)\n \tif err != nil {\n \t\treturn nil, err\n \t}\n-\n-\textractedCredentials := &apb.ExtractedCredentials{}\n-\tapb.LoadJSON(raw, extractedCredentials)\n \treturn extractedCredentials, nil\n }\n \n-func (d *Dao) SetExtractedCredentials(\n-\tid string, extractedCredentials *apb.ExtractedCredentials,\n-) error {\n-\tpayload, err := apb.DumpJSON(extractedCredentials)\n-\tif err != nil {\n-\t\treturn err\n-\t}\n-\n-\treturn d.SetRaw(extractedCredentialsKey(id), payload)\n+//SetExtractedCredentials - Set the extracted credentials for an id in the kvp API.\n+func (d *Dao) SetExtractedCredentials(id string, extractedCredentials *apb.ExtractedCredentials) error {\n+\treturn d.setObject(extractedCredentialsKey(id), extractedCredentials)\n }\n \n+//SetState - Set the Job State in the kvp API for id.\n func (d *Dao) SetState(id string, state apb.JobState) error {\n-\tpayload, err := apb.DumpJSON(state)\n-\tif err != nil {\n-\t\treturn err\n-\t}\n-\n-\treturn d.SetRaw(stateKey(id, state.Token), payload)\n+\treturn d.setObject(stateKey(id, state.Token), state)\n }\n \n+//GetState - Retrieve a job state from the kvp API for an ID and Token.\n func (d *Dao) GetState(id string, token string) (apb.JobState, error) {\n-\traw, err := d.GetRaw(stateKey(id, token))\n+\tstate := apb.JobState{}\n+\terr := d.getObject(stateKey(id, token), &state)\n \tif err != nil {\n \t\treturn apb.JobState{State: apb.StateFailed}, err\n \t}\n-\n-\tstate := apb.JobState{}\n-\tapb.LoadJSON(raw, &state)\n \treturn state, nil\n }\n \n+//DeleteBindInstance - Delete the binding instance for an id in the kvp API.\n func (d *Dao) DeleteBindInstance(id string) error {\n \td.log.Debug(fmt.Sprintf(\"Dao::DeleteBindInstance -> [ %s ]\", id))\n \t_, err := d.kapi.Delete(context.Background(), bindInstanceKey(id), nil)\n \treturn err\n }\n \n+func (d *Dao) getObject(key string, data interface{}) error {\n+\traw, err := d.GetRaw(key)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tapb.LoadJSON(raw, data)\n+\treturn nil\n+}\n+\n+func (d *Dao) setObject(key string, data interface{}) error {\n+\tpayload, err := apb.DumpJSON(data)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\treturn d.SetRaw(key, payload)\n+}\n+","path":"pkg/dao/dao.go","position":243,"original_position":243,"commit_id":"3de0c767b085c353a5cb741102d819d8cb21e464","original_commit_id":"3de0c767b085c353a5cb741102d819d8cb21e464","user":{"login":"jmrodri","id":17137,"avatar_url":"https://avatars1.githubusercontent.com/u/17137?v=3","gravatar_id":"","url":"https://api.github.com/users/jmrodri","html_url":"https://github.com/jmrodri","followers_url":"https://api.github.com/users/jmrodri/followers","following_url":"https://api.github.com/users/jmrodri/following{/other_user}","gists_url":"https://api.github.com/users/jmrodri/gists{/gist_id}","starred_url":"https://api.github.com/users/jmrodri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmrodri/subscriptions","organizations_url":"https://api.github.com/users/jmrodri/orgs","repos_url":"https://api.github.com/users/jmrodri/repos","events_url":"https://api.github.com/users/jmrodri/events{/privacy}","received_events_url":"https://api.github.com/users/jmrodri/received_events","type":"User","site_admin":false},"body":"+1","created_at":"2017-05-11T14:42:38Z","updated_at":"2017-05-11T14:44:26Z","html_url":"https://github.com/fusor/ansible-service-broker/pull/105#discussion_r116008780","pull_request_url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/comments/116008780"},"html":{"href":"https://github.com/fusor/ansible-service-broker/pull/105#discussion_r116008780"},"pull_request":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105","id":120115492,"html_url":"https://github.com/fusor/ansible-service-broker/pull/105","diff_url":"https://github.com/fusor/ansible-service-broker/pull/105.diff","patch_url":"https://github.com/fusor/ansible-service-broker/pull/105.patch","issue_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues/105","number":105,"state":"open","locked":false,"title":"Removing redundancy in dao for issue #63","user":{"login":"shawn-hurley","id":1891063,"avatar_url":"https://avatars0.githubusercontent.com/u/1891063?v=3","gravatar_id":"","url":"https://api.github.com/users/shawn-hurley","html_url":"https://github.com/shawn-hurley","followers_url":"https://api.github.com/users/shawn-hurley/followers","following_url":"https://api.github.com/users/shawn-hurley/following{/other_user}","gists_url":"https://api.github.com/users/shawn-hurley/gists{/gist_id}","starred_url":"https://api.github.com/users/shawn-hurley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawn-hurley/subscriptions","organizations_url":"https://api.github.com/users/shawn-hurley/orgs","repos_url":"https://api.github.com/users/shawn-hurley/repos","events_url":"https://api.github.com/users/shawn-hurley/events{/privacy}","received_events_url":"https://api.github.com/users/shawn-hurley/received_events","type":"User","site_admin":false},"body":"Fix for issue #63 \r\n\r\n* Also fixing golint things like comments on export methods and structs","created_at":"2017-05-11T14:07:00Z","updated_at":"2017-05-11T14:44:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"458f738f233fcc3219c5476fbcc8fbcea6108d3b","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105/commits","review_comments_url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105/comments","review_comment_url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues/105/comments","statuses_url":"https://api.github.com/repos/fusor/ansible-service-broker/statuses/3de0c767b085c353a5cb741102d819d8cb21e464","head":{"label":"fusor:cleanup-dao-redundancy","ref":"cleanup-dao-redundancy","sha":"3de0c767b085c353a5cb741102d819d8cb21e464","user":{"login":"fusor","id":9267379,"avatar_url":"https://avatars3.githubusercontent.com/u/9267379?v=3","gravatar_id":"","url":"https://api.github.com/users/fusor","html_url":"https://github.com/fusor","followers_url":"https://api.github.com/users/fusor/followers","following_url":"https://api.github.com/users/fusor/following{/other_user}","gists_url":"https://api.github.com/users/fusor/gists{/gist_id}","starred_url":"https://api.github.com/users/fusor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusor/subscriptions","organizations_url":"https://api.github.com/users/fusor/orgs","repos_url":"https://api.github.com/users/fusor/repos","events_url":"https://api.github.com/users/fusor/events{/privacy}","received_events_url":"https://api.github.com/users/fusor/received_events","type":"Organization","site_admin":false},"repo":{"id":79371528,"name":"ansible-service-broker","full_name":"fusor/ansible-service-broker","owner":{"login":"fusor","id":9267379,"avatar_url":"https://avatars3.githubusercontent.com/u/9267379?v=3","gravatar_id":"","url":"https://api.github.com/users/fusor","html_url":"https://github.com/fusor","followers_url":"https://api.github.com/users/fusor/followers","following_url":"https://api.github.com/users/fusor/following{/other_user}","gists_url":"https://api.github.com/users/fusor/gists{/gist_id}","starred_url":"https://api.github.com/users/fusor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusor/subscriptions","organizations_url":"https://api.github.com/users/fusor/orgs","repos_url":"https://api.github.com/users/fusor/repos","events_url":"https://api.github.com/users/fusor/events{/privacy}","received_events_url":"https://api.github.com/users/fusor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fusor/ansible-service-broker","description":"Ansible Service Broker","fork":false,"url":"https://api.github.com/repos/fusor/ansible-service-broker","forks_url":"https://api.github.com/repos/fusor/ansible-service-broker/forks","keys_url":"https://api.github.com/repos/fusor/ansible-service-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fusor/ansible-service-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fusor/ansible-service-broker/teams","hooks_url":"https://api.github.com/repos/fusor/ansible-service-broker/hooks","issue_events_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues/events{/number}","events_url":"https://api.github.com/repos/fusor/ansible-service-broker/events","assignees_url":"https://api.github.com/repos/fusor/ansible-service-broker/assignees{/user}","branches_url":"https://api.github.com/repos/fusor/ansible-service-broker/branches{/branch}","tags_url":"https://api.github.com/repos/fusor/ansible-service-broker/tags","blobs_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fusor/ansible-service-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/fusor/ansible-service-broker/languages","stargazers_url":"https://api.github.com/repos/fusor/ansible-service-broker/stargazers","contributors_url":"https://api.github.com/repos/fusor/ansible-service-broker/contributors","subscribers_url":"https://api.github.com/repos/fusor/ansible-service-broker/subscribers","subscription_url":"https://api.github.com/repos/fusor/ansible-service-broker/subscription","commits_url":"https://api.github.com/repos/fusor/ansible-service-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/fusor/ansible-service-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/fusor/ansible-service-broker/contents/{+path}","compare_url":"https://api.github.com/repos/fusor/ansible-service-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fusor/ansible-service-broker/merges","archive_url":"https://api.github.com/repos/fusor/ansible-service-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fusor/ansible-service-broker/downloads","issues_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues{/number}","pulls_url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/fusor/ansible-service-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/fusor/ansible-service-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fusor/ansible-service-broker/labels{/name}","releases_url":"https://api.github.com/repos/fusor/ansible-service-broker/releases{/id}","deployments_url":"https://api.github.com/repos/fusor/ansible-service-broker/deployments","created_at":"2017-01-18T18:40:49Z","updated_at":"2017-05-01T03:50:17Z","pushed_at":"2017-05-11T14:07:01Z","git_url":"git://github.com/fusor/ansible-service-broker.git","ssh_url":"git@github.com:fusor/ansible-service-broker.git","clone_url":"https://github.com/fusor/ansible-service-broker.git","svn_url":"https://github.com/fusor/ansible-service-broker","homepage":null,"size":10459,"stargazers_count":13,"watchers_count":13,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":20,"forks":12,"open_issues":20,"watchers":13,"default_branch":"master"}},"base":{"label":"fusor:master","ref":"master","sha":"f3ee4f2160455d572dbc21731fe97b88491efbb5","user":{"login":"fusor","id":9267379,"avatar_url":"https://avatars3.githubusercontent.com/u/9267379?v=3","gravatar_id":"","url":"https://api.github.com/users/fusor","html_url":"https://github.com/fusor","followers_url":"https://api.github.com/users/fusor/followers","following_url":"https://api.github.com/users/fusor/following{/other_user}","gists_url":"https://api.github.com/users/fusor/gists{/gist_id}","starred_url":"https://api.github.com/users/fusor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusor/subscriptions","organizations_url":"https://api.github.com/users/fusor/orgs","repos_url":"https://api.github.com/users/fusor/repos","events_url":"https://api.github.com/users/fusor/events{/privacy}","received_events_url":"https://api.github.com/users/fusor/received_events","type":"Organization","site_admin":false},"repo":{"id":79371528,"name":"ansible-service-broker","full_name":"fusor/ansible-service-broker","owner":{"login":"fusor","id":9267379,"avatar_url":"https://avatars3.githubusercontent.com/u/9267379?v=3","gravatar_id":"","url":"https://api.github.com/users/fusor","html_url":"https://github.com/fusor","followers_url":"https://api.github.com/users/fusor/followers","following_url":"https://api.github.com/users/fusor/following{/other_user}","gists_url":"https://api.github.com/users/fusor/gists{/gist_id}","starred_url":"https://api.github.com/users/fusor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusor/subscriptions","organizations_url":"https://api.github.com/users/fusor/orgs","repos_url":"https://api.github.com/users/fusor/repos","events_url":"https://api.github.com/users/fusor/events{/privacy}","received_events_url":"https://api.github.com/users/fusor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fusor/ansible-service-broker","description":"Ansible Service Broker","fork":false,"url":"https://api.github.com/repos/fusor/ansible-service-broker","forks_url":"https://api.github.com/repos/fusor/ansible-service-broker/forks","keys_url":"https://api.github.com/repos/fusor/ansible-service-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fusor/ansible-service-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fusor/ansible-service-broker/teams","hooks_url":"https://api.github.com/repos/fusor/ansible-service-broker/hooks","issue_events_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues/events{/number}","events_url":"https://api.github.com/repos/fusor/ansible-service-broker/events","assignees_url":"https://api.github.com/repos/fusor/ansible-service-broker/assignees{/user}","branches_url":"https://api.github.com/repos/fusor/ansible-service-broker/branches{/branch}","tags_url":"https://api.github.com/repos/fusor/ansible-service-broker/tags","blobs_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fusor/ansible-service-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/fusor/ansible-service-broker/languages","stargazers_url":"https://api.github.com/repos/fusor/ansible-service-broker/stargazers","contributors_url":"https://api.github.com/repos/fusor/ansible-service-broker/contributors","subscribers_url":"https://api.github.com/repos/fusor/ansible-service-broker/subscribers","subscription_url":"https://api.github.com/repos/fusor/ansible-service-broker/subscription","commits_url":"https://api.github.com/repos/fusor/ansible-service-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/fusor/ansible-service-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/fusor/ansible-service-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/fusor/ansible-service-broker/contents/{+path}","compare_url":"https://api.github.com/repos/fusor/ansible-service-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fusor/ansible-service-broker/merges","archive_url":"https://api.github.com/repos/fusor/ansible-service-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fusor/ansible-service-broker/downloads","issues_url":"https://api.github.com/repos/fusor/ansible-service-broker/issues{/number}","pulls_url":"https://api.github.com/repos/fusor/ansible-service-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/fusor/ansible-service-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/fusor/ansible-service-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fusor/ansible-service-broker/labels{/name}","releases_url":"https://api.github.com/repos/fusor/ansible-service-broker/releases{/id}","deployments_url":"https://api.github.com/repos/fusor/ansible-service-broker/deployments","created_at":"2017-01-18T18:40:49Z","updated_at":"2017-05-01T03:50:17Z","pushed_at":"2017-05-11T14:07:01Z","git_url":"git://github.com/fusor/ansible-service-broker.git","ssh_url":"git@github.com:fusor/ansible-service-broker.git","clone_url":"https://github.com/fusor/ansible-service-broker.git","svn_url":"https://github.com/fusor/ansible-service-broker","homepage":null,"size":10459,"stargazers_count":13,"watchers_count":13,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":20,"forks":12,"open_issues":20,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105"},"html":{"href":"https://github.com/fusor/ansible-service-broker/pull/105"},"issue":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/issues/105"},"comments":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/fusor/ansible-service-broker/statuses/3de0c767b085c353a5cb741102d819d8cb21e464"}}}}
{"actor":{"display_login":"jmrodri"}}