batali-tk 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +24 -1
- data/batali-tk.gemspec +1 -1
- data/bin/batali-tk +65 -2
- data/lib/batali-tk/monkey.rb +2 -2
- data/lib/batali-tk/provisioner.rb +16 -6
- data/lib/batali-tk/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b6f318f0e0529d04126964e9bef9be6da18018d
|
4
|
+
data.tar.gz: f38cc77847cfecfe57598d7a44614bc69ec9eae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51518ec2b64948257da81e2462e07e799f7d3164f89538b09f60229675ceda2097b22abc3f025e3be1673cdb58de7d0eeb5c51ab940c7d31aa51a6906774aea7
|
7
|
+
data.tar.gz: e8f908d11159ba87c55d3514a499f79d481ea1e94bbd4787d4dae56f2af413b564644c0c2b59d6e9d8895620530c760d1d3d22c6466c5a6de7e6a5a059565ae3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,30 @@ use the wrapper command:
|
|
17
17
|
$ batali-tk --help
|
18
18
|
```
|
19
19
|
|
20
|
-
|
20
|
+
### Infrastructure Repository
|
21
|
+
|
22
|
+
The Batali test-kitchen wrapper can be used to test cookbooks within an
|
23
|
+
infrastructure repository context. A `Batali` file is required at the root
|
24
|
+
of the infrastructure repository and is optional within the cookbook itself
|
25
|
+
(only required in the cookbook if extra testing dependencies are required).
|
26
|
+
This can be done using the `--batali-cookbook-path` flag. As most cookbooks
|
27
|
+
will live in a separate repository, you can provide the path to a working
|
28
|
+
copy on your system:
|
29
|
+
|
30
|
+
```
|
31
|
+
$ batali-tk test BOX --batali-cookbook-path ../users
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Environment constraints
|
35
|
+
|
36
|
+
If you want to test the cookbook using a specific set of environment constraints,
|
37
|
+
that can be done too. It required the auto discovery feature of Batali to be
|
38
|
+
in use within the infrastructure repository Batali file. To enable environment
|
39
|
+
constraints:
|
40
|
+
|
41
|
+
```
|
42
|
+
$ batali-tk test BOX --batali-cookbook-path ../users --batali-environment production
|
43
|
+
```
|
21
44
|
|
22
45
|
# Info
|
23
46
|
|
data/batali-tk.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = 'Batali support injector for test kitchen'
|
11
11
|
s.require_path = 'lib'
|
12
12
|
s.license = 'Apache 2.0'
|
13
|
-
s.add_runtime_dependency 'batali', '>= 0.2.
|
13
|
+
s.add_runtime_dependency 'batali', '>= 0.2.33', '< 1'
|
14
14
|
s.add_runtime_dependency 'test-kitchen', BataliTk::TK_CONSTRAINT
|
15
15
|
s.executables << 'batali-tk'
|
16
16
|
s.files = Dir['{lib,bin}/**/**/*'] + %w(batali-tk.gemspec README.md CHANGELOG.md CONTRIBUTING.md LICENSE)
|
data/bin/batali-tk
CHANGED
@@ -1,6 +1,64 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
Signal.trap("INT") { exit 1 }
|
4
|
+
require 'bogo'
|
5
|
+
require 'batali'
|
6
|
+
|
7
|
+
if(idx = ARGV.index('--batali-cookbook-path'))
|
8
|
+
_, cookbook_path = ARGV.slice!(idx, 2)
|
9
|
+
cookbook_info = Batali::Origin::Path.new(:name => 'metadata', :path => File.expand_path(cookbook_path))
|
10
|
+
cookbook_name = cookbook_info.units.first.name
|
11
|
+
ckbk_batali = File.join(File.expand_path(cookbook_path), 'Batali')
|
12
|
+
origin_batali = Batali::BFile.new(File.expand_path('./Batali'))
|
13
|
+
origin_batali.cookbook.delete_if{|item| item.name == cookbook_name}
|
14
|
+
if(File.exists?(ckbk_batali))
|
15
|
+
ckbk_b = Batali::BFile.new(ckbk_batali)
|
16
|
+
new_batali_data = MultiJson.dump(
|
17
|
+
MultiJson.load(
|
18
|
+
MultiJson.dump(ckbk_b.data)
|
19
|
+
).to_smash.deep_merge(
|
20
|
+
MultiJson.load(
|
21
|
+
MultiJson.dump(origin_batali.data)
|
22
|
+
)
|
23
|
+
)
|
24
|
+
)
|
25
|
+
else
|
26
|
+
origin_batali.cookbook.push(Batali::BFile::Cookbook.new(:name => cookbook_name, :path => cookbook_path))
|
27
|
+
new_batali_data = MultiJson.dump(origin_batali.data)
|
28
|
+
end
|
29
|
+
|
30
|
+
n_data = MultiJson.load(new_batali_data)
|
31
|
+
|
32
|
+
expander = lambda do |item|
|
33
|
+
if(item.is_a?(Hash))
|
34
|
+
item.keys.each do |k|
|
35
|
+
if(k == 'path')
|
36
|
+
item[k] = File.expand_path(item[k])
|
37
|
+
elsif(item[k].is_a?(Hash) || item[k].is_a?(Array))
|
38
|
+
expander.call(item[k])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
elsif(item.is_a?(Array))
|
42
|
+
item.each{|i| expander.call(i)}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
expander.call(n_data)
|
46
|
+
|
47
|
+
temp_b = Bogo::EphemeralFile.new('batali-tk')
|
48
|
+
temp_b.write MultiJson.dump(n_data)
|
49
|
+
temp_b.flush
|
50
|
+
|
51
|
+
ENV['KITCHEN_BATALI_FILE'] = temp_b.path
|
52
|
+
ENV['KITCHEN_YAML'] = File.expand_path(
|
53
|
+
File.join('.', cookbook_path, '.kitchen.yml')
|
54
|
+
)
|
55
|
+
puts "!! Batali test-kitchen infra-repo override for `#{cookbook_name}` @ `#{cookbook_path}`"
|
56
|
+
end
|
57
|
+
if(idx = ARGV.index('--batali-environment'))
|
58
|
+
_, environment_name = ARGV.slice!(idx, 2)
|
59
|
+
ENV['KITCHEN_BATALI_ENVIRONMENT'] = environment_name
|
60
|
+
puts "!! Batali test-kitchen infra-repo override for resolution against `#{environment_name}` environment defined constraints"
|
61
|
+
end
|
4
62
|
|
5
63
|
# Force `kitchen` name so we don't end up with batali-tk branding
|
6
64
|
require 'thor'
|
@@ -16,5 +74,10 @@ require 'kitchen'
|
|
16
74
|
require 'kitchen/cli'
|
17
75
|
require 'kitchen/errors'
|
18
76
|
|
19
|
-
|
20
|
-
|
77
|
+
cwd = Dir.pwd
|
78
|
+
begin
|
79
|
+
Dir.chdir(cookbook_path)
|
80
|
+
Kitchen.with_friendly_errors { Kitchen::CLI.start }
|
81
|
+
ensure
|
82
|
+
Dir.chdir(cwd)
|
83
|
+
end
|
data/lib/batali-tk/monkey.rb
CHANGED
@@ -3,7 +3,7 @@ module BataliTk
|
|
3
3
|
module Box
|
4
4
|
|
5
5
|
def batali_file
|
6
|
-
File.join(config[:kitchen_root], "Batali")
|
6
|
+
ENV.fetch('KITCHEN_BATALI_FILE', File.join(config[:kitchen_root], "Batali"))
|
7
7
|
end
|
8
8
|
|
9
9
|
def batali_prepare_cookbooks
|
@@ -37,7 +37,7 @@ module BataliTk
|
|
37
37
|
module Base
|
38
38
|
|
39
39
|
def batali_file
|
40
|
-
File.join(config[:kitchen_root], "Batali")
|
40
|
+
ENV.fetch('KITCHEN_BATALI_FILE', File.join(config[:kitchen_root], "Batali"))
|
41
41
|
end
|
42
42
|
|
43
43
|
def batali_load_needed_dependencies!
|
@@ -48,20 +48,30 @@ module Kitchen
|
|
48
48
|
debug "Using Batali file located at: #{batali_file}"
|
49
49
|
output = ''
|
50
50
|
begin
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
FileUtils.cp(
|
52
|
+
batali_file,
|
53
|
+
File.join(
|
54
|
+
File.dirname(vendor_path),
|
55
|
+
'Batali'
|
56
|
+
)
|
57
|
+
)
|
58
|
+
Dir.chdir(File.dirname(vendor_path)) do
|
59
|
+
::Batali::Command::Update.new(
|
60
|
+
Smash.new(
|
54
61
|
:path => vendor_path,
|
55
62
|
:update => {
|
56
|
-
:install => true
|
63
|
+
:install => true,
|
64
|
+
:environment => ENV['KITCHEN_BATALI_ENVIRONMENT'],
|
65
|
+
:infrastructure => false
|
57
66
|
},
|
58
67
|
:ui => Bogo::Ui.new(
|
59
68
|
:app_name => 'Batali',
|
60
69
|
:output_to => StringIO.new(output)
|
61
70
|
),
|
62
71
|
),
|
63
|
-
|
64
|
-
|
72
|
+
[]
|
73
|
+
).execute!
|
74
|
+
end
|
65
75
|
rescue => e
|
66
76
|
error "Batali failed to install cookbooks! #{e.class}: #{e}"
|
67
77
|
end
|
data/lib/batali-tk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batali-tk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: batali
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.33
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '1'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.2.
|
29
|
+
version: 0.2.33
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '1'
|
@@ -81,9 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.4.8
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Batali for test-kitchen
|
88
88
|
test_files: []
|
89
|
-
has_rdoc:
|