Last change
on this file since 30960 was 30960, checked in by davidb, 7 years ago |
Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster
|
File size:
877 bytes
|
Line | |
---|
1 | #
|
---|
2 | # assert_private.rb
|
---|
3 | #
|
---|
4 |
|
---|
5 | module Puppet::Parser::Functions
|
---|
6 | newfunction(:assert_private, :doc => <<-'EOS'
|
---|
7 | Sets the current class or definition as private.
|
---|
8 | Calling the class or definition from outside the current module will fail.
|
---|
9 | EOS
|
---|
10 | ) do |args|
|
---|
11 |
|
---|
12 | raise(Puppet::ParseError, "assert_private(): Wrong number of arguments "+
|
---|
13 | "given (#{args.size}}) for 0 or 1)") if args.size > 1
|
---|
14 |
|
---|
15 | scope = self
|
---|
16 | if scope.lookupvar('module_name') != scope.lookupvar('caller_module_name')
|
---|
17 | message = nil
|
---|
18 | if args[0] and args[0].is_a? String
|
---|
19 | message = args[0]
|
---|
20 | else
|
---|
21 | manifest_name = scope.source.name
|
---|
22 | manifest_type = scope.source.type
|
---|
23 | message = (manifest_type.to_s == 'hostclass') ? 'Class' : 'Definition'
|
---|
24 | message += " #{manifest_name} is private"
|
---|
25 | end
|
---|
26 | raise(Puppet::ParseError, message)
|
---|
27 | end
|
---|
28 | end
|
---|
29 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.