puppet 2.7.1 → 2.7.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (171) hide show
  1. data/CHANGELOG +225 -1
  2. data/CONTRIBUTING.md +299 -0
  3. data/README.md +0 -1
  4. data/conf/redhat/puppet.spec +132 -25
  5. data/conf/solaris/pkginfo +1 -1
  6. data/conf/suse/puppet.spec +5 -2
  7. data/ext/envpuppet +56 -3
  8. data/ext/vim/README +2 -1
  9. data/ext/vim/ftplugin/puppet.vim +94 -0
  10. data/ext/vim/indent/puppet.vim +76 -0
  11. data/lib/puppet.rb +2 -3
  12. data/lib/puppet/application/agent.rb +7 -7
  13. data/lib/puppet/application/apply.rb +20 -8
  14. data/lib/puppet/application/ca.rb +5 -0
  15. data/lib/puppet/application/cert.rb +2 -1
  16. data/lib/puppet/application/certificate.rb +0 -5
  17. data/lib/puppet/application/device.rb +4 -4
  18. data/lib/puppet/application/doc.rb +23 -12
  19. data/lib/puppet/application/face_base.rb +2 -1
  20. data/lib/puppet/application/inspect.rb +5 -2
  21. data/lib/puppet/configurer.rb +60 -56
  22. data/lib/puppet/configurer/fact_handler.rb +6 -1
  23. data/lib/puppet/defaults.rb +20 -1
  24. data/lib/puppet/face/ca.rb +233 -0
  25. data/lib/puppet/face/certificate.rb +15 -11
  26. data/lib/puppet/face/certificate_request.rb +9 -11
  27. data/lib/puppet/face/certificate_revocation_list.rb +5 -7
  28. data/lib/puppet/face/node/clean.rb +154 -0
  29. data/lib/puppet/face/status.rb +1 -0
  30. data/lib/puppet/file_serving/configuration/parser.rb +6 -13
  31. data/lib/puppet/indirector/exec.rb +3 -3
  32. data/lib/puppet/indirector/face.rb +17 -7
  33. data/lib/puppet/indirector/report/processor.rb +29 -16
  34. data/lib/puppet/indirector/rest.rb +42 -7
  35. data/lib/puppet/indirector/yaml.rb +5 -0
  36. data/lib/puppet/interface.rb +7 -2
  37. data/lib/puppet/interface/action.rb +57 -23
  38. data/lib/puppet/interface/action_manager.rb +10 -5
  39. data/lib/puppet/interface/face_collection.rb +43 -52
  40. data/lib/puppet/interface/option.rb +19 -0
  41. data/lib/puppet/interface/option_builder.rb +13 -0
  42. data/lib/puppet/interface/option_manager.rb +2 -1
  43. data/lib/puppet/metatype/manager.rb +7 -20
  44. data/lib/puppet/module.rb +4 -1
  45. data/lib/puppet/network/authconfig.rb +3 -1
  46. data/lib/puppet/network/authstore.rb +14 -5
  47. data/lib/puppet/network/handler/fileserver.rb +3 -0
  48. data/lib/puppet/network/http/webrick.rb +1 -1
  49. data/lib/puppet/network/rest_authconfig.rb +6 -1
  50. data/lib/puppet/network/rest_authorization.rb +1 -1
  51. data/lib/puppet/parser/compiler.rb +8 -11
  52. data/lib/puppet/parser/functions.rb +1 -6
  53. data/lib/puppet/parser/functions/create_resources.rb +6 -5
  54. data/lib/puppet/parser/functions/regsubst.rb +26 -0
  55. data/lib/puppet/parser/functions/shellquote.rb +26 -0
  56. data/lib/puppet/parser/functions/sprintf.rb +26 -0
  57. data/lib/puppet/parser/grammar.ra +34 -60
  58. data/lib/puppet/parser/lexer.rb +5 -5
  59. data/lib/puppet/parser/parser.rb +913 -1196
  60. data/lib/puppet/parser/resource.rb +18 -1
  61. data/lib/puppet/parser/scope.rb +2 -2
  62. data/lib/puppet/provider/augeas/augeas.rb +42 -17
  63. data/lib/puppet/provider/mount/parsed.rb +19 -1
  64. data/lib/puppet/provider/naginator.rb +9 -1
  65. data/lib/puppet/provider/nameservice/directoryservice.rb +11 -8
  66. data/lib/puppet/provider/network_device.rb +1 -1
  67. data/lib/puppet/provider/package/aptitude.rb +1 -0
  68. data/lib/puppet/provider/package/pacman.rb +94 -0
  69. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -6
  70. data/lib/puppet/rails/host.rb +7 -0
  71. data/lib/puppet/reports/store.rb +15 -0
  72. data/lib/puppet/resource/catalog.rb +15 -6
  73. data/lib/puppet/ssl/certificate.rb +6 -0
  74. data/lib/puppet/ssl/inventory.rb +2 -0
  75. data/lib/puppet/transaction.rb +9 -17
  76. data/lib/puppet/transaction/report.rb +3 -3
  77. data/lib/puppet/type.rb +13 -24
  78. data/lib/puppet/type/file.rb +8 -2
  79. data/lib/puppet/type/file/source.rb +2 -2
  80. data/lib/puppet/type/service.rb +20 -24
  81. data/lib/puppet/type/ssh_authorized_key.rb +12 -0
  82. data/lib/puppet/type/user.rb +8 -0
  83. data/lib/puppet/util.rb +0 -1
  84. data/lib/puppet/util/network_device.rb +3 -3
  85. data/lib/puppet/util/settings.rb +1 -1
  86. data/lib/puppet/util/settings/file_setting.rb +1 -0
  87. data/lib/semver.rb +65 -0
  88. data/spec/integration/defaults_spec.rb +23 -1
  89. data/spec/integration/network/rest_authconfig_spec.rb +145 -0
  90. data/spec/integration/node/facts_spec.rb +1 -1
  91. data/spec/integration/parser/functions_spec.rb +1 -1
  92. data/spec/integration/parser/parser_spec.rb +31 -0
  93. data/spec/integration/provider/ssh_authorized_key_spec.rb +207 -0
  94. data/spec/integration/type_spec.rb +11 -0
  95. data/spec/lib/puppet/face/1.0.0/huzzah.rb +8 -0
  96. data/spec/lib/puppet/face/huzzah.rb +1 -0
  97. data/spec/lib/puppet/face/huzzah/obsolete.rb +6 -0
  98. data/spec/shared_behaviours/things_that_declare_options.rb +115 -3
  99. data/spec/unit/application/agent_spec.rb +2 -2
  100. data/spec/unit/application/apply_spec.rb +74 -56
  101. data/spec/unit/application/cert_spec.rb +10 -0
  102. data/spec/unit/application/device_spec.rb +2 -3
  103. data/spec/unit/application/face_base_spec.rb +1 -0
  104. data/spec/unit/application/facts_spec.rb +1 -0
  105. data/spec/unit/application/inspect_spec.rb +5 -0
  106. data/spec/unit/configurer/fact_handler_spec.rb +45 -37
  107. data/spec/unit/configurer_spec.rb +405 -327
  108. data/spec/unit/face/ca_spec.rb +355 -0
  109. data/spec/unit/face/certificate_spec.rb +16 -4
  110. data/spec/unit/face/node_spec.rb +261 -1
  111. data/spec/unit/file_serving/configuration/parser_spec.rb +8 -0
  112. data/spec/unit/indirector/certificate/rest_spec.rb +1 -0
  113. data/spec/unit/indirector/certificate_status/file_spec.rb +4 -0
  114. data/spec/unit/indirector/exec_spec.rb +4 -4
  115. data/spec/unit/indirector/face_spec.rb +3 -1
  116. data/spec/unit/indirector/facts/couch_spec.rb +2 -2
  117. data/spec/unit/indirector/facts/network_device_spec.rb +2 -6
  118. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  119. data/spec/unit/indirector/report/processor_spec.rb +31 -8
  120. data/spec/unit/indirector/rest_spec.rb +53 -5
  121. data/spec/unit/indirector/yaml_spec.rb +18 -0
  122. data/spec/unit/interface/action_spec.rb +112 -8
  123. data/spec/unit/interface/face_collection_spec.rb +46 -36
  124. data/spec/unit/interface/option_spec.rb +44 -0
  125. data/spec/unit/interface_spec.rb +11 -6
  126. data/spec/unit/module_spec.rb +38 -9
  127. data/spec/unit/network/authconfig_spec.rb +23 -0
  128. data/spec/unit/network/authstore_spec.rb +36 -4
  129. data/spec/unit/network/handler/fileserver_spec.rb +32 -0
  130. data/spec/unit/network/rest_authconfig_spec.rb +1 -1
  131. data/spec/unit/node_spec.rb +1 -0
  132. data/spec/unit/parser/compiler_spec.rb +8 -46
  133. data/spec/unit/parser/lexer_spec.rb +27 -17
  134. data/spec/unit/parser/resource_spec.rb +61 -3
  135. data/spec/unit/parser/scope_spec.rb +5 -1
  136. data/spec/unit/provider/augeas/augeas_spec.rb +106 -1
  137. data/spec/unit/provider/cisco_spec.rb +3 -4
  138. data/spec/unit/provider/interface/cisco_spec.rb +1 -2
  139. data/spec/unit/provider/mount/parsed_spec.rb +41 -0
  140. data/spec/unit/provider/nameservice/directoryservice_spec.rb +60 -0
  141. data/spec/unit/provider/network_device_spec.rb +1 -2
  142. data/spec/unit/provider/package/pacman_spec.rb +237 -0
  143. data/spec/unit/provider/package/pkgutil_spec.rb +2 -3
  144. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +21 -32
  145. data/spec/unit/provider/vlan/cisco_spec.rb +1 -2
  146. data/spec/unit/rails/host_spec.rb +8 -0
  147. data/spec/unit/resource/catalog_spec.rb +55 -8
  148. data/spec/unit/semver_spec.rb +187 -0
  149. data/spec/unit/ssl/certificate_spec.rb +25 -0
  150. data/spec/unit/transaction/report_spec.rb +3 -3
  151. data/spec/unit/transaction_spec.rb +8 -2
  152. data/spec/unit/type/file_spec.rb +57 -0
  153. data/spec/unit/type/interface_spec.rb +1 -2
  154. data/spec/unit/type/schedule_spec.rb +73 -42
  155. data/spec/unit/type/ssh_authorized_key_spec.rb +180 -70
  156. data/spec/unit/type/user_spec.rb +8 -0
  157. data/spec/unit/type/vlan_spec.rb +1 -2
  158. data/spec/unit/type_spec.rb +66 -0
  159. data/spec/unit/util/network_device/cisco/device_spec.rb +1 -2
  160. data/spec/unit/util/network_device/cisco/facts_spec.rb +2 -3
  161. data/spec/unit/util/network_device/cisco/interface_spec.rb +1 -2
  162. data/spec/unit/util/network_device/config_spec.rb +3 -4
  163. data/spec/unit/util/network_device/ipcalc_spec.rb +1 -2
  164. data/spec/unit/util/network_device/transport/base_spec.rb +1 -2
  165. data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -2
  166. data/spec/unit/util/network_device/transport/telnet_spec.rb +1 -2
  167. data/spec/unit/util/network_device_spec.rb +2 -2
  168. data/spec/unit/util/settings/file_setting_spec.rb +4 -0
  169. data/spec/unit/util/settings_spec.rb +11 -0
  170. data/test/lib/puppettest/railstesting.rb +0 -34
  171. metadata +19 -4
