Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb

Issue 29338046: Issue 3638 - Introduce type adblockplus::host (Closed)
Patch Set: Created March 9, 2016, 11:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | modules/adblockplus/manifests/host.pp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb
diff --git a/modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb b/modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb
new file mode 100644
index 0000000000000000000000000000000000000000..0ab4ed898dfce318930c318221515cbbb705d3fc
--- /dev/null
+++ b/modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb
@@ -0,0 +1,35 @@
+module Puppet::Parser::Functions
+
+ newfunction(:manifest_exists, :type => :rvalue, :doc => <<-'begin') do |args|
+ Determine if a Puppet manifest (*.pp file) exists for the given type name,
+ within the Puppet hierarchy of the (adblockplus) module's parent directory
+ begin
+
+ if args.size != 1
+ message = "Usage: manifest_exists('some::definition::name')"
+ raise Puppet::ParseError, message
+ end
+
+ # 'foo::bar::baz' => 'foo', ['bar', 'baz']
+ module_name, *remainder = args[0].to_s.split('::')
+
+ base_directory = File.expand_path(File.join(
+ File.dirname(__FILE__),
+ '..', # parser
+ '..', # puppet
+ '..', # lib
+ '..', # $module
+ '..' # modules
+ ))
+
+ manifest_path = File.join(
+ base_directory,
+ module_name,
+ 'manifests',
+ File.join(*remainder) << '.pp'
+ )
+
+ return File.exists? manifest_path
+
+ end
+end
« no previous file with comments | « no previous file | modules/adblockplus/manifests/host.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld