diff options
author | Luke Kanies <luke@madstop.com> | 2007-08-25 17:14:13 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-08-25 17:14:13 -0500 |
commit | 9df4fd1f2188c90190e33e165206e7931938607b (patch) | |
tree | 071a42fa559ffd800a4d0e586a8bd05f0e31f3a1 /lib | |
parent | ba3a861af2e5c30fd9bbbe0e1666fa316139113b (diff) | |
download | puppet-9df4fd1f2188c90190e33e165206e7931938607b.tar.gz puppet-9df4fd1f2188c90190e33e165206e7931938607b.tar.xz puppet-9df4fd1f2188c90190e33e165206e7931938607b.zip |
And we have multiple environment support in the parser. The only remaining piece to make this complete is to add multiple environment support to the fileserver. I also renamed Configuration.rb to Compile.rb (that is, I fixed all the classes that used to know it as a configuration).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/module.rb | 20 | ||||
-rw-r--r-- | lib/puppet/parser/compile.rb | 3 | ||||
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/parser.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/parser_support.rb | 18 |
5 files changed, 25 insertions, 24 deletions
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 34b13edb7..924958bbe 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -43,17 +43,25 @@ class Puppet::Module # param. # In all cases, an absolute path is returned, which does not # necessarily refer to an existing file - def self.find_template(file, environment = nil) - if file =~ /^#{File::SEPARATOR}/ - return file + def self.find_template(template, environment = nil) + if template =~ /^#{File::SEPARATOR}/ + return template end - path, file = split_path(file) - mod = find(path, environment) + path, file = split_path(template) + + # Because templates don't have an assumed template name, like manifests do, + # we treat templates with no name as being templates in the main template + # directory. + if file.nil? + mod = nil + else + mod = find(path, environment) + end if mod return mod.template(file) else - return File.join(Puppet.config.value(:templatedir, environment), path, file) + return File.join(Puppet.config.value(:templatedir, environment), template) end end diff --git a/lib/puppet/parser/compile.rb b/lib/puppet/parser/compile.rb index 6cfe66fce..710f90273 100644 --- a/lib/puppet/parser/compile.rb +++ b/lib/puppet/parser/compile.rb @@ -102,6 +102,8 @@ class Puppet::Parser::Compile unless defined? @environment if node.environment and node.environment != "" @environment = node.environment + else + @environment = nil end end @environment @@ -232,7 +234,6 @@ class Puppet::Parser::Compile # Now see if we can find the node. astnode = nil - #nodes = @parser.nodes @node.names.each do |name| break if astnode = @parser.nodes[name.to_s.downcase] end diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index c0f9d32a7..b6c61d202 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -25,7 +25,7 @@ class Puppet::Parser::Interpreter # evaluate our whole tree def compile(node) - return Puppet::Parser::Configuration.new(node, parser(node.environment), :ast_nodes => usenodes?).compile + return Puppet::Parser::Compile.new(node, parser(node.environment), :ast_nodes => usenodes?).compile end # create our interpreter @@ -62,7 +62,7 @@ class Puppet::Parser::Interpreter # Create a new parser object and pre-parse the configuration. def create_parser(environment) begin - parser = Puppet::Parser::Parser.new(environment) + parser = Puppet::Parser::Parser.new(:environment => environment) if self.code parser.string = self.code elsif self.file diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index 21a054223..aaffa816e 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -29,7 +29,7 @@ module Puppet class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..idc5e5087e93', 'grammar.ra', 640 +module_eval <<'..end grammar.ra modeval..idc3bb85ed76', 'grammar.ra', 640 # It got too annoying having code in a file that needs to be compiled. require 'puppet/parser/parser_support' @@ -41,7 +41,7 @@ require 'puppet/parser/parser_support' # $Id$ -..end grammar.ra modeval..idc5e5087e93 +..end grammar.ra modeval..idc3bb85ed76 ##### racc 1.4.5 generates ### diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index dfc91ba12..401b5b1c0 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -176,14 +176,14 @@ class Puppet::Parser::Parser "in file #{@lexer.file} at line #{@lexer.line}" ) end - files = Puppet::Module::find_manifests(pat, dir) + files = Puppet::Module::find_manifests(pat, :cwd => dir) if files.size == 0 raise Puppet::ImportError.new("No file(s) found for import " + "of '#{pat}'") end files.collect { |file| - parser = Puppet::Parser::Parser.new(@astset) + parser = Puppet::Parser::Parser.new(:astset => @astset, :environment => @environment) parser.files = self.files Puppet.debug("importing '%s'" % file) @@ -202,8 +202,9 @@ class Puppet::Parser::Parser } end - def initialize(environment) - @environment = environment + def initialize(options = {}) + @astset = options[:astset] || ASTSet.new({}, {}, {}) + @environment = options[:environment] initvars() end @@ -212,15 +213,6 @@ class Puppet::Parser::Parser @lexer = Puppet::Parser::Lexer.new() @files = [] @loaded = [] - - # This is where we store our classes and definitions and nodes. - # Clear each hash, just to help the GC a bit. - if defined?(@astset) - [:classes, :definitions, :nodes].each do |name| - @astset.send(name).clear - end - end - @astset = ASTSet.new({}, {}, {}) end # Try to load a class, since we could not find it. |