depengine 3.0.20 → 3.0.21

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 +8 -0
  3. data/.rubocop_todo.yml +52 -0
  4. data/Gemfile.lock +16 -1
  5. data/Rakefile +9 -9
  6. data/bin/cdb_crypt +2 -2
  7. data/bin/de +1 -1
  8. data/bin/depengine +2 -2
  9. data/bin/spec_setup +2 -2
  10. data/depengine.gemspec +22 -21
  11. data/lib/depengine/asserter/url.rb +8 -9
  12. data/lib/depengine/cli.rb +12 -14
  13. data/lib/depengine/dsl/cdb.rb +16 -17
  14. data/lib/depengine/dsl/deployment.rb +42 -50
  15. data/lib/depengine/dsl/dweb.rb +10 -11
  16. data/lib/depengine/dsl/executor.rb +5 -5
  17. data/lib/depengine/dsl/fileops.rb +3 -4
  18. data/lib/depengine/dsl/helper.rb +26 -28
  19. data/lib/depengine/dsl/iis.rb +21 -24
  20. data/lib/depengine/dsl/patch.rb +22 -46
  21. data/lib/depengine/dsl/publisher.rb +14 -14
  22. data/lib/depengine/dsl/remote.rb +11 -13
  23. data/lib/depengine/dsl/repository.rb +19 -21
  24. data/lib/depengine/dsl/template.rb +19 -19
  25. data/lib/depengine/dsl/zip.rb +24 -24
  26. data/lib/depengine/helper/cli_helper.rb +9 -11
  27. data/lib/depengine/helper/hudson.rb +15 -19
  28. data/lib/depengine/helper/mail.rb +19 -25
  29. data/lib/depengine/helper/properties.rb +33 -52
  30. data/lib/depengine/helper/smb.rb +19 -25
  31. data/lib/depengine/helper/validations.rb +7 -7
  32. data/lib/depengine/helper/yaml.rb +7 -9
  33. data/lib/depengine/log/log.rb +3 -6
  34. data/lib/depengine/processor/erb_template.rb +42 -47
  35. data/lib/depengine/processor/fileops.rb +39 -48
  36. data/lib/depengine/processor/local_execute.rb +6 -4
  37. data/lib/depengine/processor/properties.rb +34 -56
  38. data/lib/depengine/processor/sed.rb +8 -12
  39. data/lib/depengine/processor/tags.rb +9 -10
  40. data/lib/depengine/processor/template.rb +27 -32
  41. data/lib/depengine/processor/zip.rb +16 -20
  42. data/lib/depengine/provider/cdb.rb +64 -71
  43. data/lib/depengine/provider/cdb_filesystem.rb +18 -26
  44. data/lib/depengine/provider/git.rb +37 -42
  45. data/lib/depengine/provider/repository.rb +161 -176
  46. data/lib/depengine/publisher/dweb.rb +74 -90
  47. data/lib/depengine/publisher/iis.rb +23 -30
  48. data/lib/depengine/publisher/rsync.rb +14 -17
  49. data/lib/depengine/publisher/samba.rb +12 -14
  50. data/lib/depengine/publisher/sftp.rb +51 -61
  51. data/lib/depengine/publisher/ssh.rb +19 -22
  52. data/lib/depengine/publisher/tomcat.rb +19 -21
  53. data/lib/depengine/reporter/cdb.rb +2 -3
  54. data/lib/depengine/version.rb +1 -1
  55. data/lib/depengine.rb +1 -2
  56. data/spec/cdb_spec.rb +8 -10
  57. data/spec/demo_recipe/recipes/demo.rb +10 -10
  58. data/spec/deployhelper_spec.rb +20 -21
  59. data/spec/fileops_spec.rb +11 -12
  60. data/spec/git_spec.rb +8 -4
  61. data/spec/helper_spec.rb +75 -75
  62. data/spec/junit.rb +47 -49
  63. data/spec/local_execute.rb +7 -7
  64. data/spec/log_spec.rb +17 -18
  65. data/spec/properties_spec.rb +13 -15
  66. data/spec/recipe_spec.rb +15 -16
  67. data/spec/repository_spec.rb +20 -20
  68. data/spec/ssh_spec.rb +18 -19
  69. data/spec/template_spec.rb +30 -30
  70. data/spec/zip_spec.rb +7 -7
  71. metadata +18 -2
@@ -2,12 +2,12 @@ module Processor
2
2
  class Template
3
3
  include Processor
4
4
  attr_accessor :basepath, :outdir, :source, :content
5
- attr_writer :cdb
5
+ attr_writer :cdb
6
6
 
7
7
  # Render a template and write the output to a file or directory
8
8
  # structure under 'basepath'
9
- def parse_template(template_source, content, outdir, options={})
10
- Helper.validates_presence_of basepath, "Basepath not set for template engine"
9
+ def parse_template(template_source, content, outdir, options = {})
10
+ Helper.validates_presence_of basepath, 'Basepath not set for template engine'
11
11
  # expand basepath
12
12
  @basepath = File.expand_path basepath
13
13
  @outdir = outdir
@@ -20,8 +20,8 @@ module Processor
20
20
  else
21
21
  all_from_directory
22
22
  end
23
- return self
24
- end
23
+ self
24
+ end
25
25
 
26
26
  def from_file
27
27
  if excluded? @source
@@ -30,8 +30,8 @@ module Processor
30
30
  end
31
31
  target_dir = target_path_of(@source)
32
32
  create_sub_dirs!(target_dir)
33
- target_file = File.join(target_dir, File.basename(@source).gsub(".tpl",""))
34
- File.open(target_file, "w") do |f|
33
+ target_file = File.join(target_dir, File.basename(@source).gsub('.tpl', ''))
34
+ File.open(target_file, 'w') do |f|
35
35
  f.write(parse(@source))
36
36
  end
37
37
  end
@@ -48,7 +48,7 @@ module Processor
48
48
  Find.find(path_to_find_in) do |path|
49
49
  # next if we found ourself
50
50
  next if path == path_to_find_in
51
- next unless File.file?(path) and path.end_with?(".tpl")
51
+ next unless File.file?(path) and path.end_with?('.tpl')
52
52
  templates << path
53
53
  end
54
54
  templates
@@ -63,22 +63,18 @@ module Processor
63
63
  def excluded?(target)
64
64
  if @excludes
65
65
  @excludes.each do |exclude|
66
- if target.include? exclude
67
- return true
68
- end
66
+ return true if target.include? exclude
69
67
  end
70
68
  end
71
- return false
69
+ false
72
70
  end
73
71
 
74
72
  def create_sub_dirs!(target)
75
- if not File.directory?(target)
76
- FileUtils.mkdir_p(target)
77
- $log.writer.debug "Create directory #{target}"
78
- end
73
+ return if File.directory?(target)
74
+ FileUtils.mkdir_p(target)
75
+ $log.writer.debug "Create directory #{target}"
79
76
  end
80
77
 
81
-
82
78
  # This function returns the output of a parsed template, 'template' can be
83
79
  # a filename or a String.
84
80
  def self.parse(template, content)
@@ -92,39 +88,39 @@ module Processor
92
88
  def parse(template)
93
89
  context = load_tags(@content, @cdb)
94
90
  begin
95
- parser = Radius::Parser.new(context, :tag_prefix => 't')
96
- template_content = ""
97
- result = ""
91
+ parser = Radius::Parser.new(context, tag_prefix: 't')
92
+ template_content = ''
93
+ result = ''
98
94
  if File.file? template
99
95
  $log.writer.debug "template #{template} seems to be a file, reading it..."
100
- File.open(template, "rb") do |f|
101
- c = ""
102
- f.ungetc c unless (c = f.getc)=="\uFEFF" # remove BOM, if present
103
- while line = f.gets
96
+ File.open(template, 'rb') do |f|
97
+ c = '' # rubocop:disable Lint/UselessAssignment
98
+ f.ungetc c unless (c = f.getc) == "\uFEFF" # remove BOM, if present
99
+ while line = f.gets # rubocop:disable Lint/AssignmentInCondition
104
100
  template_content << line
105
101
  end
106
102
  end
107
103
  else
108
- $log.writer.debug "tempalte is not a file, using it as source"
104
+ $log.writer.debug 'tempalte is not a file, using it as source'
109
105
  template_content = template
110
106
  end
111
107
 
112
108
  result = parser.parse(template_content)
113
- nested_result_1 = ""
109
+ nested_result_1 = ''
114
110
  nested_result_2 = result
115
111
  nested_loop = 0
116
- while( nested_result_1 != nested_result_2 )
112
+ while ( nested_result_1 != nested_result_2)
117
113
  if nested_loop >= 100
118
- $log.writer.error "Template stack overflow, too many nested tags"
114
+ $log.writer.error 'Template stack overflow, too many nested tags'
119
115
  exit 1
120
116
  end
121
117
  nested_result_1 = parser.parse(nested_result_2)
122
118
  nested_result_2 = parser.parse(nested_result_1)
123
119
 
124
120
  nested_loop = nested_loop + 1
125
- end
126
- result = nested_result_2
127
- rescue Exception => e
121
+ end
122
+ result = nested_result_2
123
+ rescue => e
128
124
  $log.writer.error "Error in template processing: #{template}"
129
125
  $log.writer.error e.message
130
126
  exit 1
@@ -134,4 +130,3 @@ module Processor
134
130
  end
135
131
  end
136
132
  end
137
-
@@ -1,22 +1,21 @@
1
1
  module Processor
2
-
3
- def unzip_file(zip_file, target_dir, extract_file=nil, unzip_bin=nil)
2
+ def unzip_file(zip_file, target_dir, extract_file = nil, unzip_bin = nil)
4
3
  unzip = unzip_bin || 'unzip'
5
4
 
6
- if not File.exists? zip_file
5
+ unless File.exist? zip_file
7
6
  $log.writer.error "Zip file #{zip_file} does not exist!"
8
7
  exit 1
9
8
  end
10
9
 
11
- if not File.exists? target_dir
12
- FileUtils.mkdir( target_dir )
10
+ unless File.exist? target_dir
11
+ FileUtils.mkdir(target_dir)
13
12
  $log.writer.debug "Create target directory #{target_dir}"
14
13
  end
15
14
 
16
15
  begin
17
- stdout = %x"#{unzip} -o \"#{zip_file}\" #{extract_file} -d \"#{target_dir}\""
16
+ stdout = `#{unzip} -o \"#{zip_file}\" #{extract_file} -d \"#{target_dir}\"`
18
17
  $log.writer.debug stdout
19
- rescue Exception => e
18
+ rescue => e
20
19
  $log.writer.error "Can not extract Zipfile #{zip_file} to #{target_dir}"
21
20
  $log.writer.error e.message
22
21
  exit 1
@@ -24,18 +23,18 @@ module Processor
24
23
  end
25
24
  module_function :unzip_file
26
25
 
27
- def tgz_file(tgz_file, source_dir, add_file=nil, tar_bin=nil)
26
+ def tgz_file(tgz_file, source_dir, add_file = nil, tar_bin = nil)
28
27
  tar = tar_bin || 'tar'
29
28
 
30
- if not File.exists? source_dir
29
+ unless File.exist? source_dir
31
30
  $log.writer.error "Source directory #{source_dir} does not exist!"
32
31
  exit 1
33
32
  end
34
33
 
35
34
  begin
36
- stdout = %x"#{tar} -c -z -C #{source_dir} -f #{tgz_file} #{add_file}"
35
+ stdout = `#{tar} -c -z -C #{source_dir} -f #{tgz_file} #{add_file}`
37
36
  $log.writer.debug stdout
38
- rescue Exception => e
37
+ rescue => e
39
38
  $log.writer.error "Can not add files in #{source_dir} to Tar-Gz file #{tgz_file}"
40
39
  $log.writer.error e.message
41
40
  exit 1
@@ -43,30 +42,27 @@ module Processor
43
42
  end
44
43
  module_function :tgz_file
45
44
 
46
- def untgz_file(tgz_file, target_dir, extract_file=nil, tar_bin=nil)
45
+ def untgz_file(tgz_file, target_dir, extract_file = nil, tar_bin = nil)
47
46
  tar = tar_bin || 'tar'
48
47
 
49
- if not File.exists? tgz_file
48
+ unless File.exist? tgz_file
50
49
  $log.writer.error "Tar-Gz file #{tgz_file} does not exist!"
51
50
  exit 1
52
51
  end
53
52
 
54
- if not File.exists? target_dir
55
- FileUtils.mkdir( target_dir )
53
+ unless File.exist? target_dir
54
+ FileUtils.mkdir(target_dir)
56
55
  $log.writer.debug "Create target directory #{target_dir}"
57
56
  end
58
57
 
59
58
  begin
60
- stdout = %x"#{tar} -x -z -C #{target_dir} -f #{tgz_file} #{extract_file}"
59
+ stdout = `#{tar} -x -z -C #{target_dir} -f #{tgz_file} #{extract_file}`
61
60
  $log.writer.debug stdout
