puppet-retrospec 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -0
  3. data/CHANGELOG.md +11 -0
  4. data/DEVELOPMENT.md +3 -0
  5. data/Gemfile +10 -9
  6. data/Gemfile.lock +2 -0
  7. data/README.md +211 -273
  8. data/Rakefile +8 -8
  9. data/VERSION +1 -1
  10. data/lib/retrospec-puppet.rb +3 -3
  11. data/lib/retrospec/plugins/v1/plugin/conditional.rb +5 -6
  12. data/lib/retrospec/plugins/v1/plugin/exceptions.rb +17 -0
  13. data/lib/retrospec/plugins/v1/plugin/generators.rb +7 -0
  14. data/lib/retrospec/plugins/v1/plugin/generators/fact_generator.rb +18 -10
  15. data/lib/retrospec/plugins/v1/plugin/generators/function_generator.rb +187 -0
  16. data/lib/retrospec/plugins/v1/plugin/generators/module_generator.rb +25 -26
  17. data/lib/retrospec/plugins/v1/plugin/generators/{facter.rb → parsers/facter.rb} +28 -35
  18. data/lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb +91 -0
  19. data/lib/retrospec/plugins/v1/plugin/generators/parsers/type.rb +79 -0
  20. data/lib/retrospec/plugins/v1/plugin/generators/provider_generator.rb +107 -0
  21. data/lib/retrospec/plugins/v1/plugin/generators/schema_generator.rb +221 -0
  22. data/lib/retrospec/plugins/v1/plugin/generators/type_generator.rb +118 -0
  23. data/lib/retrospec/plugins/v1/plugin/helpers.rb +3 -7
  24. data/lib/retrospec/plugins/v1/plugin/puppet.rb +141 -60
  25. data/lib/retrospec/plugins/v1/plugin/puppet_module.rb +29 -26
  26. data/lib/retrospec/plugins/v1/plugin/resource.rb +6 -7
  27. data/lib/retrospec/plugins/v1/plugin/spec_object.rb +5 -8
  28. data/lib/retrospec/plugins/v1/plugin/template_helpers.rb +9 -10
  29. data/lib/retrospec/plugins/v1/plugin/templates/clone-hook +15 -8
  30. data/lib/retrospec/plugins/v1/plugin/type_code.rb +4 -4
  31. data/lib/retrospec/plugins/v1/plugin/variable_store.rb +26 -30
  32. data/lib/retrospec/plugins/v1/plugin/version.rb +1 -1
  33. data/puppet-retrospec.gemspec +43 -4
  34. data/spec/fixtures/facts/oracle_controls.rb +38 -0
  35. data/spec/fixtures/fixture_modules/required_parameters/manifests/init.pp +8 -0
  36. data/spec/fixtures/fixture_modules/sample_module/lib/facter/fix_installed.rb +11 -0
  37. data/spec/fixtures/fixture_modules/sample_module/lib/puppet/functions/awesome_parser.rb +13 -0
  38. data/spec/fixtures/fixture_modules/sample_module/lib/puppet/functions/reduce.rb +31 -0
  39. data/spec/fixtures/fixture_modules/sample_module/lib/puppet/parser/functions/bad_sha1.rb +6 -0
  40. data/spec/fixtures/fixture_modules/sample_module/lib/puppet/parser/functions/defined.rb +94 -0
  41. data/spec/fixtures/fixture_modules/sample_module/lib/puppet/parser/functions/sha1.rb +6 -0
  42. data/spec/fixtures/fixture_modules/sample_module/spec/unit/facter/fix_installed_spec.rb +21 -0
  43. data/spec/fixtures/modules/tomcat/files/.gitkeep +0 -0
  44. data/spec/fixtures/modules/tomcat/templates/.gitkeep +0 -0
  45. data/spec/fixtures/modules/tomcat/tests/.gitkeep +0 -0
  46. data/spec/fixtures/providers/bmc/ipmitool.rb +188 -0
  47. data/spec/fixtures/providers/bmcuser/ipmitool.rb +140 -0
  48. data/spec/fixtures/types/bmc.rb +102 -0
  49. data/spec/fixtures/types/bmcuser.rb +46 -0
  50. data/spec/fixtures/types/db_opatch.rb +93 -0
  51. data/spec/integration/retrospec_spec.rb +1 -3
  52. data/spec/spec_helper.rb +33 -6
  53. data/spec/unit/conditional_spec.rb +12 -15
  54. data/spec/unit/generators/fact_generater_spec.rb +49 -17
  55. data/spec/unit/generators/function_generator_spec.rb +301 -0
  56. data/spec/unit/generators/function_spec.rb +67 -0
  57. data/spec/unit/generators/parsers/fact_spec.rb +62 -0
  58. data/spec/unit/generators/parsers/provider_spec.rb +44 -0
  59. data/spec/unit/generators/parsers/type_spec.rb +93 -0
  60. data/spec/unit/generators/provider_generator_spec.rb +120 -0
  61. data/spec/unit/generators/schema_generator_spec.rb +122 -0
  62. data/spec/unit/generators/type_generator_spec.rb +173 -0
  63. data/spec/unit/module_spec.rb +7 -10
  64. data/spec/unit/plugin_spec.rb +213 -15
  65. data/spec/unit/puppet-retrospec_spec.rb +81 -100
  66. data/spec/unit/resource_spec.rb +16 -17
  67. data/spec/unit/spec_object_spec.rb +46 -0
  68. data/spec/unit/type_code_spec.rb +9 -11
  69. data/spec/unit/variable_store_spec.rb +41 -43
  70. metadata +54 -4
  71. data/spec/unit/generators/fact_spec.rb +0 -58
