depengine 3.0.20 → 3.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +52 -0
- data/Gemfile.lock +16 -1
- data/Rakefile +9 -9
- data/bin/cdb_crypt +2 -2
- data/bin/de +1 -1
- data/bin/depengine +2 -2
- data/bin/spec_setup +2 -2
- data/depengine.gemspec +22 -21
- data/lib/depengine/asserter/url.rb +8 -9
- data/lib/depengine/cli.rb +12 -14
- data/lib/depengine/dsl/cdb.rb +16 -17
- data/lib/depengine/dsl/deployment.rb +42 -50
- data/lib/depengine/dsl/dweb.rb +10 -11
- data/lib/depengine/dsl/executor.rb +5 -5
- data/lib/depengine/dsl/fileops.rb +3 -4
- data/lib/depengine/dsl/helper.rb +26 -28
- data/lib/depengine/dsl/iis.rb +21 -24
- data/lib/depengine/dsl/patch.rb +22 -46
- data/lib/depengine/dsl/publisher.rb +14 -14
- data/lib/depengine/dsl/remote.rb +11 -13
- data/lib/depengine/dsl/repository.rb +19 -21
- data/lib/depengine/dsl/template.rb +19 -19
- data/lib/depengine/dsl/zip.rb +24 -24
- data/lib/depengine/helper/cli_helper.rb +9 -11
- data/lib/depengine/helper/hudson.rb +15 -19
- data/lib/depengine/helper/mail.rb +19 -25
- data/lib/depengine/helper/properties.rb +33 -52
- data/lib/depengine/helper/smb.rb +19 -25
- data/lib/depengine/helper/validations.rb +7 -7
- data/lib/depengine/helper/yaml.rb +7 -9
- data/lib/depengine/log/log.rb +3 -6
- data/lib/depengine/processor/erb_template.rb +42 -47
- data/lib/depengine/processor/fileops.rb +39 -48
- data/lib/depengine/processor/local_execute.rb +6 -4
- data/lib/depengine/processor/properties.rb +34 -56
- data/lib/depengine/processor/sed.rb +8 -12
- data/lib/depengine/processor/tags.rb +9 -10
- data/lib/depengine/processor/template.rb +27 -32
- data/lib/depengine/processor/zip.rb +16 -20
- data/lib/depengine/provider/cdb.rb +64 -71
- data/lib/depengine/provider/cdb_filesystem.rb +18 -26
- data/lib/depengine/provider/git.rb +37 -42
- data/lib/depengine/provider/repository.rb +161 -176
- data/lib/depengine/publisher/dweb.rb +74 -90
- data/lib/depengine/publisher/iis.rb +23 -30
- data/lib/depengine/publisher/rsync.rb +14 -17
- data/lib/depengine/publisher/samba.rb +12 -14
- data/lib/depengine/publisher/sftp.rb +51 -61
- data/lib/depengine/publisher/ssh.rb +19 -22
- data/lib/depengine/publisher/tomcat.rb +19 -21
- data/lib/depengine/reporter/cdb.rb +2 -3
- data/lib/depengine/version.rb +1 -1
- data/lib/depengine.rb +1 -2
- data/spec/cdb_spec.rb +8 -10
- data/spec/demo_recipe/recipes/demo.rb +10 -10
- data/spec/deployhelper_spec.rb +20 -21
- data/spec/fileops_spec.rb +11 -12
- data/spec/git_spec.rb +8 -4
- data/spec/helper_spec.rb +75 -75
- data/spec/junit.rb +47 -49
- data/spec/local_execute.rb +7 -7
- data/spec/log_spec.rb +17 -18
- data/spec/properties_spec.rb +13 -15
- data/spec/recipe_spec.rb +15 -16
- data/spec/repository_spec.rb +20 -20
- data/spec/ssh_spec.rb +18 -19
- data/spec/template_spec.rb +30 -30
- data/spec/zip_spec.rb +7 -7
- 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
|
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,
|
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
|
-
|
24
|
-
|
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(
|
34
|
-
File.open(target_file,
|
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?(
|
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
|
-
|
69
|
+
false
|
72
70
|
end
|
73
71
|
|
74
72
|
def create_sub_dirs!(target)
|
75
|
-
if
|
76
|
-
|
77
|
-
|
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, :
|
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,
|
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
|
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
|
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
|
-
|
126
|
-
|
127
|
-
rescue
|
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
|
-
|
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
|
-
|
12
|
-
FileUtils.mkdir(
|
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 =
|
16
|
+
stdout = `#{unzip} -o \"#{zip_file}\" #{extract_file} -d \"#{target_dir}\"`
|
18
17
|
$log.writer.debug stdout
|
19
|
-
rescue
|
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
|
-
|
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 =
|
35
|
+
stdout = `#{tar} -c -z -C #{source_dir} -f #{tgz_file} #{add_file}`
|
37
36
|
$log.writer.debug stdout
|
38
|
-
rescue
|
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
|
-
|
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
|
-
|
55
|
-
FileUtils.mkdir(
|
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 =
|
59
|
+
stdout = `#{tar} -x -z -C #{target_dir} -f #{tgz_file} #{extract_file}`
|
61
60
|
$log.writer.debug stdout
|
62
|
-
rescue
|
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 =
|
10
|
-
version =
|
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
|
-
|
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(
|
25
|
-
rescue
|
26
|
-
$log.writer.error
|
27
|
-
$log.writer.error "Request was: #{url
|
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
|
39
|
+
password = YAML.load_file(password_file)['password']
|
40
40
|
else
|
41
|
-
$log.writer.warn
|
41
|
+
$log.writer.warn 'Can not open etc/crypt.yaml, no decryption possible'
|
42
42
|
end
|
43
43
|
|
44
|
-
if result.class.name ==
|
45
|
-
result.each do |key,value|
|
46
|
-
|
47
|
-
(
|
48
|
-
|
49
|
-
|
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 !=
|
53
|
-
(
|
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
|
59
|
-
$log.writer.error
|
60
|
-
$log.writer.error "Request was: #{url
|
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 ==
|
66
|
-
$log.writer.error
|
67
|
-
$log.writer.error "Request was: #{url
|
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 =
|
76
|
-
version =
|
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::
|
87
|
+
cdb_filesystem = Provider::CdbFilesystem.new
|
90
88
|
result = JSON.parse(cdb_filesystem.read_data(path))
|
91
|
-
#puts result
|
92
|
-
rescue
|
93
|
-
$log.writer.error
|
94
|
-
$log.writer.error "Request was: #{path
|
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
|
107
|
+
password = YAML.load_file(password_file)['password']
|
110
108
|
else
|
111
|
-
$log.writer.warn
|
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 ==
|
116
|
-
value.each do |subkey,subvalue|
|
117
|
-
|
118
|
-
(
|
119
|
-
|
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 !=
|
124
|
-
(
|
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
|
131
|
-
$log.writer.error
|
132
|
-
$log.writer.error "Request was: #{url
|
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 ==
|
138
|
-
$log.writer.error
|
139
|
-
$log.writer.error "Request was: #{url
|
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 =
|
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
|
165
|
-
$log.writer.error
|
166
|
-
$log.writer.error "Request was: #{url
|
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 ==
|
172
|
-
$log.writer.error
|
173
|
-
$log.writer.error "Request was: #{url
|
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(
|
182
|
-
hex_encrypted = transferrable.split(
|
183
|
-
hex_iv = transferrable.split(
|
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
|
3
|
-
|
2
|
+
class CdbFilesystem
|
4
3
|
def load_yaml(filename)
|
5
4
|
if File.file? filename
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
12
|
+
fail "File not found: #{filename}"
|
19
13
|
end
|
20
14
|
end
|
21
15
|
|
22
|
-
def read_data(cdb_path, options={})
|
23
|
-
config =
|
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
|
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(
|
27
|
+
basedir = File.join(basedir, path.to_s)
|
34
28
|
filename = basedir + '.yaml'
|
35
29
|
additional_config = load_yaml(filename)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|