62
- rescue Exception => e
61
+ rescue => e
63
62
  $log.writer.error "Can not extract Tar-Gz file #{tgz_file} to #{target_dir}"
64
63
  $log.writer.error e.message
65
64
  exit 1
66
65
  end
67
66
  end
68
67
  module_function :untgz_file
69
-
70
68
  end
71
-
72
-
@@ -6,8 +6,8 @@ module Provider
6
6
  attr_accessor :env
7
7
 
8
8
  def get_parameter(path, version)
9
- result = "@@ERROR@@"
10
- version = "" if version == 0
9
+ result = '@@ERROR@@'
10
+ version = '' if version == 0
11
11
 
12
12
  Helper.validates_presence_of host
13
13
  Helper.validates_presence_of context
@@ -17,14 +17,14 @@ module Provider
17
17
 
18
18
  begin
19
19
  url = protocol + '://' + File.join(host, context, \
20
- version.to_s, env, path)
20
+ version.to_s, env, path)
21
21
  result = Net::HTTP.get(URI.parse(url))
22
22
  if path =~ /.json$/
23
23
  begin
24
- result = JSON.parse( result )
25
- rescue Exception => e
26
- $log.writer.error "Error: got invalid json from cdb"
27
- $log.writer.error "Request was: #{url.to_s}"
24
+ result = JSON.parse(result)
25
+ rescue => e
26
+ $log.writer.error 'Error: got invalid json from cdb'
27
+ $log.writer.error "Request was: #{url}"
28
28
  $log.writer.error "Answer was: #{Net::HTTP.get(URI.parse(url))}"
29
29
  $log.writer.error e.message
30
30
  exit 1
@@ -32,39 +32,38 @@ module Provider
32
32
  end
33
33
 
34
34
  # decrypt encrypted entries automagically
35
- password = ""
35
+ password = ''
36
36
  password_file = (File.join(File.dirname($exec_file_path), '../etc/crypt.yaml'))
37
37
 
38
38
  if File.file? password_file
39
- password = YAML::load_file(password_file)['password']
39
+ password = YAML.load_file(password_file)['password']
40
40
  else
41
- $log.writer.warn "Can not open etc/crypt.yaml, no decryption possible"
41
+ $log.writer.warn 'Can not open etc/crypt.yaml, no decryption possible'
42
42
  end
43
43
 
44
- if result.class.name == "Hash"
45
- result.each do |key,value|
46
- if value.class.name != "Fixnum" and \
47
- ((value =~ /^\{[\w-]+\}.+/ ) != nil)
48
- result[key] = decrypt(password, value)
49
- end
50
- end
44
+ if result.class.name == 'Hash'
45
+ result.each do |key, value|
46
+ next unless value.class.name != 'Fixnum' and \
47
+ (value =~ /^\{[\w-]+\}.+/)
48
+ result[key] = decrypt(password, value)
49
+ end
51
50
  else
52
- if result.class.name != "Fixnum" and \
53
- ((result =~ /^\{[\w-]+\}.+/ ) != nil)
51
+ if result.class.name != 'Fixnum' and \
52
+ (result =~ /^\{[\w-]+\}.+/)
54
53
  result = decrypt(password, result)
55
54
  end
56
55
  end
57
56
 
58
- rescue Exception => e
59
- $log.writer.error "Error: while connecting to configuration database"
60
- $log.writer.error "Request was: #{url.to_s}"
57
+ rescue => e
58
+ $log.writer.error 'Error: while connecting to configuration database'
59
+ $log.writer.error "Request was: #{url}"
61
60
  $log.writer.error e.message
62
61
  exit 1
63
62
  end
64
63
 
65
- if result == "@@ERROR@@"
66
- $log.writer.error "Error while talking to configuration database, giving up!"
67
- $log.writer.error "Request was: #{url.to_s}"
64
+ if result == '@@ERROR@@'
65
+ $log.writer.error 'Error while talking to configuration database, giving up!'
66
+ $log.writer.error "Request was: #{url}"
68
67
  exit 1
69
68
  end
70
69
 
@@ -72,10 +71,9 @@ module Provider
72
71
  end
73
72
 
74
73
  def get_parameters(path, version)
75
- result = "@@ERROR@@"
76
- version = "" if version == 0
77
- url = ""
78
-
74
+ result = '@@ERROR@@'
75
+ version = '' if version == 0
76
+ url = ''
79
77
 
80
78
  Helper.validates_presence_of host
81
79
  Helper.validates_presence_of context
