Method: Puppet::Parser::Compiler#add_resource

Defined in:
lib/puppet/parser/compiler.rb

#add_resource(scope, resource) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/puppet/parser/compiler.rb', line 76

def add_resource(scope, resource)
  @resources << resource

  # Note that this will fail if the resource is not unique.
  @catalog.add_resource(resource)

  if !resource.class? and resource[:stage]
    # TRANSLATORS "stage" is a keyword in Puppet and should not be translated
    raise ArgumentError, _("Only classes can set 'stage'; normal resources like %{resource} cannot change run stage") % { resource: resource }
  end

  # Stages should not be inside of classes.  They are always a
  # top-level container, regardless of where they appear in the
  # manifest.
  return if resource.stage?

  # This adds a resource to the class it lexically appears in in the
  # manifest.
  unless resource.class?
    @catalog.add_edge(scope.resource, resource)
  end
end