@@ -1,5 +1,7 @@
1
1
  require 'singleton'
2
2
  require 'puppet/face'
3
+ require_relative 'exceptions'
4
+
3
5
  module Utilities
4
6
  class PuppetModule
5
7
  attr_writer :module_path
@@ -33,17 +35,13 @@ module Utilities
33
35
 
34
36
  # create the temporary module create, validate the
35
37
  def self.create_tmp_module_path
36
- Utilities::PuppetModule::instance.create_tmp_module_path(module_path)
38
+ Utilities::PuppetModule.instance.create_tmp_module_path(module_path)
37
39
  end
38
40
 
39
41
  def self.clean_tmp_modules_dir
40
- FileUtils.remove_entry_secure instance.tmp_modules_dir # ensure we remove the temporary directory
41
- end
42
-
43
- def module_path
44
- @module_path
42
+ FileUtils.remove_entry_secure instance.tmp_modules_dir # ensure we remove the temporary directory
45
43
  end
46
-
44
+ attr_reader :module_path
47
45
  # validate and set the module path
48
46
  def module_path=(path)
49
47
  @module_path = validate_module_dir(path)
@@ -62,14 +60,14 @@ module Utilities
62
60
  if dir.nil?
63
61
  dir = '.'
64
62
  elsif dir.instance_of?(Array)
65
- puts "Retrospec - an array of module paths is not supported at this time".fatal
66
- exit 1
63
+ puts 'Retrospec - an array of module paths is not supported at this time'.fatal
64
+ raise Retrospec::Puppet::InvalidModulePathError
67
65
  end
68
66
  dir = File.expand_path(dir)
69
- manifest_dir = File.join(dir,'manifests')
70
- if ! File.exist?(manifest_dir)
67
+ manifest_dir = File.join(dir, 'manifests')
68
+ if !File.exist?(manifest_dir)
71
69
  puts "No manifest directory in #{manifest_dir}, cannot validate this is a module".fatal
72
- exit 1
70
+ raise Retrospec::Puppet::NoManifestDirError
73
71
  else
74
72
  files = Dir.glob("#{manifest_dir}/**/*.pp")
75
73
  warn "No puppet manifest files found at #{manifest_dir}".warning if files.length < 1
@@ -80,7 +78,7 @@ module Utilities
80
78
  Puppet::Face[:parser, :current].validate(file)
81
79
  rescue SystemExit => e
82
80
  puts "Manifest file: #{file} has parser errors, please fix and re-check using\n puppet parser validate #{file}".fatal
