{"action":"closed","number":177,"pull_request":{"url":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/177","id":73345192,"html_url":"https://github.com/vmware/vmware-vcenter/pull/177","diff_url":"https://github.com/vmware/vmware-vcenter/pull/177.diff","patch_url":"https://github.com/vmware/vmware-vcenter/pull/177.patch","issue_url":"https://api.github.com/repos/vmware/vmware-vcenter/issues/177","number":177,"state":"closed","locked":false,"title":"Provide a more centralized way of requiring vmware_lib","user":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"body":"# Summary\r\n\r\nClasses provided by vmware_lib are shipped in a separate module, any library in this module that needs to use resources from `vmware_lib` do so by invoking a call on `Puppet::Module.find` to try and determine where the module is in order to require it.\r\n\r\n# Problem\r\n\r\nThis becomes a problem for things like rspec, where you are not inside an instance of Puppet and therefore `Puppet::Module.find` fails since there is no environment to look up against.  While there is no standard/reliable way of looking up libraries from other modules (the practice is actually discouraged by Puppet) I think using `Puppet::Module.find` should be a fall back if the library does not exist in Ruby's load path.    It's also more optimal to just require the class from the load path than to call `Puppet::Module.find`.    This approach was already taken `lib/puppet/provider/vcenter.rb`, but in some types and providers this fall back approach was not used and calls to `Puppet::Module.find` were always done, which breaks rspec, amoungst other things:\r\n\r\n```ruby\r\nbegin\r\n  require 'puppet_x/puppetlabs/transport'\r\nrescue LoadError => e\r\n  require 'pathname' # WORK_AROUND #14073 and #7788\r\n  vmware_module = Puppet::Module.find('vmware_lib', Puppet[:environment].to_s)\r\n  require File.join vmware_module.path, 'lib/puppet_x/puppetlabs/transport'\r\nend\r\n```\r\n\r\n# Implementation\r\n\r\nRather than go about putting this logic in 20 or more places in the code base, I've added what might be called pseudo wrapper libraries under `lib/puppet_x/vmware/vmware_lib` - these provide a central place to determine how libraries are loaded outside of the module.  This means within the code base we require vmware_lib by first requiring a _local_ library where we always know the relative path, eg:\r\n\r\n```ruby\r\nrequire File.join module_lib, 'puppet_x/vmware/vmware_lib/puppet_x/puppetlabs/transport'\r\n```\r\n\r\nThis in turn has the logic to try to load `puppet_x/puppetlabs/transport` from the load path, and fall back on `Puppet::Module.find` if that fails.   This also means if vmware_lib has any namespace changes...etc we only have one central place to manage how it gets loaded.\r\n\r\n","created_at":"2016-06-10T09:31:42Z","updated_at":"2016-07-05T19:01:07Z","closed_at":"2016-07-05T19:01:07Z","merged_at":"2016-07-05T19:01:07Z","merge_commit_sha":"adff41ded1eea4db5dea7e4402997d342a8a3dc7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/177/commits","review_comments_url":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/177/comments","review_comment_url":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/vmware-vcenter/issues/177/comments","statuses_url":"https://api.github.com/repos/vmware/vmware-vcenter/statuses/d9195bf5f43a93604f32d6312776be31d89d8318","head":{"label":"crayfishx:pr/paths","ref":"pr/paths","sha":"d9195bf5f43a93604f32d6312776be31d89d8318","user":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"repo":{"id":58212358,"name":"vmware-vcenter","full_name":"crayfishx/vmware-vcenter","owner":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/crayfishx/vmware-vcenter","description":"VMware vCenter Module","fork":true,"url":"https://api.github.com/repos/crayfishx/vmware-vcenter","forks_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/forks","keys_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/teams","hooks_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/hooks","issue_events_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/issues/events{/number}","events_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/events","assignees_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/assignees{/user}","branches_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/branches{/branch}","tags_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/tags","blobs_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/git/refs{/sha}","trees_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/statuses/{sha}","languages_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/languages","stargazers_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/stargazers","contributors_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/contributors","subscribers_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/subscribers","subscription_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/subscription","commits_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/commits{/sha}","git_commits_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/git/commits{/sha}","comments_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/comments{/number}","issue_comment_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/issues/comments{/number}","contents_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/contents/{+path}","compare_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/merges","archive_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/downloads","issues_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/issues{/number}","pulls_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/pulls{/number}","milestones_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/milestones{/number}","notifications_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/labels{/name}","releases_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/releases{/id}","deployments_url":"https://api.github.com/repos/crayfishx/vmware-vcenter/deployments","created_at":"2016-05-06T14:20:39Z","updated_at":"2016-05-06T14:20:40Z","pushed_at":"2016-07-05T08:05:39Z","git_url":"git://github.com/crayfishx/vmware-vcenter.git","ssh_url":"git@github.com:crayfishx/vmware-vcenter.git","clone_url":"https://github.com/crayfishx/vmware-vcenter.git","svn_url":"https://github.com/crayfishx/vmware-vcenter","homepage":null,"size":738,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":0,"default_branch":"master"}},"base":{"label":"vmware:master","ref":"master","sha":"1842f38bd5a5494452f360b27551d7a044e1b373","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":6147799,"name":"vmware-vcenter","full_name":"vmware/vmware-vcenter","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/vmware-vcenter","description":"VMware vCenter Module","fork":false,"url":"https://api.github.com/repos/vmware/vmware-vcenter","forks_url":"https://api.github.com/repos/vmware/vmware-vcenter/forks","keys_url":"https://api.github.com/repos/vmware/vmware-vcenter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/vmware-vcenter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/vmware-vcenter/teams","hooks_url":"https://api.github.com/repos/vmware/vmware-vcenter/hooks","issue_events_url":"https://api.github.com/repos/vmware/vmware-vcenter/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/vmware-vcenter/events","assignees_url":"https://api.github.com/repos/vmware/vmware-vcenter/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/vmware-vcenter/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/vmware-vcenter/tags","blobs_url":"https://api.github.com/repos/vmware/vmware-vcenter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/vmware-vcenter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/vmware-vcenter/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/vmware-vcenter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/vmware-vcenter/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/vmware-vcenter/languages","stargazers_url":"https://api.github.com/repos/vmware/vmware-vcenter/stargazers","contributors_url":"https://api.github.com/repos/vmware/vmware-vcenter/contributors","subscribers_url":"https://api.github.com/repos/vmware/vmware-vcenter/subscribers","subscription_url":"https://api.github.com/repos/vmware/vmware-vcenter/subscription","commits_url":"https://api.github.com/repos/vmware/vmware-vcenter/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/vmware-vcenter/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/vmware-vcenter/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/vmware-vcenter/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/vmware-vcenter/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/vmware-vcenter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/vmware-vcenter/merges","archive_url":"https://api.github.com/repos/vmware/vmware-vcenter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/vmware-vcenter/downloads","issues_url":"https://api.github.com/repos/vmware/vmware-vcenter/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/vmware-vcenter/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/vmware-vcenter/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/vmware-vcenter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/vmware-vcenter/labels{/name}","releases_url":"https://api.github.com/repos/vmware/vmware-vcenter/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/vmware-vcenter/deployments","created_at":"2012-10-09T21:05:16Z","updated_at":"2016-06-28T19:49:30Z","pushed_at":"2016-07-05T19:01:07Z","git_url":"git://github.com/vmware/vmware-vcenter.git","ssh_url":"git@github.com:vmware/vmware-vcenter.git","clone_url":"https://github.com/vmware/vmware-vcenter.git","svn_url":"https://github.com/vmware/vmware-vcenter","homepage":null,"size":1363,"stargazers_count":51,"watchers_count":51,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":74,"mirror_url":null,"open_issues_count":22,"forks":74,"open_issues":22,"watchers":51,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/177"},"html":{"href":"https://github.com/vmware/vmware-vcenter/pull/177"},"issue":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/issues/177"},"comments":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/issues/177/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/177/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/pulls/177/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/vmware-vcenter/statuses/d9195bf5f43a93604f32d6312776be31d89d8318"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"maniacmurphy","id":4752283,"avatar_url":"https://avatars.githubusercontent.com/u/4752283?v=3","gravatar_id":"","url":"https://api.github.com/users/maniacmurphy","html_url":"https://github.com/maniacmurphy","followers_url":"https://api.github.com/users/maniacmurphy/followers","following_url":"https://api.github.com/users/maniacmurphy/following{/other_user}","gists_url":"https://api.github.com/users/maniacmurphy/gists{/gist_id}","starred_url":"https://api.github.com/users/maniacmurphy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniacmurphy/subscriptions","organizations_url":"https://api.github.com/users/maniacmurphy/orgs","repos_url":"https://api.github.com/users/maniacmurphy/repos","events_url":"https://api.github.com/users/maniacmurphy/events{/privacy}","received_events_url":"https://api.github.com/users/maniacmurphy/received_events","type":"User","site_admin":false},"comments":1,"review_comments":6,"commits":4,"additions":110,"deletions":112,"changed_files":36}}
{"actor":{"display_login":"maniacmurphy"}}