@@ -86,57 +84,56 @@ module Provider
86
84
  begin
87
85
 
88
86
  begin
89
- cdb_filesystem = Provider::CDB_FILESYSTEM.new
87
+ cdb_filesystem = Provider::CdbFilesystem.new
90
88
  result = JSON.parse(cdb_filesystem.read_data(path))
91
- #puts result
92
- rescue Exception => e
93
- $log.writer.error "Error: got invalid json from cdb"
94
- $log.writer.error "Request was: #{path.to_s}"
89
+ # puts result
90
+ rescue => e
91
+ $log.writer.error 'Error: got invalid json from cdb'
92
+ $log.writer.error "Request was: #{path}"
95
93
  $log.writer.error e.message
96
94
  exit 1
97
95
  end
98
96
 
99
97
  # decrypt encrypted entries automagically
100
- password = ""
98
+ password = ''
101
99
  if ENV['USE_DEPENGINE_AS_GEM']
102
100
  password_file = \
103
- ( File.join(File.dirname($exec_file_path), '../../etc/crypt.yaml') )
101
+ ( File.join(File.dirname($exec_file_path), '../../etc/crypt.yaml'))
104
102
  else
105
103
  password_file = \
106
- ( File.join(File.dirname($exec_file_path), '../etc/crypt.yaml') )
104
+ ( File.join(File.dirname($exec_file_path), '../etc/crypt.yaml'))
107
105
  end
108
106
  if File.file? password_file
109
- password = YAML::load_file(password_file)['password']
107
+ password = YAML.load_file(password_file)['password']
110
108
  else
111
- $log.writer.warn "Can not open etc/crypt.yaml, no decryption possible"
109
+ $log.writer.warn 'Can not open etc/crypt.yaml, no decryption possible'
112
110
  end
113
111
 
114
- result.each do |key,value|
115
- if value.class.name == "Hash"
116
- value.each do |subkey,subvalue|
117
- if subvalue.class.name != "Fixnum" and \
118
- ((subvalue =~ /^\{[\w-]+\}.+/ ) != nil)
119
- result[key][subkey] = decrypt(password, subvalue)
120
- end
112
+ result.each do |key, value|
113
+ if value.class.name == 'Hash'
114
+ value.each do |subkey, subvalue|
115
+ next unless subvalue.class.name != 'Fixnum' and \
116
+ (subvalue =~ /^\{[\w-]+\}.+/)
117
+ result[key][subkey] = decrypt(password, subvalue)
121
118
  end
122
119
  else
123
- if value.class.name != "Fixnum" and
124
- ((value =~ /^\{[\w-]+\}.+/ ) != nil)
120
+ if value.class.name != 'Fixnum' and
121
+ (value =~ /^\{[\w-]+\}.+/)
125
122
  result[key] = decrypt(password, value)
126
123
  end
127
124
  end
128
125
  end
129
126
 
130
- rescue Exception => e
131
- $log.writer.error "Error: while talking to configuration database, giving up!"
132
- $log.writer.error "Request was: #{url.to_s}"
127
+ rescue => e
128
+ $log.writer.error 'Error: while talking to configuration database, giving up!'
129
+ $log.writer.error "Request was: #{url}"
133
130
  $log.writer.error e.message
134
131
  exit 1
135
132
  end
136
133
 
137
- if result == "@@ERROR@@"
138
- $log.writer.error "Error while talking to configuration database, giving up!"
139
- $log.writer.error "Request was: #{url.to_s}"
134
+ if result == '@@ERROR@@'
135
+ $log.writer.error 'Error while talking to configuration database, giving up!'
136
+ $log.writer.error "Request was: #{url}"
140
137
  exit 1
141
138
  end
142
139
 
@@ -144,7 +141,7 @@ module Provider
144
141
  end
145
142
 
146
143
  def set_parameter(path, key, value)
147
- result = "@@ERROR@@"
144
+ result = '@@ERROR@@'
148
145
 
149
146
  Helper.validates_presence_of host
150
147
  Helper.validates_presence_of context
@@ -154,33 +151,33 @@ module Provider
154
151
  Helper.validates_presence_of value
155
152
 
156
153
  begin
157
- json = {key => value.to_s}.to_json
154
+ json = { key => value.to_s }.to_json
158
155
  url = URI.parse(protocol + '://' + \
159
156
  File.join(host, context, env, path))