83
- exit 1
81
+ raise Retrospec::Puppet::ParserError
84
82
  end
85
83
  end
86
84
  # switch back to current parser, since we rely on the AST parser
@@ -93,9 +91,9 @@ module Utilities
93
91
 
94
92
  # puts a symlink in that module directory that points back to the user supplied module path
95
93
  def create_tmp_module_path(module_path)
96
- raise "ModulePathNotFound" unless module_path
94
+ fail 'ModulePathNotFound' unless module_path
97
95
  path = File.join(tmp_modules_dir, module_dir_name)
98
- unless File.exists?(path) # only create if it doesn't already exist
96
+ unless File.exist?(path) # only create if it doesn't already exist
99
97
  # create a link where source is the current repo and dest is /tmp/modules/module_name
100
98
  FileUtils.ln_s(module_path, path)
101
99
  end
@@ -109,26 +107,32 @@ module Utilities
109
107
  # the directory name of the module
110
108
  # usually this is the same as the module name but it can be namespaced sometimes
111
109
  def module_dir_name
112
- raise "ModulePathNotFound" unless module_path
110
+ fail 'ModulePathNotFound' unless module_path
113
111
  @module_dir_name ||= File.basename(module_path)
114
112
  end
115
113
 
114
+ def module_dir_name=(name)
115
+ @module_dir_name = name
116
+ end
117
+
116
118
  def module_type_names
117
- types.map {|x| x.name}
119
+ types.map(&:name)
120
+ end
121
+
122
+ def module_name=(name)
123
+ @module_name = name
118
124
  end
119
125
 
120
126
  # returns the name of the module ie. mysql::config => mysql
121
127
  def module_name
122
- begin
123
- @module_name ||= types.first.name.split('::').first
124
- rescue
125
- @module_name = module_dir_name
126
- end
128
+ @module_name ||= types.first.name.split('::').first
129
+ rescue
130
+ @module_name ||= module_dir_name
127
131
  end
128
132
 
129
133
  # creates a tmp module directory so puppet can work correctly
130
134
  def tmp_modules_dir
131
- if @tmp_modules_dir.nil? or not File.exists?(@tmp_modules_dir)
135
+ if @tmp_modules_dir.nil? || !File.exist?(@tmp_modules_dir)
132
136
  dir = Dir.mktmpdir
133
137
  tmp_path = File.expand_path(File.join(dir, 'modules'))
134
138
  FileUtils.mkdir_p(tmp_path)
@@ -137,7 +141,6 @@ module Utilities
137
141
  @tmp_modules_dir
138
142
  end
139
143
 
140
-
141
144
  # creates a puppet environment given a module path and environment name
142
145
  def puppet_environment
143
146
  @puppet_environment ||= Puppet::Node::Environment.create('production', [tmp_modules_dir])
@@ -164,12 +167,12 @@ module Utilities
164
167
  end
165
168
 
166
169
  # returns the resource types found in the module
167
- def search_module(pattern='*')
170
+ def search_module(pattern = '*')
168
171
  request = request(pattern, 'search')
169
172
  resource_type_parser.search(request)
170
173
  end
171
174
 
172
- # TODO we need to parse the types and find all the types that inherit other types and then order them so we can load the files first
175
+ # TODO: we need to parse the types and find all the types that inherit other types and then order them so we can load the files first
173
176
  def types
174
177
  @types ||= search_module || []
175
178
  end
@@ -1,14 +1,13 @@
1
1
  require_relative 'variable_store'
2
2
 
3
3
  class Resource
4
-
5
4
  attr_reader :type, :title, :parameters, :scope_name
6
5
 
7
- def initialize(type_name,instance)
6
+ def initialize(type_name, instance)
8
7
  # we don't store the resource parameters in the variablestore because they are never referenced
9
- @parameters = Hash[instance.parameters.map { |k| [k.param, VariableStore.resolve(k.value).gsub("\"", '')]}]
8
+ @parameters = Hash[instance.parameters.map { |k| [k.param, VariableStore.resolve(k.value).delete("\"")] }]
10
9
  @type = type_name
