{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments/40232168","id":40232168,"diff_hunk":"@@ -40,20 +46,62 @@ def compile\n     end\n   end\n \n-  def add_resource(scope, resource)\n-    type = resource.resource_type\n-    # At topscope, only applications and Class[main] are allowed. Elsewhere,\n-    # only components and capabilities are allowed.\n-    if scope == @topscope\n-      if ! (type.is_a?(Puppet::Resource::Type) && type.application?) && resource != @main_resource\n-        raise ArgumentError, \"Only applications are allowed at topscope, not #{resource.ref}\"\n-      end\n+  # Prunes the catalog by dropping all resources that are not contained under the Site (if a site expression is used).\n+  # As a consequence all edges to/from dropped resources are also dropped.\n+  # Once the pruning is performed, this compiler returns the pruned list when calling the #resources method.\n+  # The pruning does not alter the order of resources in the resources list.\n+  #\n+  def prune_catalog\n+    # Everything under Class[main], that is not under (inclusive of) Site[site] should be pruned as those resources\n+    # are intended for nodes in a node catalog.\n+    #\n+    the_main_class_resource = @catalog.resource('Class', '')\n+    the_site_resource = @catalog.resource('Site', 'site')\n+\n+    # Get downstream vertexes returns a hash where the keys are the resources and values nesting level\n+    rooted_in_main = @catalog.downstream_from_vertex(the_main_class_resource).keys\n+    if the_site_resource\n+      keep_from_site = @catalog.downstream_from_vertex(the_site_resource).keys\n+      keep_from_site << the_site_resource\n     else\n-      unless (resource.is_application_component? || resource.is_capability?)","path":"lib/puppet/parser/environment_compiler.rb","position":47,"original_position":47,"commit_id":"285a3b141ff8705fe96c943c453d02e24ecdba41","original_commit_id":"285a3b141ff8705fe96c943c453d02e24ecdba41","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":"Yes, that seems right to me; inside the `site` statement we want, after evaluation, applications and their components. I am not entirely clear whether containment is set up right, but assuming it is, we should have inside `site` something like `app_instance -> component -> other_stuff` - we want the app_instance in there and the component; the other_stuff is not an error but we don't care about it. I am not sure whether that happens, but during environment compilation it's sufficient to evaluate just to the point where we know the type/title of components and the type/title of capability resources referenced by `export`, `consume` or any of the standard relationship metaparams. IOW, we do not need to actually evaluate the bodies of components.","created_at":"2015-09-23T17:29:48Z","updated_at":"2015-09-23T17:29:48Z","html_url":"https://github.com/puppetlabs/puppet/pull/4264#discussion_r40232168","pull_request_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments/40232168"},"html":{"href":"https://github.com/puppetlabs/puppet/pull/4264#discussion_r40232168"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264","id":45406481,"html_url":"https://github.com/puppetlabs/puppet/pull/4264","diff_url":"https://github.com/puppetlabs/puppet/pull/4264.diff","patch_url":"https://github.com/puppetlabs/puppet/pull/4264.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppet/issues/4264","number":4264,"state":"open","locked":false,"title":"REVIEW ONLY: (PUP-5076) Fail non app components in site catalog","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":"This stands on PUP 5087 (contained in this PR since it is not yet merged).","created_at":"2015-09-18T13:33:24Z","updated_at":"2015-09-23T17:29:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"589fb0986cf887c96f12eff426d70b9c0661516d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppet/issues/4264/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppet/statuses/285a3b141ff8705fe96c943c453d02e24ecdba41","head":{"label":"hlindberg:PUP-5076_fail-non-app-components-in-site-catalog","ref":"PUP-5076_fail-non-app-components-in-site-catalog","sha":"285a3b141ff8705fe96c943c453d02e24ecdba41","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},"repo":{"id":5693635,"name":"puppet","full_name":"hlindberg/puppet","owner":{"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},"private":false,"html_url":"https://github.com/hlindberg/puppet","description":"Server automation framework and application","fork":true,"url":"https://api.github.com/repos/hlindberg/puppet","forks_url":"https://api.github.com/repos/hlindberg/puppet/forks","keys_url":"https://api.github.com/repos/hlindberg/puppet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hlindberg/puppet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hlindberg/puppet/teams","hooks_url":"https://api.github.com/repos/hlindberg/puppet/hooks","issue_events_url":"https://api.github.com/repos/hlindberg/puppet/issues/events{/number}","events_url":"https://api.github.com/repos/hlindberg/puppet/events","assignees_url":"https://api.github.com/repos/hlindberg/puppet/assignees{/user}","branches_url":"https://api.github.com/repos/hlindberg/puppet/branches{/branch}","tags_url":"https://api.github.com/repos/hlindberg/puppet/tags","blobs_url":"https://api.github.com/repos/hlindberg/puppet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hlindberg/puppet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hlindberg/puppet/git/refs{/sha}","trees_url":"https://api.github.com/repos/hlindberg/puppet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hlindberg/puppet/statuses/{sha}","languages_url":"https://api.github.com/repos/hlindberg/puppet/languages","stargazers_url":"https://api.github.com/repos/hlindberg/puppet/stargazers","contributors_url":"https://api.github.com/repos/hlindberg/puppet/contributors","subscribers_url":"https://api.github.com/repos/hlindberg/puppet/subscribers","subscription_url":"https://api.github.com/repos/hlindberg/puppet/subscription","commits_url":"https://api.github.com/repos/hlindberg/puppet/commits{/sha}","git_commits_url":"https://api.github.com/repos/hlindberg/puppet/git/commits{/sha}","comments_url":"https://api.github.com/repos/hlindberg/puppet/comments{/number}","issue_comment_url":"https://api.github.com/repos/hlindberg/puppet/issues/comments{/number}","contents_url":"https://api.github.com/repos/hlindberg/puppet/contents/{+path}","compare_url":"https://api.github.com/repos/hlindberg/puppet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hlindberg/puppet/merges","archive_url":"https://api.github.com/repos/hlindberg/puppet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hlindberg/puppet/downloads","issues_url":"https://api.github.com/repos/hlindberg/puppet/issues{/number}","pulls_url":"https://api.github.com/repos/hlindberg/puppet/pulls{/number}","milestones_url":"https://api.github.com/repos/hlindberg/puppet/milestones{/number}","notifications_url":"https://api.github.com/repos/hlindberg/puppet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hlindberg/puppet/labels{/name}","releases_url":"https://api.github.com/repos/hlindberg/puppet/releases{/id}","created_at":"2012-09-05T21:08:12Z","updated_at":"2014-06-25T01:27:30Z","pushed_at":"2015-09-22T23:58:38Z","git_url":"git://github.com/hlindberg/puppet.git","ssh_url":"git@github.com:hlindberg/puppet.git","clone_url":"https://github.com/hlindberg/puppet.git","svn_url":"https://github.com/hlindberg/puppet","homepage":"http://www.puppetlabs.com/puppet/introduction/","size":158824,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"119c4c03dd38fbf60cb5c2abb54699f9b5b755bf","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-09-23T12:30:15Z","pushed_at":"2015-09-23T15:47:39Z","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":"https://puppetlabs.com/puppet/what-is-puppet","size":119831,"stargazers_count":3554,"watchers_count":3554,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1483,"mirror_url":null,"open_issues_count":41,"forks":1483,"open_issues":41,"watchers":3554,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264"},"html":{"href":"https://github.com/puppetlabs/puppet/pull/4264"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppet/issues/4264"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppet/issues/4264/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/4264/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppet/statuses/285a3b141ff8705fe96c943c453d02e24ecdba41"}}}}