boxgrinder-core 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/boxgrinder-core.gemspec +3 -3
- data/lib/boxgrinder-core/helpers/appliance-definition-helper.rb +17 -2
- data/lib/boxgrinder-core/helpers/exec-helper.rb +8 -4
- data/lib/boxgrinder-core/helpers/log-helper.rb +1 -1
- data/rubygem-boxgrinder-core.spec +6 -1
- data/spec/helpers/appliance-definition-helper-spec.rb +9 -3
- data/spec/helpers/exec-helper-spec.rb +16 -6
- data/spec/helpers/log-helper-spec.rb +3 -3
- data/spec/rspec/src/appliances/{invalid_yaml.appl → invalid-yaml.appl} +0 -0
- data/spec/rspec/src/appliances/legacy.appl +8 -0
- metadata +7 -6
data/CHANGELOG
CHANGED
data/boxgrinder-core.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{boxgrinder-core}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marek Goldmann"]
|
9
|
-
s.date = %q{2011-
|
9
|
+
s.date = %q{2011-03-09}
|
10
10
|
s.description = %q{Core library for BoxGrinder}
|
11
11
|
s.email = %q{info@boxgrinder.org}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-definition-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb"]
|
13
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-definition-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "rubygem-boxgrinder-core.spec", "spec/helpers/appliance-config-helper-spec.rb", "spec/helpers/appliance-definition-helper-spec.rb", "spec/helpers/exec-helper-spec.rb", "spec/helpers/log-helper-spec.rb", "spec/models/config-spec.rb", "spec/rspec/ls/one", "spec/rspec/ls/two", "spec/rspec/src/appliances/ephemeral-repo.appl", "spec/rspec/src/appliances/full.appl", "spec/rspec/src/appliances/
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-definition-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "rubygem-boxgrinder-core.spec", "spec/helpers/appliance-config-helper-spec.rb", "spec/helpers/appliance-definition-helper-spec.rb", "spec/helpers/exec-helper-spec.rb", "spec/helpers/log-helper-spec.rb", "spec/models/config-spec.rb", "spec/rspec/ls/one", "spec/rspec/ls/two", "spec/rspec/src/appliances/ephemeral-repo.appl", "spec/rspec/src/appliances/full.appl", "spec/rspec/src/appliances/invalid-yaml.appl", "spec/rspec/src/appliances/legacy.appl", "spec/rspec/src/appliances/repo.appl", "spec/rspec/src/config/empty", "spec/rspec/src/config/valid", "spec/validators/appliance-config-validator-spec.rb"]
|
14
14
|
s.homepage = %q{http://www.jboss.org/boxgrinder}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-core", "--main", "README"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -105,9 +105,24 @@ module BoxGrinder
|
|
105
105
|
|
106
106
|
definition['variables'].each { |key, value| appliance_config.variables[key] = value } unless definition['variables'].nil?
|
107
107
|
|
108
|
-
|
108
|
+
@log.debug "Adding packages to appliance..."
|
109
|
+
|
110
|
+
unless definition['packages'].nil?
|
111
|
+
if definition['packages'].is_a?(Array)
|
112
|
+
# new format
|
113
|
+
appliance_config.packages = definition['packages']
|
114
|
+
elsif definition['packages'].is_a?(Hash)
|
115
|
+
# legacy format
|
116
|
+
@log.warn "BoxGrinder Build packages section format has been changed. Support for legacy format will be removed in the future. See http://boxgrinder.org/tutorials/appliance-definition/ for more information about current format."
|
117
|
+
appliance_config.packages = definition['packages']['includes'] if definition['packages']['includes'].is_a?(Array)
|
118
|
+
@log.warn "BoxGrinder Build no longer supports package exclusion, the following packages will not be explicitly excluded: #{definition['packages']['excludes'].join(", ")}." if definition['packages']['excludes'].is_a?(Array)
|
119
|
+
else
|
120
|
+
@log.warn "Unsupported format for packages section."
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
@log.debug "#{appliance_config.packages.size} package(s) added to appliance."
|
109
125
|
|
110
|
-
appliance_config.packages = definition['packages'] if definition['packages'].is_a?(Array)
|
111
126
|
appliance_config.appliances = definition['appliances'] unless definition['appliances'].nil?
|
112
127
|
appliance_config.repos = definition['repos'] unless definition['repos'].nil?
|
113
128
|
|
@@ -26,8 +26,13 @@ module BoxGrinder
|
|
26
26
|
@log = options[:log] || Logger.new(STDOUT)
|
27
27
|
end
|
28
28
|
|
29
|
-
def execute( command )
|
30
|
-
|
29
|
+
def execute( command, options = {} )
|
30
|
+
redacted = options[:redacted] || []
|
31
|
+
|
32
|
+
redacted_command = command
|
33
|
+
redacted.each { |word| redacted_command = redacted_command.gsub(word, '<REDACTED>') }
|
34
|
+
|
35
|
+
@log.debug "Executing command: '#{redacted_command}'"
|
31
36
|
|
32
37
|
output = ""
|
33
38
|
|
@@ -66,8 +71,7 @@ module BoxGrinder
|
|
66
71
|
return output.strip
|
67
72
|
rescue => e
|
68
73
|
@log.error e.backtrace.join($/)
|
69
|
-
|
70
|
-
raise "An error occurred while executing command: '#{command}', #{e.message}"
|
74
|
+
raise "An error occurred while executing command: '#{redacted_command}', #{e.message}"
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -67,7 +67,7 @@ module BoxGrinder
|
|
67
67
|
FileUtils.mkdir_p(File.dirname(location))
|
68
68
|
|
69
69
|
@file_log = Logger.new(location, 10, 1024000)
|
70
|
-
@file_log.level =
|
70
|
+
@file_log.level = Logger::TRACE
|
71
71
|
@file_log.formatter = formatter
|
72
72
|
end
|
73
73
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Summary: Core library for BoxGrinder
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.
|
8
|
+
Version: 0.3.0
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
11
|
License: LGPLv3+
|
@@ -74,6 +74,11 @@ popd
|
|
74
74
|
%{gemdir}/doc/%{gemname}-%{version}
|
75
75
|
|
76
76
|
%changelog
|
77
|
+
* Sat Mar 05 2011 <mgoldman@redhat.com> - 0.3.0-1
|
78
|
+
- Upstream release: 0.3.0
|
79
|
+
- [BGBUILD-178] Remove sensitive data from logs
|
80
|
+
- [BGBUILD-168] Support deprecated package inclusion format in appliance definitions
|
81
|
+
|
77
82
|
* Tue Feb 16 2011 <mgoldman@redhat.com> - 0.2.1-1
|
78
83
|
- Upstream release: 0.2.1
|
79
84
|
- [BGBUILD-142] Backtraces make output unreadable - add option to enable them, and disable by default
|
@@ -22,7 +22,7 @@ module BoxGrinder
|
|
22
22
|
describe ApplianceDefinitionHelper do
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
@helper = ApplianceDefinitionHelper.new(:log =>
|
25
|
+
@helper = ApplianceDefinitionHelper.new(:log => LogHelper.new(:level => :trace, :type => :stdout))
|
26
26
|
end
|
27
27
|
|
28
28
|
describe ".read_definitions" do
|
@@ -166,7 +166,7 @@ module BoxGrinder
|
|
166
166
|
configs.first.should == appliance_a
|
167
167
|
end
|
168
168
|
|
169
|
-
it "should read
|
169
|
+
it "should read YAML content instead of loading a file" do
|
170
170
|
yaml = "name: abc\nos:\n name: fedora\n version: 13\npackages:\n - @core\nhardware:\n partitions:\n \"/\":\n size: 6"
|
171
171
|
appliance = @helper.read_definitions(yaml).last
|
172
172
|
|
@@ -184,7 +184,7 @@ module BoxGrinder
|
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should catch exception if YAML file parsing raises it" do
|
187
|
-
lambda { @helper.read_definitions("#{File.dirname(__FILE__)}/../rspec/src/appliances/
|
187
|
+
lambda { @helper.read_definitions("#{File.dirname(__FILE__)}/../rspec/src/appliances/invalid-yaml.appl") }.should raise_error(RuntimeError, /File '(.*)' could not be read./)
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should raise because xml files aren't supported yet" do
|
@@ -263,6 +263,12 @@ module BoxGrinder
|
|
263
263
|
appliance_config.hardware.partitions['/'].should == {'size' => 1}
|
264
264
|
appliance_config.hardware.partitions['/home'].should == {'size' => 1}
|
265
265
|
end
|
266
|
+
|
267
|
+
it "should allow legacy package inclusion style" do
|
268
|
+
appliance = @helper.read_yaml_file("#{File.dirname(__FILE__)}/../rspec/src/appliances/legacy.appl")
|
269
|
+
appliance.packages.should == ['squid','boxgrinder-rest']
|
270
|
+
end
|
271
|
+
|
266
272
|
end
|
267
273
|
end
|
268
274
|
end
|
@@ -21,11 +21,11 @@ require 'boxgrinder-core/helpers/exec-helper'
|
|
21
21
|
module BoxGrinder
|
22
22
|
describe ExecHelper do
|
23
23
|
before(:each) do
|
24
|
-
@helper = ExecHelper.new(
|
24
|
+
@helper = ExecHelper.new(:log => Logger.new('/dev/null'))
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should fail when command doesn't exists" do
|
28
|
-
Open4.should_receive(
|
28
|
+
Open4.should_receive(:popen4).with('thisdoesntexists').and_raise('abc')
|
29
29
|
|
30
30
|
proc { @helper.execute("thisdoesntexists") }.should raise_error("An error occurred while executing command: 'thisdoesntexists', abc")
|
31
31
|
end
|
@@ -34,7 +34,7 @@ module BoxGrinder
|
|
34
34
|
open4 = mock(Open4)
|
35
35
|
open4.stub!(:exitstatus).and_return(1)
|
36
36
|
|
37
|
-
Open4.should_receive(
|
37
|
+
Open4.should_receive(:popen4).with('abc').and_return(open4)
|
38
38
|
|
39
39
|
proc { @helper.execute("abc") }.should raise_error("An error occurred while executing command: 'abc', process exited with wrong exit status: 1")
|
40
40
|
end
|
@@ -43,17 +43,27 @@ module BoxGrinder
|
|
43
43
|
open4 = mock(Open4)
|
44
44
|
open4.stub!(:exitstatus).and_return(0)
|
45
45
|
|
46
|
-
Open4.should_receive(
|
46
|
+
Open4.should_receive(:popen4).with('abc').and_return(open4)
|
47
47
|
|
48
48
|
proc { @helper.execute("abc") }.should_not raise_error
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should execute the command and return output" do
|
52
|
-
@helper.execute("ls #{File.dirname(
|
52
|
+
@helper.execute("ls #{File.dirname(__FILE__)}/../rspec/ls | wc -l").should == "2"
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should execute the command and return multi line output" do
|
56
|
-
@helper.execute("ls -1 #{File.dirname(
|
56
|
+
@helper.execute("ls -1 #{File.dirname(__FILE__)}/../rspec/ls").should == "one\ntwo"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should redact some words from a command" do
|
60
|
+
log = mock('Logger')
|
61
|
+
log.should_receive(:debug).with("Executing command: 'ala ma <REDACTED> i jest fajnie'")
|
62
|
+
|
63
|
+
@helper = ExecHelper.new(:log => log)
|
64
|
+
Open4.should_receive(:popen4).and_return(OpenStruct.new(:exitstatus => 0))
|
65
|
+
|
66
|
+
@helper.execute("ala ma kota i jest fajnie", :redacted => ['kota'])
|
57
67
|
end
|
58
68
|
end
|
59
69
|
end
|
@@ -36,7 +36,7 @@ module BoxGrinder
|
|
36
36
|
file_log = @helper.instance_variable_get(:@file_log)
|
37
37
|
|
38
38
|
stdout_log.level.should == Logger::INFO
|
39
|
-
file_log.level.should == Logger::
|
39
|
+
file_log.level.should == Logger::TRACE
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should allow to log in every known log level" do
|
@@ -56,7 +56,7 @@ module BoxGrinder
|
|
56
56
|
file_log = @helper.instance_variable_get(:@file_log)
|
57
57
|
|
58
58
|
stdout_log.level.should == Logger::DEBUG
|
59
|
-
file_log.level.should == Logger::
|
59
|
+
file_log.level.should == Logger::TRACE
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should change log level" do
|
@@ -68,7 +68,7 @@ module BoxGrinder
|
|
68
68
|
file_log = @helper.instance_variable_get(:@file_log)
|
69
69
|
|
70
70
|
stdout_log.level.should == Logger::INFO
|
71
|
-
file_log.level.should == Logger::
|
71
|
+
file_log.level.should == Logger::TRACE
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxgrinder-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Goldmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-09 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -97,7 +97,8 @@ files:
|
|
97
97
|
- spec/rspec/ls/two
|
98
98
|
- spec/rspec/src/appliances/ephemeral-repo.appl
|
99
99
|
- spec/rspec/src/appliances/full.appl
|
100
|
-
- spec/rspec/src/appliances/
|
100
|
+
- spec/rspec/src/appliances/invalid-yaml.appl
|
101
|
+
- spec/rspec/src/appliances/legacy.appl
|
101
102
|
- spec/rspec/src/appliances/repo.appl
|
102
103
|
- spec/rspec/src/config/empty
|
103
104
|
- spec/rspec/src/config/valid
|