11
- @title = VariableStore.resolve(instance.title).gsub("\"", '')
10
+ @title = VariableStore.resolve(instance.title).delete("\"")
12
11
  end
13
12
 
14
13
  # Gets all resources in the type that are not in a code block
@@ -20,7 +19,7 @@ class Resource
20
19
  a = []
21
20
  # sometimes the code is empty
22
21
  if statements.respond_to?(:find_all)
23
- res = statements.find_all { |s| s.instance_of?(Puppet::Parser::AST::Resource)}
22
+ res = statements.find_all { |s| s.instance_of?(Puppet::Parser::AST::Resource) }
24
23
  res.each do |r|
25
24
  r.instances.each do |i|
26
25
  a << Resource.new(r.type, i)
@@ -31,6 +30,6 @@ class Resource
31
30
  end
32
31
 
33
32
  def self.all_resources
34
- ObjectSpace.each_object(Puppet::Parser::AST::Resource).map {|x| x}
33
+ ObjectSpace.each_object(Puppet::Parser::AST::Resource).map { |x| x }
35
34
  end
36
- end
35
+ end
@@ -4,11 +4,9 @@ module Retrospec
4
4
  # this object is passed to the templates for erb template rendering
5
5
  # you can use data contained in this object in your templates
6
6
  class SpecObject < Retrospec::Plugins::V1::ContextObject
7
-
8
7
  attr_reader :instance, :module_path, :module_name, :all_hiera_data, :config
9
8
  attr_accessor :enable_beaker_tests, :parameters, :types, :resources, :type
10
9
 
11
-
12
10
  def initialize(mod_path, instance_data, config_data)
13
11
  @instance = instance_data
14
12
  @config = config_data
@@ -27,9 +25,9 @@ module Retrospec
27
25
  def class_hiera_data(classname)
28
26
  data = {}
29
27
  types.each do |t|
30
- next unless t.type == :hostclass #defines don't have hiera lookup values
28
+ next unless t.type == :hostclass # defines don't have hiera lookup values
31
29
  next unless t.name == classname
32
- t.arguments.each do |k, v|
30
+ t.arguments.each do |k, _v|
33
31
  key = "#{t.name}::#{k}"
34
32
  data[key] = nil
35
33
  end
@@ -42,8 +40,8 @@ module Retrospec
42
40
  if @all_hiera_data.nil?
43
41
  @all_hiera_data = {}
44
42
  types.each do |t|
45
- next unless t.type == :hostclass #defines don't have hiera lookup values
46
- t.arguments.each do |k, v|
43
+ next unless t.type == :hostclass # defines don't have hiera lookup values
44
+ t.arguments.each do |k, _v|
47
45
  key = "#{t.name}::#{k}"
48
46
  @all_hiera_data[key] = nil
49
47
  end
@@ -64,7 +62,6 @@ module Retrospec
64
62
  def fact_name
65
63
  instance[:name]
66
64
  end
67
-
68
65
  end
69
66
  end
70
- end
67
+ end
@@ -4,12 +4,12 @@ module Retrospec
4
4
  module TemplateHelpers
5
5
  # creates the user supplied or default template directory
6
6
  # returns: user_template_dir
7
- def create_user_template_dir(user_template_directory=nil)
7
+ def create_user_template_dir(user_template_directory = nil)
8
8
  if user_template_directory.nil?
9
9
  user_template_directory = default_user_template_dir
10
10
  end
11
11
  # create default user template path or supplied user template path
12
- if not File.exists?(user_template_directory)
12
+ unless File.exist?(user_template_directory)
13
13
  FileUtils.mkdir_p(File.expand_path(user_template_directory))
14
14
  end
15
15
  user_template_directory
@@ -27,7 +27,7 @@ module Retrospec
27
27
 
28
28
  # creates and syncs the specifed user template diretory
29
29
  # returns: user_template_dir
30
- def setup_user_template_dir(user_template_directory=nil, git_url=nil, branch=nil)
30
+ def setup_user_template_dir(user_template_directory = nil, git_url = nil, branch = nil)
31
31
  if user_template_directory.nil?
