poise-boiler 1.8.0 → 1.9.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 +5 -0
- data/lib/kitchen/provisioner/poise_policyfile_zero.rb +26 -0
- data/lib/poise_boiler/helpers/kitchen/policy_provisioner.rb +79 -0
- data/lib/poise_boiler/helpers/kitchen/provisioner.rb +6 -59
- data/lib/poise_boiler/helpers/kitchen/provisioner_helpers.rb +83 -0
- data/lib/poise_boiler/helpers/kitchen.rb +3 -1
- data/lib/poise_boiler/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: decb85a1657b0c1c205af3a06f5230e560ebd263
|
4
|
+
data.tar.gz: f1779ebb60dce5312bbe7e6acc0b04888ef752fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7592335dce58c6705c6e563ab94f83e5d39bb328dae8bbf93999af6364b89ecbb88056a553e447b348b56d89ed7c6f3997a45c7d2707d7ed919bd601e284fb82
|
7
|
+
data.tar.gz: d3a1c25c7071428b36971465a31a76a1949ecb839e48824348532c2c9bfd849de1a391bd9123a08149ddd7c8885b4cae42a51cf8b6a83611ec16973468d6f4e1
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'poise_boiler/helpers/kitchen/policy_provisioner'
|
18
|
+
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
module Kitchen
|
22
|
+
module Provisioner
|
23
|
+
# An alias for Kitchen plugin loading.
|
24
|
+
PoisePolicyfileZero = PoiseBoiler::Helpers::Kitchen::PolicyProvisioner
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
# From chef-dk.
|
20
|
+
require 'kitchen/provisioner/policyfile_zero'
|
21
|
+
require 'mixlib/shellout'
|
22
|
+
|
23
|
+
require 'poise_boiler/helpers/kitchen/provisioner_helpers'
|
24
|
+
|
25
|
+
|
26
|
+
module PoiseBoiler
|
27
|
+
module Helpers
|
28
|
+
class Kitchen
|
29
|
+
class PolicyProvisioner < ::Kitchen::Provisioner::PolicyfileZero
|
30
|
+
include ProvisionerHelpers
|
31
|
+
|
32
|
+
# Override the default value from the base class.
|
33
|
+
# default_config :policyfile, '.kitchen/poise_policy.rb'
|
34
|
+
# expand_path_for :policyfile
|
35
|
+
|
36
|
+
def self.name
|
37
|
+
'PoisePolicyfileZero'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Run our policy generation first.
|
41
|
+
def create_sandbox
|
42
|
+
policy_base = File.join(config[:kitchen_root], '.kitchen', 'poise_policy')
|
43
|
+
# Copy all my halite-y stuff to a folder. This should probably use a
|
44
|
+
# temp dir instead.
|
45
|
+
FileUtils.rm_rf(policy_base)
|
46
|
+
convert_halite_cookbooks(policy_base) unless poise_helper_instance.options['no_gem']
|
47
|
+
copy_test_cookbook(policy_base)
|
48
|
+
copy_test_cookbooks(policy_base)
|
49
|
+
# Generate a modified policy to use the cookbooks we just made.
|
50
|
+
policy_path = generate_poise_policy(policy_base)
|
51
|
+
# Compile that policy because the base provider doesn't do that.
|
52
|
+
compile_poise_policy(policy_path)
|
53
|
+
# Tell the base provider code to use our new policy instead.
|
54
|
+
config[:policyfile] = policy_path
|
55
|
+
super
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def generate_poise_policy(base)
|
61
|
+
info("Preparing modified policy")
|
62
|
+
original_policy = IO.read(config[:policyfile])
|
63
|
+
new_policy = "default_source :chef_repo, #{base.inspect}\n#{original_policy}"
|
64
|
+
policy_path = File.join(config[:kitchen_root], '.kitchen', "poise_policy_#{instance.name}.rb")
|
65
|
+
IO.write(policy_path, new_policy)
|
66
|
+
policy_path
|
67
|
+
end
|
68
|
+
|
69
|
+
def compile_poise_policy(policy_path)
|
70
|
+
info("Compiling policy")
|
71
|
+
compile_cmd = Mixlib::ShellOut.new(['chef', 'update', policy_path])
|
72
|
+
compile_cmd.run_command
|
73
|
+
compile_cmd.error!
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -14,18 +14,18 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require 'fileutils'
|
18
|
-
|
19
|
-
require 'halite'
|
20
17
|
require 'kitchen/provisioner/chef_solo'
|
21
18
|
|
22
19
|
require 'poise_boiler/helpers/kitchen/core_ext'
|
20
|
+
require 'poise_boiler/helpers/kitchen/provisioner_helpers'
|
23
21
|
|
24
22
|
|
25
23
|
module PoiseBoiler
|
26
24
|
module Helpers
|
27
25
|
class Kitchen
|
28
26
|
class Provisioner < ::Kitchen::Provisioner::ChefSolo
|
27
|
+
include ProvisionerHelpers
|
28
|
+
|
29
29
|
default_config :gemspec do |provisioner|
|
30
30
|
Dir[File.join(provisioner[:kitchen_root], '*.gemspec')].first
|
31
31
|
end
|
@@ -37,62 +37,9 @@ module PoiseBoiler
|
|
37
37
|
|
38
38
|
def create_sandbox
|
39
39
|
super
|
40
|
-
convert_halite_cookbooks unless poise_helper_instance.options['no_gem']
|
41
|
-
copy_test_cookbook
|
42
|
-
copy_test_cookbooks
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def poise_helper_instance
|
48
|
-
PoiseBoiler::Kitchen.instance || begin
|
49
|
-
raise 'Global poise-boiler kitchen instance not set'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def convert_halite_cookbooks
|
54
|
-
@real_cookbook_deps = {}
|
55
|
-
gems_to_convert = {'poise-profiler' => Halite::Gem.new('poise-profiler')}
|
56
|
-
gems_to_check = [poise_helper_instance.cookbook]
|
57
|
-
until gems_to_check.empty?
|
58
|
-
check = gems_to_check.pop
|
59
|
-
# Already in the list, skip expansion.
|
60
|
-
next if gems_to_convert.include?(check.name)
|
61
|
-
# Not a cookbook, don't expand.
|
62
|
-
next unless check.is_halite_cookbook?
|
63
|
-
gems_to_convert[check.name] = check
|
64
|
-
# Expand dependencies and check each of those.
|
65
|
-
check.cookbook_dependencies.each do |dep|
|
66
|
-
dep_cook = dep.cookbook
|
67
|
-
if dep_cook
|
68
|
-
gems_to_check << dep_cook
|
69
|
-
else
|
70
|
-
@real_cookbook_deps[dep.name] = dep
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
# Convert all the things!
|
75
|
-
tmpbooks_dir = File.join(sandbox_path, 'cookbooks')
|
76
|
-
FileUtils.mkdir_p(tmpbooks_dir)
|
77
|
-
gems_to_convert.each do |name, gem_data|
|
78
|
-
Halite.convert(gem_data, File.join(tmpbooks_dir, gem_data.cookbook_name))
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def copy_test_cookbook
|
83
|
-
fixture_base = File.join(config[:kitchen_root], 'test', 'cookbook')
|
84
|
-
return unless File.exist?(File.join(fixture_base, 'metadata.rb'))
|
85
|
-
tmp_base = File.join(sandbox_path, 'cookbooks', "#{poise_helper_instance.cookbook_name}_test")
|
86
|
-
FileUtils.mkdir_p(tmp_base)
|
87
|
-
FileUtils.cp_r(File.join(fixture_base, "."), tmp_base)
|
88
|
-
end
|
89
|
-
|
90
|
-
def copy_test_cookbooks
|
91
|
-
fixtures_base = File.join(config[:kitchen_root], 'test', 'cookbooks')
|
92
|
-
return unless File.exist?(fixtures_base)
|
93
|
-
tmp_base = File.join(sandbox_path, 'cookbooks')
|
94
|
-
FileUtils.mkdir_p(tmp_base)
|
95
|
-
FileUtils.cp_r(File.join(fixtures_base, "."), tmp_base)
|
40
|
+
convert_halite_cookbooks(sandbox_path) unless poise_helper_instance.options['no_gem']
|
41
|
+
copy_test_cookbook(sandbox_path)
|
42
|
+
copy_test_cookbooks(sandbox_path)
|
96
43
|
end
|
97
44
|
|
98
45
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
require 'halite'
|
20
|
+
|
21
|
+
|
22
|
+
module PoiseBoiler
|
23
|
+
module Helpers
|
24
|
+
class Kitchen
|
25
|
+
# Helper methods for the two TK provisioners.
|
26
|
+
module ProvisionerHelpers
|
27
|
+
private
|
28
|
+
|
29
|
+
def poise_helper_instance
|
30
|
+
PoiseBoiler::Kitchen.instance || begin
|
31
|
+
raise 'Global poise-boiler kitchen instance not set'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def convert_halite_cookbooks(dest)
|
36
|
+
@real_cookbook_deps = {}
|
37
|
+
gems_to_convert = {'poise-profiler' => Halite::Gem.new('poise-profiler')}
|
38
|
+
gems_to_check = [poise_helper_instance.cookbook]
|
39
|
+
until gems_to_check.empty?
|
40
|
+
check = gems_to_check.pop
|
41
|
+
# Already in the list, skip expansion.
|
42
|
+
next if gems_to_convert.include?(check.name)
|
43
|
+
# Not a cookbook, don't expand.
|
44
|
+
next unless check.is_halite_cookbook?
|
45
|
+
gems_to_convert[check.name] = check
|
46
|
+
# Expand dependencies and check each of those.
|
47
|
+
check.cookbook_dependencies.each do |dep|
|
48
|
+
dep_cook = dep.cookbook
|
49
|
+
if dep_cook
|
50
|
+
gems_to_check << dep_cook
|
51
|
+
else
|
52
|
+
@real_cookbook_deps[dep.name] = dep
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
# Convert all the things!
|
57
|
+
tmpbooks_dir = File.join(dest, 'cookbooks')
|
58
|
+
FileUtils.mkdir_p(tmpbooks_dir)
|
59
|
+
gems_to_convert.each do |name, gem_data|
|
60
|
+
Halite.convert(gem_data, File.join(tmpbooks_dir, gem_data.cookbook_name))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def copy_test_cookbook(dest)
|
65
|
+
fixture_base = File.join(config[:kitchen_root], 'test', 'cookbook')
|
66
|
+
return unless File.exist?(File.join(fixture_base, 'metadata.rb'))
|
67
|
+
tmp_base = File.join(dest, 'cookbooks', "#{poise_helper_instance.cookbook_name}_test")
|
68
|
+
FileUtils.mkdir_p(tmp_base)
|
69
|
+
FileUtils.cp_r(File.join(fixture_base, "."), tmp_base)
|
70
|
+
end
|
71
|
+
|
72
|
+
def copy_test_cookbooks(dest)
|
73
|
+
fixtures_base = File.join(config[:kitchen_root], 'test', 'cookbooks')
|
74
|
+
return unless File.exist?(fixtures_base)
|
75
|
+
tmp_base = File.join(dest, 'cookbooks')
|
76
|
+
FileUtils.mkdir_p(tmp_base)
|
77
|
+
FileUtils.cp_r(File.join(fixtures_base, "."), tmp_base)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -178,8 +178,10 @@ module PoiseBoiler
|
|
178
178
|
'log_level' => (ENV['DEBUG'] ? 'debug' : (ENV['CHEF_LOG_LEVEL'] || 'auto')),
|
179
179
|
# Use the poise_solo provisioner, also part of kitchen-docker.
|
180
180
|
'name' => 'poise_solo',
|
181
|
-
# Pass through debug/poise_debug settings to the test instance.
|
182
181
|
'attributes' => {
|
182
|
+
# Pass through $CI to know if we are on Travis.
|
183
|
+
'CI' => ENV['CI'],
|
184
|
+
# Pass through debug/poise_debug settings to the test instance.
|
183
185
|
'POISE_DEBUG' => !!((ENV['POISE_DEBUG'] && ENV['POISE_DEBUG'] != 'false') ||
|
184
186
|
(ENV['poise_debug'] && ENV['poise_debug'] != 'false') ||
|
185
187
|
(ENV['DEBUG'] && ENV['DEBUG'] != 'false')
|
data/lib/poise_boiler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poise-boiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Kantrowitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -462,6 +462,7 @@ files:
|
|
462
462
|
- Rakefile
|
463
463
|
- gemfiles/default.gemfile
|
464
464
|
- gemfiles/master.gemfile
|
465
|
+
- lib/kitchen/provisioner/poise_policyfile_zero.rb
|
465
466
|
- lib/kitchen/provisioner/poise_solo.rb
|
466
467
|
- lib/poise-boiler.rb
|
467
468
|
- lib/poise_boiler.rb
|
@@ -470,7 +471,9 @@ files:
|
|
470
471
|
- lib/poise_boiler/helpers/kitchen.rb
|
471
472
|
- lib/poise_boiler/helpers/kitchen/Dockerfile.erb
|
472
473
|
- lib/poise_boiler/helpers/kitchen/core_ext.rb
|
474
|
+
- lib/poise_boiler/helpers/kitchen/policy_provisioner.rb
|
473
475
|
- lib/poise_boiler/helpers/kitchen/provisioner.rb
|
476
|
+
- lib/poise_boiler/helpers/kitchen/provisioner_helpers.rb
|
474
477
|
- lib/poise_boiler/helpers/rake.rb
|
475
478
|
- lib/poise_boiler/helpers/rake/badges.rb
|
476
479
|
- lib/poise_boiler/helpers/rake/bump.rb
|