160
- header = {'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'}
157
+ header = { 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8' }
161
158
  http = Net::HTTP.new(url.host, url.port)
162
159
  result = http.request_post(url.path, 'json=' + json.to_s, header)
163
160
  $log.writer.debug "Writing #{key} with #{value} to cdb"
164
- rescue Exception => e
165
- $log.writer.error "Error: while connecting to configuration database"
166
- $log.writer.error "Request was: #{url.to_s}"
161
+ rescue => e
162
+ $log.writer.error 'Error: while connecting to configuration database'
163
+ $log.writer.error "Request was: #{url}"
167
164
  $log.writer.error e.message
168
165
  exit 1
169
166
  end
170
167
 
171
- if result == "@@ERROR@@"
172
- $log.writer.error "Error while talking to configuration database, giving up!"
173
- $log.writer.error "Request was: #{url.to_s}"
168
+ if result == '@@ERROR@@'
169
+ $log.writer.error 'Error while talking to configuration database, giving up!'
170
+ $log.writer.error "Request was: #{url}"
174
171
  exit 1
175
172
  end
176
173
 
177
174
  result
178
175
  end
179
176
 
180
- def decrypt(password,transferrable)
181
- alg = transferrable.split("}")[0].split("{")[1]
182
- hex_encrypted = transferrable.split(":")[0].split("}")[1]
183
- hex_iv = transferrable.split(":")[1]
177
+ def decrypt(password, transferrable)
178
+ alg = transferrable.split('}')[0].split('{')[1]
179
+ hex_encrypted = transferrable.split(':')[0].split('}')[1]
180
+ hex_iv = transferrable.split(':')[1]
184
181
  text = Base64.decode64(hex_encrypted)
185
182
  iv = Base64.decode64(hex_iv)
186
183
  c = OpenSSL::Cipher::Cipher.new(alg)
@@ -190,10 +187,6 @@ module Provider
190
187
  c.iv = iv
191
188
  d = c.update(text)
192
189
  d << c.final
193
-
194
- return d
195
190
  end
196
-
197
191
  end
198
192
  end
199
-
@@ -1,48 +1,40 @@
1
1
  module Provider
2
- class CDB_FILESYSTEM
3
-
2
+ class CdbFilesystem
4
3
  def load_yaml(filename)
5
4
  if File.file? filename
6
- begin
7
- YAML::load_file(filename)
8
- rescue StringIndexOutOfBoundsException => e
9
- puts "Error: YAML parsing in #{filename}"
10
- raise "YAML not parsable"
11
- false
12
- rescue Exception => e
13
- puts "Error: YAML parsing in #{filename}"
14
- raise "YAML not parsable"
15
- false
16
- end
5
+ begin
6
+ YAML.load_file(filename)
7
+ rescue
8
+ puts "Error: YAML parsing in #{filename}"
9
+ raise 'YAML not parsable'
10
+ end
17
11
  else
18
- raise "File not found: #{filename}"
12
+ fail "File not found: #{filename}"
19
13
  end
20
14
  end
21
15
 
22
- def read_data(cdb_path, options={})
23
- config = Hash.new
24
- basedir = File.join(($recipe_config[:recipe_base_dir] || $recipe_config[:deploy_home]),'cdb')
16
+ def read_data(cdb_path, options = {})
17
+ config = {}
18
+ basedir = File.join(($recipe_config[:recipe_base_dir] || $recipe_config[:deploy_home]), 'cdb')
25
19
  filename = ''
26
20
  if cdb_path.nil? or cdb_path.empty?
27
- $log.writer.error "Error while talking to configuration database, no cdb path given!"
21
+ $log.writer.error 'Error while talking to configuration database, no cdb path given!'
28
22
  exit 1
29
23
  end
30
24
  paths = cdb_path.split('/')
31
25
 
32
26
  paths.each do |path|
33
- basedir = File.join( basedir, path.to_s )
27
+ basedir = File.join(basedir, path.to_s)
34
28
  filename = basedir + '.yaml'
35
29
  additional_config = load_yaml(filename)
36
- if additional_config.is_a?(Hash)
37
- if options[:disable_merge]
38
- config = additional_config
39
- else
40
- config.merge!( additional_config )
41
- end
30
+ next unless additional_config.is_a?(Hash)
31
+ if options[:disable_merge]
32
+ config = additional_config
33
+ else
34
+ config.merge!(additional_config)
42
35
  end
43
36
  end
44
37
  config.to_json
45
38
  end
46
-
47
39
  end
48
40
  end