32
32
  user_template_directory = default_user_template_dir
33
33
  end
@@ -37,7 +37,7 @@ module Retrospec
37
37
  end
38
38
 
39
39
  def default_user_template_dir
40
- File.expand_path(File.join(ENV['HOME'], '.retrospec','repos', 'retrospec-puppet-templates' ))
40
+ File.expand_path(File.join(ENV['HOME'], '.retrospec', 'repos', 'retrospec-puppet-templates'))
41
41
  end
42
42
 
43
43
  def gem_template_dir
@@ -49,15 +49,15 @@ module Retrospec
49
49
  # from an external repo. Because templates are updated frequently
50
50
  # and users will sometimes have client specific templates I wanted to
51
51
  # externalize them for easier management.
52
- def run_clone_hook(template_dir, git_url=nil, branch=nil)
53
- if File.exists?(File.join(template_dir,'clone-hook'))
54
- hook_file = File.join(template_dir,'clone-hook')
52
+ def run_clone_hook(template_dir, git_url = nil, branch = nil)
53
+ if File.exist?(File.join(template_dir, 'clone-hook'))
54
+ hook_file = File.join(template_dir, 'clone-hook')
55
55
  else
56
56
  hook_file = File.join(gem_template_dir, 'clone-hook')
57
57
  end
58
- if File.exists?(hook_file)
58
+ if File.exist?(hook_file)
59
59
  output = `#{hook_file} #{template_dir} #{git_url} #{branch}`
60
- if $?.success?
60
+ if $CHILD_STATUS.success?
61
61
  puts "Successfully ran hook: #{hook_file}".info
62
62
  puts output.info
63
63
  else
@@ -69,4 +69,3 @@ module Retrospec
69
69
  end
70
70
  end
71
71
  end
72
-
@@ -2,7 +2,12 @@
2
2
  require 'fileutils'
3
3
  require 'open-uri'
4
4
 
5
- @template_dir = ARGV[0] || File.join(ENV['HOME'], '.retrospec','repos','retrospec-puppet-templates')
5
+ # this hook is only called once until the template directory is clone
6
+ # once the template directory is cloned the, the clone hook from the template directory
7
+ # will be run instead of this file. This is on purpose in order to allow the user
8
+ # to easily to customize the hook.
9
+
10
+ @template_dir = ARGV[0] || File.join(ENV['HOME'], '.retrospec', 'repos', 'retrospec-puppet-templates')
6
11
  @template_repo = ARGV[1] || 'https://github.com/nwops/retrospec-templates'
7
12
  @template_branch = ARGV[2] || 'master'
8
13
 
@@ -14,26 +19,28 @@ def create_repo(template_dir, git_url, branch)
14
19
  end
15
20
 
16
21
  def git_exists?(template_dir)
17
- File.exists? File.join(template_dir,'.git','config')
22
+ File.exist? File.join(template_dir, '.git', 'config')
18
23
  end
19
24
 
20
25
  def origin_exists?(template_dir)
21
26
  `git -C #{template_dir} remote show origin`
22
- $?.success?
27
+ $CHILD_STATUS.success?
23
28
  end
24
29
 
25
- def update_templates(git_url, dest, branch='master')
30
+ def update_templates(git_url, dest, branch = 'master')
26
31
  create_repo(dest, git_url, branch)
27
32
  puts `git -C #{dest} pull`
28
33
  dest
29
34
  end
30
35
 
31
36
  def connected?
32
- open("http://www.google.com/") rescue false
37
+ unless ENV['CLONE_RETROSPEC_TEMPLATES'].nil?
38
+ # if the user wants internet but doesn't want cloning, allow them to set this variable
39
+ return false
40
+ end
41
+ open('http://www.google.com/') rescue false
33
42
  end
34
43
 
35
44
  # sometimes I work on an airplane and don't care to clone everything all the time
36
45
  # so lets check for connectivity first
37
- if connected?
38
- update_templates(@template_repo, @template_dir, @template_branch)
39
- end
46
+ update_templates(@template_repo, @template_dir, @template_branch) if connected?
@@ -5,9 +5,9 @@ require 'retrospec/exceptions'
5
5
  class TypeCode
