{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments/38377338","id":38377338,"diff_hunk":"@@ -199,6 +199,51 @@ def raw_tagged?(tag_array)\n     super || ((scope_resource = scope.resource) && !scope_resource.equal?(self) && scope_resource.raw_tagged?(tag_array))\n   end\n \n+  # Fill resource params from a capability\n+  #\n+  # This backs 'consumes => Sql[one]'\n+  def add_parameters_from_consume\n+    return unless self[:consume]\n+\n+    map = {}\n+    [ self[:consume] ].flatten.map do |ref|\n+      # Resolve references\n+      catalog.resource(ref.type, ref.title) or\n+        raise \"Resource #{ref} could not be found; it might not have been produced yet\"\n+    end.each do |cns|\n+      # Establish mappings\n+      blueprint = resource_type.consumes.find do |bp|\n+        bp[:capability] == cns.type\n+      end\n+      # @todo lutter 2015-08-03: catch this earlier, can we do this during\n+      # static analysis ?\n+      raise \"Resource #{self} tries to consume #{cns} but no 'consumes' mapping exists for #{self.resource_type} and #{cns.type}\" unless blueprint\n+\n+      # setup scope that has, for each attr of cns, a binding to cns[attr]\n+      cns_scope = scope.find_global_scope.newscope(:source => self, :resource => self)\n+      cns.to_hash.each { |name, value| cns_scope[name.to_s] = value }\n+\n+      # evaluate mappings in that scope\n+      resource_type.arguments.keys.each do |name|\n+        if expr = blueprint[:mappings][name]\n+          # Explicit mapping\n+          value = expr.safeevaluate(cns_scope)\n+        else\n+          value = cns[name]\n+        end\n+        if value","path":"lib/puppet/parser/resource.rb","position":40,"original_position":36,"commit_id":"3fff1be88eca20a21c95973139e93e16cc84689f","original_commit_id":"72cdf554af5a4335337a251b57a6c0e8c27d11b1","user":{"login":"hlindberg","id":563066,"avatar_url":"https://avatars.githubusercontent.com/u/563066?v=3","gravatar_id":"","url":"https://api.github.com/users/hlindberg","html_url":"https://github.com/hlindberg","followers_url":"https://api.github.com/users/hlindberg/followers","following_url":"https://api.github.com/users/hlindberg/following{/other_user}","gists_url":"https://api.github.com/users/hlindberg/gists{/gist_id}","starred_url":"https://api.github.com/users/hlindberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hlindberg/subscriptions","organizations_url":"https://api.github.com/users/hlindberg/orgs","repos_url":"https://api.github.com/users/hlindberg/repos","events_url":"https://api.github.com/users/hlindberg/events{/privacy}","received_events_url":"https://api.github.com/users/hlindberg/received_events","type":"User","site_admin":false},"body":"well, if there is an \"explicit mapping\" - it calls ´expr.safeevaluate´ - then the result of that is assign to ´value´. I assume that can return a boolean ´false´ value. If it does, the value will not be used to set `map[name] = value` on line 243. \r\nSuggest changing to ´unless value.nil?´","created_at":"2015-09-01T01:06:18Z","updated_at":"2015-09-01T01:06:18Z","html_url":"https://github.com/puppetlabs/puppet/pull/4169#discussion_r38377338","pull_request_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments/38377338"},"html":{"href":"https://github.com/puppetlabs/puppet/pull/4169#discussion_r38377338"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169","id":42648017,"html_url":"https://github.com/puppetlabs/puppet/pull/4169","diff_url":"https://github.com/puppetlabs/puppet/pull/4169.diff","patch_url":"https://github.com/puppetlabs/puppet/pull/4169.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppet/issues/4169","number":4169,"state":"open","locked":false,"title":"(PUP-5045) Evaluate produced/consumed resources ","user":{"login":"lutter","id":23697,"avatar_url":"https://avatars.githubusercontent.com/u/23697?v=3","gravatar_id":"","url":"https://api.github.com/users/lutter","html_url":"https://github.com/lutter","followers_url":"https://api.github.com/users/lutter/followers","following_url":"https://api.github.com/users/lutter/following{/other_user}","gists_url":"https://api.github.com/users/lutter/gists{/gist_id}","starred_url":"https://api.github.com/users/lutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lutter/subscriptions","organizations_url":"https://api.github.com/users/lutter/orgs","repos_url":"https://api.github.com/users/lutter/repos","events_url":"https://api.github.com/users/lutter/events{/privacy}","received_events_url":"https://api.github.com/users/lutter/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-17T23:57:52Z","updated_at":"2015-09-01T01:06:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c8a85602a49407be4d662b4eedad0e4e0779658a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppet/issues/4169/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppet/statuses/3fff1be88eca20a21c95973139e93e16cc84689f","head":{"label":"lutter:pup/5045","ref":"pup/5045","sha":"3fff1be88eca20a21c95973139e93e16cc84689f","user":{"login":"lutter","id":23697,"avatar_url":"https://avatars.githubusercontent.com/u/23697?v=3","gravatar_id":"","url":"https://api.github.com/users/lutter","html_url":"https://github.com/lutter","followers_url":"https://api.github.com/users/lutter/followers","following_url":"https://api.github.com/users/lutter/following{/other_user}","gists_url":"https://api.github.com/users/lutter/gists{/gist_id}","starred_url":"https://api.github.com/users/lutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lutter/subscriptions","organizations_url":"https://api.github.com/users/lutter/orgs","repos_url":"https://api.github.com/users/lutter/repos","events_url":"https://api.github.com/users/lutter/events{/privacy}","received_events_url":"https://api.github.com/users/lutter/received_events","type":"User","site_admin":false},"repo":{"id":332593,"name":"puppet","full_name":"lutter/puppet","owner":{"login":"lutter","id":23697,"avatar_url":"https://avatars.githubusercontent.com/u/23697?v=3","gravatar_id":"","url":"https://api.github.com/users/lutter","html_url":"https://github.com/lutter","followers_url":"https://api.github.com/users/lutter/followers","following_url":"https://api.github.com/users/lutter/following{/other_user}","gists_url":"https://api.github.com/users/lutter/gists{/gist_id}","starred_url":"https://api.github.com/users/lutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lutter/subscriptions","organizations_url":"https://api.github.com/users/lutter/orgs","repos_url":"https://api.github.com/users/lutter/repos","events_url":"https://api.github.com/users/lutter/events{/privacy}","received_events_url":"https://api.github.com/users/lutter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lutter/puppet","description":"Server automation framework and application","fork":true,"url":"https://api.github.com/repos/lutter/puppet","forks_url":"https://api.github.com/repos/lutter/puppet/forks","keys_url":"https://api.github.com/repos/lutter/puppet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lutter/puppet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lutter/puppet/teams","hooks_url":"https://api.github.com/repos/lutter/puppet/hooks","issue_events_url":"https://api.github.com/repos/lutter/puppet/issues/events{/number}","events_url":"https://api.github.com/repos/lutter/puppet/events","assignees_url":"https://api.github.com/repos/lutter/puppet/assignees{/user}","branches_url":"https://api.github.com/repos/lutter/puppet/branches{/branch}","tags_url":"https://api.github.com/repos/lutter/puppet/tags","blobs_url":"https://api.github.com/repos/lutter/puppet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lutter/puppet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lutter/puppet/git/refs{/sha}","trees_url":"https://api.github.com/repos/lutter/puppet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lutter/puppet/statuses/{sha}","languages_url":"https://api.github.com/repos/lutter/puppet/languages","stargazers_url":"https://api.github.com/repos/lutter/puppet/stargazers","contributors_url":"https://api.github.com/repos/lutter/puppet/contributors","subscribers_url":"https://api.github.com/repos/lutter/puppet/subscribers","subscription_url":"https://api.github.com/repos/lutter/puppet/subscription","commits_url":"https://api.github.com/repos/lutter/puppet/commits{/sha}","git_commits_url":"https://api.github.com/repos/lutter/puppet/git/commits{/sha}","comments_url":"https://api.github.com/repos/lutter/puppet/comments{/number}","issue_comment_url":"https://api.github.com/repos/lutter/puppet/issues/comments{/number}","contents_url":"https://api.github.com/repos/lutter/puppet/contents/{+path}","compare_url":"https://api.github.com/repos/lutter/puppet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lutter/puppet/merges","archive_url":"https://api.github.com/repos/lutter/puppet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lutter/puppet/downloads","issues_url":"https://api.github.com/repos/lutter/puppet/issues{/number}","pulls_url":"https://api.github.com/repos/lutter/puppet/pulls{/number}","milestones_url":"https://api.github.com/repos/lutter/puppet/milestones{/number}","notifications_url":"https://api.github.com/repos/lutter/puppet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lutter/puppet/labels{/name}","releases_url":"https://api.github.com/repos/lutter/puppet/releases{/id}","created_at":"2009-10-09T22:02:16Z","updated_at":"2015-04-01T21:23:34Z","pushed_at":"2015-08-29T19:40:07Z","git_url":"git://github.com/lutter/puppet.git","ssh_url":"git@github.com:lutter/puppet.git","clone_url":"https://github.com/lutter/puppet.git","svn_url":"https://github.com/lutter/puppet","homepage":"http://reductivelabs.com/trac/puppet/","size":49592,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"82ef870916ba6729ceb177e585f4cabf768d6f74","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":910744,"name":"puppet","full_name":"puppetlabs/puppet","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppet","description":"Server automation framework and application","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppet","forks_url":"https://api.github.com/repos/puppetlabs/puppet/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppet/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppet/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppet/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppet/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppet/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppet/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppet/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppet/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppet/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppet/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppet/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppet/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppet/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppet/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppet/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppet/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppet/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppet/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppet/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppet/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppet/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppet/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppet/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppet/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppet/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppet/releases{/id}","created_at":"2010-09-14T19:26:44Z","updated_at":"2015-08-31T09:50:51Z","pushed_at":"2015-08-31T22:52:48Z","git_url":"git://github.com/puppetlabs/puppet.git","ssh_url":"git@github.com:puppetlabs/puppet.git","clone_url":"https://github.com/puppetlabs/puppet.git","svn_url":"https://github.com/puppetlabs/puppet","homepage":"http://www.puppetlabs.com/puppet/introduction/","size":118730,"stargazers_count":3517,"watchers_count":3517,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1466,"mirror_url":null,"open_issues_count":37,"forks":1466,"open_issues":37,"watchers":3517,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169"},"html":{"href":"https://github.com/puppetlabs/puppet/pull/4169"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppet/issues/4169"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppet/issues/4169/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4169/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppet/statuses/3fff1be88eca20a21c95973139e93e16cc84689f"}}}}