summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/ast/resource.rb7
-rw-r--r--lib/puppet/parser/compiler.rb4
-rw-r--r--lib/puppet/parser/lexer.rb3
-rw-r--r--lib/puppet/provider/service/launchd.rb2
-rw-r--r--lib/puppet/resource.rb10
-rw-r--r--lib/puppet/resource/type.rb31
-rw-r--r--lib/puppet/util/reference.rb2
7 files changed, 37 insertions, 22 deletions
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb
index bd15d9935..ce3c499c5 100644
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@ -53,10 +53,11 @@ class Resource < AST::Branch
:strict => true
)
- # And then store the resource in the compiler.
- # At some point, we need to switch all of this to return
- # resources instead of storing them like this.
+ if resource.resource_type.is_a? Puppet::Resource::Type
+ resource.resource_type.instantiate_resource(scope, resource)
+ end
scope.compiler.add_resource(scope, resource)
+ scope.compiler.evaluate_classes([resource_title],scope,false) if fully_qualified_type == 'class'
resource
end
}
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index e1227e753..c60e1d4fb 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -144,7 +144,7 @@ class Puppet::Parser::Compiler
if klass = scope.find_hostclass(name)
found << name and next if scope.class_scope(klass)
- resource = klass.mk_plain_resource(scope)
+ resource = klass.ensure_in_catalog(scope)
# If they've disabled lazy evaluation (which the :include function does),
# then evaluate our resource immediately.
@@ -220,7 +220,7 @@ class Puppet::Parser::Compiler
# Create a resource to model this node, and then add it to the list
# of resources.
- resource = astnode.mk_plain_resource(topscope)
+ resource = astnode.ensure_in_catalog(topscope)
resource.evaluate
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 9036d652e..31d39ae2f 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -522,13 +522,14 @@ class Puppet::Parser::Lexer
# backslash; the caret is there to match empty strings
str = @scanner.scan_until(/([^\\]|^|[^\\])([\\]{2})*[#{terminators}]/) or lex_error "Unclosed quote after '#{last}' in '#{rest}'"
@line += str.count("\n") # literal carriage returns add to the line count.
- str.gsub!(/\\(.)/) {
+ str.gsub!(/\\(.)/m) {
ch = $1
if escapes.include? ch
case ch
when 'n'; "\n"
when 't'; "\t"
when 's'; " "
+ when "\n": ''
else ch
end
else
diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb
index b296e0a38..1632edabf 100644
--- a/lib/puppet/provider/service/launchd.rb
+++ b/lib/puppet/provider/service/launchd.rb
@@ -56,7 +56,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
# Read a plist, whether its format is XML or in Apple's "binary1"
# format.
def self.read_plist(path)
- Plist::parse_xml(plutil('-convert', 'xml1', '-o', '-', path))
+ Plist::parse_xml(plutil('-convert', 'xml1', '-o', '/dev/stdout', path))
end
# returns a label => path map for either all jobs, or just a single
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 39803b077..7dea270e8 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -154,6 +154,14 @@ class Puppet::Resource
end
end
+ # This stub class is only needed for serialization compatibility with 0.25.x
+ class Reference
+ attr_accessor :type,:title
+ def initialize(type,title)
+ @type,@title = type,title
+ end
+ end
+
# Create our resource.
def initialize(type, title = nil, attributes = {})
@parameters = {}
@@ -180,6 +188,8 @@ class Puppet::Resource
tag(self.type)
tag(self.title) if valid_tag?(self.title)
+ @reference = Reference.new(@type,@title) # for serialization compatibility with 0.25.x
+
raise ArgumentError, "Invalid resource type #{type}" if strict? and ! resource_type
end
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index 3edf286bb..77824845d 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -140,21 +140,15 @@ class Puppet::Resource::Type
end
end
- # Make an instance of our resource type. This is only possible
- # for those classes and nodes that don't have any arguments, and is
- # only useful for things like the 'include' function.
- def mk_plain_resource(scope)
+ # Make an instance of the resource type, and place it in the catalog
+ # if it isn't in the catalog already. This is only possible for
+ # classes and nodes. No parameters are be supplied--if this is a
+ # parameterized class, then all parameters take on their default
+ # values.
+ def ensure_in_catalog(scope)
type == :definition and raise ArgumentError, "Cannot create resources for defined resource types"
resource_type = type == :hostclass ? :class : :node
- # Make sure our parent class has been evaluated, if we have one.
- if parent
- parent_resource = scope.catalog.resource(resource_type, parent)
- unless parent_resource
- parent_type(scope).mk_plain_resource(scope)
- end
- end
-
# Do nothing if the resource already exists; this makes sure we don't
# get multiple copies of the class resource, which helps provide the
# singleton nature of classes.
@@ -163,11 +157,22 @@ class Puppet::Resource::Type
end
resource = Puppet::Parser::Resource.new(resource_type, name, :scope => scope, :source => self)
+ instantiate_resource(scope, resource)
scope.compiler.add_resource(scope, resource)
- scope.catalog.tag(*resource.tags)
resource
end
+ def instantiate_resource(scope, resource)
+ # Make sure our parent class has been evaluated, if we have one.
+ if parent && !scope.catalog.resource(resource.type, parent)
+ parent_type(scope).ensure_in_catalog(scope)
+ end
+
+ if ['Class', 'Node'].include? resource.type
+ scope.catalog.tag(*resource.tags)
+ end
+ end
+
def name
return @name unless @name.is_a?(Regexp)
@name.source.downcase.gsub(/[^-\w:.]/,'').sub(/^\.+/,'')
diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb
index 99458aa57..ab201cde4 100644
--- a/lib/puppet/util/reference.rb
+++ b/lib/puppet/util/reference.rb
@@ -32,7 +32,6 @@ class Puppet::Util::Reference
section = reference(name) or raise "Could not find section #{name}"
depth = section.depth if section.depth < depth
end
- text = "* TOC text.\n{:toc}\n\n"
end
def self.pdf(text)
@@ -141,7 +140,6 @@ class Puppet::Util::Reference
# First the header
text = h(@title, 1)
text += "\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on #{Time.now.to_s})*\n\n"
- text += "* TOC Text.\n{:toc}\n\n" if withcontents
text += @header