summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/grammar.ra
diff options
context:
space:
mode:
authorlutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-09 00:52:47 +0000
committerlutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-09 00:52:47 +0000
commit0fa3c434b658fe432c306dc9e52e6b8c949ad3cf (patch)
tree21f012dd7ef63123f00cf5d207313177ed17d1aa /lib/puppet/parser/grammar.ra
parent38975de420bfd2f1350e7e55a996db40bc05d0b8 (diff)
downloadpuppet-0fa3c434b658fe432c306dc9e52e6b8c949ad3cf.tar.gz
puppet-0fa3c434b658fe432c306dc9e52e6b8c949ad3cf.tar.xz
puppet-0fa3c434b658fe432c306dc9e52e6b8c949ad3cf.zip
Search manifests first within modules, and if no module is found, search in
the directory the current manifest is in. Glob patterns can be used for the path, but the path only matches a module if the first part of the path is not a glob. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2279 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/grammar.ra')
-rw-r--r--lib/puppet/parser/grammar.ra71
1 files changed, 33 insertions, 38 deletions
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index e0629fe9a..f191e2969 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -458,47 +458,42 @@ import: IMPORT quotedtext {
end
result = ast AST::ASTArray
- Dir.chdir(dir) {
- # We can't interpolate at this point since we don't have any
- # scopes set up. Warn the user if they use a variable reference
- pat = val[1].value
- if pat.index("$")
- Puppet.warning(
- "The import of #{pat} contains a variable reference;" +
- " variables are not interpolated for imports " +
- "in file #{@lexer.file} at line #{@lexer.line}"
- )
+ # We can't interpolate at this point since we don't have any
+ # scopes set up. Warn the user if they use a variable reference
+ pat = val[1].value
+ if pat.index("$")
+ Puppet.warning(
+ "The import of #{pat} contains a variable reference;" +
+ " variables are not interpolated for imports " +
+ "in file #{@lexer.file} at line #{@lexer.line}"
+ )
+ end
+ files = Puppet::Module::find_manifests(pat, dir)
+ if files.size == 0
+ raise Puppet::ImportError.new("No file(s) found for import " +
+ "of '#{pat}'")
+ end
+
+ files.each { |file|
+ parser = Puppet::Parser::Parser.new(interp)
+ parser.files = self.files
+ Puppet.debug("importing '%s'" % file)
+
+ unless file =~ /^#{File::SEPARATOR}/
+ file = File.join(dir, file)
end
- files = Dir.glob(pat)
- if files.size == 0
- files = Dir.glob(pat + ".pp")
- if files.size == 0
- raise Puppet::ImportError.new("No file(s) found for import " +
- "of '#{pat}'")
- end
+ begin
+ parser.file = file
+ rescue Puppet::ImportError
+ Puppet.warning(
+ "Importing %s would result in an import loop" %
+ File.join(dir, file)
+ )
+ next
end
- files.each { |file|
- parser = Puppet::Parser::Parser.new(interp)
- parser.files = self.files
- Puppet.debug("importing '%s'" % file)
-
- unless file =~ /^#{File::SEPARATOR}/
- file = File.join(dir, file)
- end
- begin
- parser.file = file
- rescue Puppet::ImportError
- Puppet.warning(
- "Importing %s would result in an import loop" %
- File.join(dir, file)
- )
- next
- end
-
- # This will normally add code to the 'main' class.
- parser.parse
- }
+ # This will normally add code to the 'main' class.
+ parser.parse
}
}