6
6
  attr_reader :type, :variables, :scope_name, :parent, :name
7
7
 
8
- #TODO figure out how to store vardef statements that are contained inside conditional blocks
8
+ # TODO: figure out how to store vardef statements that are contained inside conditional blocks
9
9
  def initialize(type)
10
- raise TypeNotFoundException unless type
10
+ fail TypeNotFoundException unless type
11
11
  @scope_name = type.namespace
12
12
  @name = type.name
13
13
  @type = type
@@ -21,10 +21,10 @@ class TypeCode
21
21
  # returns a list of variables found in the main code block
22
22
  def variables
23
23
  if @type.code.respond_to?(:find_all)
24
- @variables ||= @type.code.find_all {|i| i.instance_of?(Puppet::Parser::AST::VarDef) }
24
+ @variables ||= @type.code.find_all { |i| i.instance_of?(Puppet::Parser::AST::VarDef) }
25
25
  else
26
26
  @variables = []
27
27
  end
28
28
  @variables
29
29
  end
30
- end
30
+ end
@@ -20,16 +20,14 @@ class VariableStore
20
20
 
21
21
  # key should be a variable starting with $
22
22
  # enable_value_conversion converts the value to a string
23
- def self.add(key, value, enable_value_conversion=true)
24
- if key.respond_to?(:value)
25
- key = key.value
26
- end
23
+ def self.add(key, value, enable_value_conversion = true)
24
+ key = key.value if key.respond_to?(:value)
27
25
  # the key name must always be the same and look like $key_name or $key_name::other::name
28
26
  key = "#{'$' + key.to_s}" unless key.to_s.start_with?('$')
29
- key = key.to_s.gsub('$::', '$') if key.to_s.start_with?('$::') # sometimes variables start with $::
30
- #return if instance.store[key] == value
31
- if value.instance_of?(String) or value.instance_of?(Puppet::Parser::AST::String)
32
- value = value.to_s.gsub("\"",'')
27
+ key = key.to_s.gsub('$::', '$') if key.to_s.start_with?('$::') # sometimes variables start with $::
28
+ # return if instance.store[key] == value
29
+ if value.instance_of?(String) || value.instance_of?(Puppet::Parser::AST::String)
30
+ value = value.to_s.delete("\"")
33
31
  end
34
32
  if enable_value_conversion
35
33
  instance.store[key.to_s] = value.to_s
@@ -40,22 +38,20 @@ class VariableStore
40
38
 
41
39
  # lookup the key in the hash, if we dont' find it lets just return the string representation
42
40
  def self.lookup(key)
43
- if key.respond_to?(:value)
44
- key = key.value
45
- end
46
- key = "$#{key.to_s}" unless key.to_s.start_with?('$')
47
- key = key.gsub('$::', '$') if key.to_s.start_with?('$::') # sometimes variables start with $::
48
- #puts "Looking up: #{key}"
41
+ key = key.value if key.respond_to?(:value)
42
+ key = "$#{key}" unless key.to_s.start_with?('$')
43
+ key = key.gsub('$::', '$') if key.to_s.start_with?('$::') # sometimes variables start with $::
44
+ # puts "Looking up: #{key}"
49
45
  begin
50
46
  value = VariableStore.instance.store.fetch(key.to_s)
51
47
  # try and resolve if necessary
52
- if [Puppet::Parser::AST::Variable,Puppet::Parser::AST::VarDef].include?(value.class)
48
+ if [Puppet::Parser::AST::Variable, Puppet::Parser::AST::VarDef].include?(value.class)
53
49
  value = resolve(value)
54
50
  else
55
51
  if captures = value.scan(/(\$[::]?[\w+::]*\w+)/).flatten
56
52
  # produces an array of variables that have not been resolved yet
57
53
  # ["$concat1", "$concat"] = "$concat1/test3183/$concat"
58
- captures.each { |c| value.gsub(c, resolve(c))}
54
+ captures.each { |c| value.gsub(c, resolve(c)) }
59
55
  end