@@ -38,6 +38,7 @@ class Puppet::Interface::Action
38
38
  def to_s() "#{@face}##{@name}" end
39
39
 
40
40
  attr_reader :name
41
+ attr_reader :face
41
42
  attr_accessor :default
42
43
  def default?
43
44
  !!@default
@@ -195,14 +196,12 @@ class Puppet::Interface::Action
195
196
  wrapper = <<WRAPPER
196
197
  def #{@name}(#{decl.join(", ")})
197
198
  #{optn}
198
- args = #{args}
199
- options = args.last
200
-
201
- action = get_action(#{name.inspect})
202
- action.validate_args(args)
203
- __invoke_decorations(:before, action, args, options)
199
+ args = #{args}
200
+ action = get_action(#{name.inspect})
201
+ args << action.validate_and_clean(args.pop)
202
+ __invoke_decorations(:before, action, args, args.last)
204
203
  rval = self.__send__(#{internal_name.inspect}, *args)
205
- __invoke_decorations(:after, action, args, options)
204
+ __invoke_decorations(:after, action, args, args.last)
206
205
  return rval
207
206
  end
208
207
  WRAPPER
@@ -227,8 +226,9 @@ WRAPPER
227
226
  end
228
227
  end
229
228
 
229
+ @options << option.name
230
+
230
231
  option.aliases.each do |name|
231
- @options << name
232
232
  @options_hash[name] = option
233
233
  end
234
234
 
@@ -251,27 +251,61 @@ WRAPPER
251
251
  option
252
252
  end
253
253
 
254
- def validate_args(args)
255
- # Check for multiple aliases for the same option...
256
- args.last.keys.each do |name|
257
- # #7290: If this isn't actually an option, ignore it for now. We should
258
- # probably fail, but that wasn't our API, and I don't want to perturb
259
- # behaviour this late in the RC cycle. --daniel 2011-04-29
254
+ def validate_and_clean(original)
255
+ # The final set of arguments; effectively a hand-rolled shallow copy of
256
+ # the original, which protects the caller from the surprises they might
257
+ # get if they passed us a hash and we mutated it...
258
+ result = {}
259
+
260
+ # Check for multiple aliases for the same option, and canonicalize the
261
+ # name of the argument while we are about it.
262
+ overlap = Hash.new do |h, k| h[k] = [] end
263
+ unknown = []
264
+ original.keys.each do |name|
260
265
  if option = get_option(name) then
261
- overlap = (option.aliases & args.last.keys)
262
- unless overlap.length == 1 then
263
- raise ArgumentError, "Multiple aliases for the same option passed: #{overlap.join(', ')}"
266
+ canonical = option.name
267
+ if result.has_key? canonical
268
+ overlap[canonical] << name
269
+ else
270
+ result[canonical] = original[name]
264
271
  end
272
+ elsif Puppet.settings.include? name
273
+ result[name] = original[name]
274
+ else
275
+ unknown << name
276
+ end
277
+ end
278
+
279
+ unless overlap.empty?
280
+ msg = overlap.map {|k, v| "(#{k}, #{v.sort.join(', ')})" }.join(", ")
281
+ raise ArgumentError, "Multiple aliases for the same option passed: #{msg}"
282
+ end
283
+
284
+ unless unknown.empty?
285
+ msg = unknown.sort.join(", ")
286
+ raise ArgumentError, "Unknown options passed: #{msg}"
287
+ end
288
+
289
+ # Inject default arguments and check for missing mandating options.
290
+ missing = []
291
+ options.map {|x| get_option(x) }.each do |option|
292
+ name = option.name
293
+ next if result.has_key? name
294
+
295
+ if option.has_default?
296
+ result[name] = option.default
297
+ elsif option.required?
298
+ missing << name
265
299
  end
266
300
  end
267
301
 
268
- # Check for missing mandatory options.
269
- required = options.map do |name|
270
- get_option(name)
271
- end.select(&:required?).collect(&:name) - args.last.keys
302
+ unless missing.empty?
303
+ msg = missing.sort.join(', ')
304
+ raise ArgumentError, "The following options are required: #{msg}"
305
+ end
272
306
 
273
- return if required.empty?
274
- raise ArgumentError, "The following options are required: #{required.join(', ')}"
307
+ # All done.
308
+ return result
275
309
  end
276
310
 
277
311
  ########################################################################
@@ -7,13 +7,14 @@ module Puppet::Interface::ActionManager
7
7
  require 'puppet/interface/action_builder'
8
8
 
9
9
  @actions ||= {}
10
- @default_action ||= nil
11
10
  raise "Action #{name} already defined for #{self}" if action?(name)
11
+
12
12
  action = Puppet::Interface::ActionBuilder.build(self, name, &block)
13
- if action.default
14
- raise "Actions #{@default_action.name} and #{name} cannot both be default" if @default_action
15
- @default_action = action
13
+
14
+ if action.default and current = get_default_action
15
+ raise "Actions #{current.name} and #{name} cannot both be default"
16
16
  end
17
+
17
18
  @actions[action.name] = action
18
19
  end
19
20
 
@@ -61,7 +62,11 @@ module Puppet::Interface::ActionManager
61
62
  end
62
63
 
63
64
  def get_default_action
64
- @default_action
65
+ default = actions.map {|x| get_action(x) }.select {|x| x.default }
66
+ if default.length > 1
67
+ raise "The actions #{default.map(&:name).join(", ")} cannot all be default"
68
+ end
69
+ default.first
65
70
  end
66
71
 
67
72
  def action?(name)
@@ -1,8 +1,6 @@
1
1
  require 'puppet/interface'
2
2
 
3
3
  module Puppet::Interface::FaceCollection
4
- SEMVER_VERSION = /^(\d+)\.(\d+)\.(\d+)([A-Za-z][0-9A-Za-z-]*|)$/
5
-
6
4
  @faces = Hash.new { |hash, key| hash[key] = {} }
7
5
 
8
6
  def self.faces
@@ -17,55 +15,36 @@ module Puppet::Interface::FaceCollection
17
15
  @faces.keys.select {|name| @faces[name].length > 0 }
18
16
  end
19
17
 
20
- def self.validate_version(version)
21
- !!(SEMVER_VERSION =~ version.to_s)
22
- end
23
-
24
- def self.semver_to_array(v)
25
- parts = SEMVER_VERSION.match(v).to_a[1..4]
26
- parts[0..2] = parts[0..2].map { |e| e.to_i }
27
- parts
28
- end
29
-
30
- def self.cmp_semver(a, b)
31
- a, b = [a, b].map do |x| semver_to_array(x) end
32
-
33
- cmp = a[0..2] <=> b[0..2]
34
- if cmp == 0
35
- cmp = a[3] <=> b[3]
36
- cmp = +1 if a[3].empty? && !b[3].empty?
37
- cmp = -1 if b[3].empty? && !a[3].empty?
38
- end
39
- cmp
18
+ def self.[](name, version)
19
+ name = underscorize(name)
20
+ get_face(name, version) or load_face(name, version)
40
21
  end
41
22
 
42
- def self.prefix_match?(desired, target)
43
- # Can't meaningfully do a prefix match with current on either side.
44
- return false if desired == :current
45
- return false if target == :current
46
-
47
- # REVISIT: Should probably fail if the matcher is not valid.
48
- prefix = desired.split('.').map {|x| x =~ /^\d+$/ and x.to_i }
49
- have = semver_to_array(target)
23
+ def self.get_action_for_face(name, action_name, version)
24
+ name = underscorize(name)
50
25
 
51
- while want = prefix.shift do
52
- return false unless want == have.shift
26
+ # If the version they request specifically doesn't exist, don't search
27
+ # elsewhere. Usually this will start from :current and all...
28
+ return nil unless face = self[name, version]
29
+ unless action = face.get_action(action_name)
30
+ # ...we need to search for it bound to an o{lder,ther} version. Since
31
+ # we load all actions when the face is first references, this will be in
32
+ # memory in the known set of versions of the face.
33
+ (@faces[name].keys - [ :current ]).sort.reverse.each do |version|
34
+ break if action = @faces[name][version].get_action(action_name)
35
+ end
53
36
  end
54
- return true
55
- end
56
37
 
57
- def self.[](name, version)
58
- name = underscorize(name)
59
- get_face(name, version) or load_face(name, version)
38
+ return action
60
39
  end
61
40
 
62
41
  # get face from memory, without loading.
63
- def self.get_face(name, desired_version)
42
+ def self.get_face(name, pattern)
64
43
  return nil unless @faces.has_key? name
44
+ return @faces[name][:current] if pattern == :current
65
45
 
66
- return @faces[name][:current] if desired_version == :current
67
-
68
- found = @faces[name].keys.select {|v| prefix_match?(desired_version, v) }.sort.last
46
+ versions = @faces[name].keys - [ :current ]
47
+ found = SemVer.find_matching(pattern, versions)
69
48
  return @faces[name][found]
70
49
  end
71
50
 
@@ -77,9 +56,7 @@ module Puppet::Interface::FaceCollection
77
56
  #
78
57
  # We use require to avoid executing the code multiple times, like any
79
58
  # other Ruby library that we might want to use. --daniel 2011-04-06
80
- begin
81
- require "puppet/face/#{name}"
82
-
59
+ if safely_require name then
83
60
  # If we wanted :current, we need to index to find that; direct version
84
61
  # requests just work™ as they go. --daniel 2011-04-06
85
62
  if version == :current then
@@ -108,21 +85,35 @@ module Puppet::Interface::FaceCollection
108
85
  # versions here and return the last item in that set.
109
86
  #
110
87
  # --daniel 2011-04-06
111
- latest_ver = @faces[name].keys.sort {|a, b| cmp_semver(a, b) }.last
88
+ latest_ver = @faces[name].keys.sort.last
112
89
  @faces[name][:current] = @faces[name][latest_ver]
113
90
  end
114
- rescue LoadError => e
115
- raise unless e.message =~ %r{-- puppet/face/#{name}$}
116
- # ...guess we didn't find the file; return a much better problem.
117
- rescue SyntaxError => e
118
- raise unless e.message =~ %r{puppet/face/#{name}\.rb:\d+: }
119
- Puppet.err "Failed to load face #{name}:\n#{e}"
120
- # ...but we just carry on after complaining.
91
+ end
92
+
93
+ unless version == :current or get_face(name, version)
94
+ # Try an obsolete version of the face, if needed, to see if that helps?
95
+ safely_require name, version
121
96
  end
122
97
 
123
98
  return get_face(name, version)
124
99
  end
125
100
 
101
+ def self.safely_require(name, version = nil)
102
+ path = File.join 'puppet' ,'face', version.to_s, name.to_s
103
+ require path
104
+ true
105
+
106
+ rescue LoadError => e
107
+ raise unless e.message =~ %r{-- #{path}$}
108
+ # ...guess we didn't find the file; return a much better problem.
109
+ nil
110
+ rescue SyntaxError => e
111
+ raise unless e.message =~ %r{#{path}\.rb:\d+: }
112
+ Puppet.err "Failed to load face #{name}:\n#{e}"
113
+ # ...but we just carry on after complaining.
114
+ nil
115
+ end
116
+
126
117
  def self.register(face)
127
118
  @faces[underscorize(face.name)][face.version] = face
128
119
  end
@@ -6,6 +6,7 @@ class Puppet::Interface::Option
6
6
  def initialize(parent, *declaration, &block)
7
7
  @parent = parent
8
8
  @optparse = []
9
+ @default = nil
9
10
 
10
11
  # Collect and sort the arguments in the declaration.
11
12
  dups = {}
@@ -81,8 +82,26 @@ class Puppet::Interface::Option
81
82
  !!@required
82
83
  end
83
84
 
85
+ def has_default?
86
+ !!@default
87
+ end
88
+
89
+ def default=(proc)
90
+ required and raise ArgumentError, "#{self} can't be optional and have a default value"
91
+ proc.is_a? Proc or raise ArgumentError, "default value for #{self} is a #{proc.class.name.inspect}, not a proc"
92
+ @default = proc
93
+ end
94
+
95
+ def default
96
+ @default and @default.call
97
+ end
98
+
84
99
  attr_reader :parent, :name, :aliases, :optparse
85
100
  attr_accessor :required
101
+ def required=(value)
102
+ has_default? and raise ArgumentError, "#{self} can't be optional and have a default value"
103
+ @required = value
104
+ end
86
105
 
87
106
  attr_accessor :before_action
88
107
  def before_action=(proc)
@@ -51,4 +51,17 @@ class Puppet::Interface::OptionBuilder
51
51
  def required(value = true)
52
52
  @option.required = value
53
53
  end
54
+
55
+ def default_to(&block)
56
+ block or raise ArgumentError, "#{@option} default_to requires a block"
57
+ if @option.has_default?
58
+ raise ArgumentError, "#{@option} already has a default value"
59
+ end
60
+ # Ruby 1.8 treats a block without arguments as accepting any number; 1.9
61
+ # gets this right, so we work around it for now... --daniel 2011-07-20
62
+ unless block.arity == 0 or (RUBY_VERSION =~ /^1\.8/ and block.arity == -1)
63
+ raise ArgumentError, "#{@option} default_to block should not take any arguments"
64
+ end
65
+ @option.default = block
66
+ end
54
67
  end
@@ -26,8 +26,9 @@ module Puppet::Interface::OptionManager
26
26
  end
27
27
  end
28
28
 
29
+ @options << option.name
30
+
29
31
  option.aliases.each do |name|
30
- @options << name
31
32
  @options_hash[name] = option
32
33
  end
33
34
 
@@ -61,10 +61,9 @@ module Manager
61
61
 
62
62
  # Then create the class.
63
63
 
64
- klass = genclass(
65
- name,
64
+ klass = genclass(
65
+ name,
66
66
  :parent => (parent || Puppet::Type),
67
-
68
67
  :overwrite => true,
69
68
  :hash => @types,
70
69
  :attributes => options,
@@ -87,14 +86,11 @@ module Manager
87
86
 
88
87
  # Now set up autoload any providers that might exist for this type.
89
88
 
90
- klass.providerloader = Puppet::Util::Autoload.new(
91
- klass,
92
-
93
- "puppet/provider/#{klass.name.to_s}"
94
- )
89
+ klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name.to_s}")
95
90
 
96
- # We have to load everything so that we can figure out the default type.
91
+ # We have to load everything so that we can figure out the default provider.
97
92
  klass.providerloader.loadall
93
+ klass.providify unless klass.providers.empty?
98
94
 
99
95
  klass
100
96
  end
@@ -103,11 +99,7 @@ module Manager
103
99
  def rmtype(name)
104
100
  # Then create the class.
105
101
 
106
- klass = rmclass(
107
- name,
108
-
109
- :hash => @types
110
- )
102
+ klass = rmclass(name, :hash => @types)
111
103
 
112
104
  singleton_class.send(:remove_method, "new#{name}") if respond_to?("new#{name}")
113
105
  end
@@ -132,12 +124,7 @@ module Manager
132
124
  # Create a loader for Puppet types.
133
125
  def typeloader
134
126
  unless defined?(@typeloader)
135
-
136
- @typeloader = Puppet::Util::Autoload.new(
137
- self,
138
-
139
- "puppet/type", :wrap => false
140
- )
127
+ @typeloader = Puppet::Util::Autoload.new(self, "puppet/type", :wrap => false)
141
128
  end
142
129
 
143
130
  @typeloader
@@ -42,7 +42,10 @@ class Puppet::Module
42
42
  def has_metadata?
43
43
  return false unless metadata_file
44
44
 
45
- FileTest.exist?(metadata_file)
45
+ return false unless FileTest.exist?(metadata_file)
46
+
47
+ metadata = PSON.parse File.read(metadata_file)
48
+ return metadata.is_a?(Hash) && !metadata.keys.empty?
46
49
  end
47
50
 
48
51
  def initialize(name, environment = nil)
@@ -102,7 +102,7 @@ module Puppet
102
102
  name = $3 if $2 == "path"
103
103
  name.chomp!
104
104
  right = newrights.newright(name, count, @file)
105
- when /^\s*(allow|deny|method|environment|auth(?:enticated)?)\s+(.+)$/
105
+ when /^\s*(allow|deny|method|environment|auth(?:enticated)?)\s+(.+?)(\s*#.*)?$/
106
106
  parse_right_directive(right, $1, $2, count)
107
107
  else
108
108
  raise ConfigurationError, "Invalid line #{count}: #{line}"
@@ -130,6 +130,7 @@ module Puppet
130
130
  end
131
131
 
132
132
  def parse_right_directive(right, var, value, count)
133
+ value.strip!
133
134
  case var
134
135
  when "allow"
135
136
  modify_right(right, :allow, value, "allowing %s access", count)
@@ -159,6 +160,7 @@ module Puppet
159
160
  def modify_right(right, method, value, msg, count)
160
161
  value.split(/\s*,\s*/).each do |val|
161
162
  begin
163
+ val.strip!
162
164
  right.info msg % val
163
165
  right.send(method, val)
164
166
  rescue AuthStoreError => detail
@@ -182,9 +182,11 @@ module Puppet
182
182
  # we'll return a pattern of puppet.reductivelabs.com
183
183
  def interpolate(match)
184
184
  clone = dup
185
- clone.pattern = clone.pattern.reverse.collect do |p|
186
- p.gsub(/\$(\d)/) { |m| match[$1.to_i] }
187
- end.join(".")
185
+ if @name == :dynamic
186
+ clone.pattern = clone.pattern.reverse.collect do |p|
187
+ p.gsub(/\$(\d)/) { |m| match[$1.to_i] }
188
+ end.join(".")
189
+ end
188
190
  clone
189
191
  end
190
192
 
@@ -199,8 +201,13 @@ module Puppet
199
201
 
200
202
  # Does the name match our pattern?
201
203
  def matchname?(name)
202
- name = munge_name(name)
203
- (pattern == name) or (not exact? and pattern.zip(name).all? { |p,n| p == n })
204
+ case @name
205
+ when :domain, :dynamic, :opaque
206
+ name = munge_name(name)
207
+ (pattern == name) or (not exact? and pattern.zip(name).all? { |p,n| p == n })
208
+ when :regex
209
+ Regexp.new(pattern.slice(1..-2)).match(name)
210
+ end
204
211
  end
205
212
 
206
213
  # Convert the name to a common pattern.
@@ -240,6 +247,8 @@ module Puppet
240
247
  [:dynamic,:exact,nil,munge_name(value)]
241
248
  when /^\w[-.@\w]*$/ # ? Just like a host name but allow '@'s and ending '.'s
242
249
  [:opaque,:exact,nil,[value]]
250
+ when /^\/.*\/$/ # a regular expression
251
+ [:regex,:inexact,nil,value]
243
252
  else
244
253
  raise AuthStoreError, "Invalid pattern #{value}"
245
254
  end