60
56
  end
61
57
  rescue
@@ -69,12 +65,12 @@ class VariableStore
69
65
  res = nil
70
66
  if variable.instance_of? Puppet::Parser::AST::VarDef
71
67
  res = lookup(variable.name.value)
72
- #add(variable.name, variable.value,false) unless res.nil?
68
+ # add(variable.name, variable.value,false) unless res.nil?
73
69
  elsif variable.instance_of?(Puppet::Parser::AST::Variable)
74
70
  res = lookup(variable.value)
75
71
  elsif variable.instance_of?(Puppet::Parser::AST::Concat)
76
72
  begin
77
- res = variable.value.map { |i| variable_resolution(i)}.join.gsub("\"",'')
73
+ res = variable.value.map { |i| variable_resolution(i) }.join.delete("\"")
78
74
  rescue
79
75
  res = variable.value
80
76
  end
@@ -85,7 +81,7 @@ class VariableStore
85
81
  unless res.nil?
86
82
  if variable.instance_of?(Puppet::Parser::AST::Variable)
87
83
  unless res = lookup(variable.to_s)
88
- #add(variable.to_s, res)
84
+ # add(variable.to_s, res)
89
85
  end
90
86
  end
91
87
  end
@@ -99,8 +95,8 @@ class VariableStore
99
95
 
100
96
  # gets all the variables and parameters and passes them through the resolve function to populate the variable store
101
97
  # we use recursion to evaluate inherited manifests
102
- # TODO use the same recursion method to evaluate included manifests
103
- def self.populate(type, is_parent=false)
98
+ # TODO: use the same recursion method to evaluate included manifests
99
+ def self.populate(type, is_parent = false)
104
100
  if type.parent
105
101
  p = type.parent.gsub(/\A::/, '')
106
102
  parent = type.resource_type_collection.hostclasses[p]
@@ -110,14 +106,14 @@ class VariableStore
110
106
  if parent
111
107
  # type has a parent and we want to add the parent variables first so we call populate first
112
108
  # then we load the type's variable
113
- populate(parent,true)
109
+ populate(parent, true)
114
110
  # we load the local scope and top scope variables because we need access to both
115
111
  # there is a chance some of the local scope variables will be overwritten but by the time that happens
116
112
  # we won't need them anymore.
117
- type.arguments.each do |k,v|
113
+ type.arguments.each do |k, v|
118
114
  # store the class params
119
- add(k.to_s,resolve(v),true)
120
- add(("$#{type.namespace}::" << k.to_s),resolve(v),true)
115
+ add(k.to_s, resolve(v), true)
116
+ add(("$#{type.namespace}::" << k.to_s), resolve(v), true)
121
117
  end
122
118
  TypeCode.new(type).variables.each do |v|
123
119
  add(v.name.to_s, resolve(v.value))
@@ -125,14 +121,14 @@ class VariableStore
125
121
  end
126
122
  elsif is_parent
127
123
  # if this is the parent we load the variables
128
- type.arguments.each {|k,v| add(("$#{type.namespace}::" << k.to_s),resolve(v),true)}
129
- TypeCode.new(type).variables.each {|v| add(("$#{type.namespace}::" << v.name.to_s), resolve(v.value))}
124
+ type.arguments.each { |k, v| add(("$#{type.namespace}::" << k.to_s), resolve(v), true) }
125
+ TypeCode.new(type).variables.each { |v| add(("$#{type.namespace}::" << v.name.to_s), resolve(v.value)) }
130
126
  else
131
127
  # if the type does not have a parent we load the variables
132
- type.arguments.each do |k,v|
128
+ type.arguments.each do |k, v|
133
129
  # store the class params
134
- add(k.to_s,resolve(v),true)
135
- add(("$#{type.namespace}::" << k.to_s),resolve(v),true)
130
+ add(k.to_s, resolve(v), true)
131
+ add(("$#{type.namespace}::" << k.to_s), resolve(v), true)
136
132
  end
137
133
  TypeCode.new(type).variables.each do |v|
138
134
  add(v.name.to_s, resolve(v.value))