kitchen-shopify-provisioner 0.0.1 → 0.0.2
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/.travis.yml +1 -2
- data/LICENSE.txt +0 -2
- data/lib/kitchen-shopify-provisioner/version.rb +1 -1
- data/lib/kitchen/provisioner/chef_zero_shopify.rb +31 -0
- metadata +2 -2
- data/lib/kitchen/provisioner/shopify_chef_zero.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1c921b079b138dfbd9c71d0ae83fdacadc1fb3
|
4
|
+
data.tar.gz: 866f35bb98f1515c2a5df128af9bfe868309d322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc5adf47ae3d103bcdf558d54649a86ccd94e1462bdca99f8cac2c220515dc614bc189b654f478bce4cc5084549081d225adf287a93750696450426b7783f03a
|
7
|
+
data.tar.gz: 5107dcf1a8363d390021a11eca386ece03f9f00033421bdabc3d7d4ae737d25c55ffd66ad05efbcb33df488780938ee11d05203ac4f0be3835262eaa2894b5b9
|
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'kitchen/provisioner/chef_zero'
|
2
|
+
require 'chef-config/config'
|
3
|
+
require 'chef/role'
|
4
|
+
|
5
|
+
module Kitchen
|
6
|
+
module Provisioner
|
7
|
+
|
8
|
+
# This Provisioner combines the roles of the Apt, Ruby Roles, and ChefZero
|
9
|
+
# provisioners, to ensure a server is ready to run before ChefZero starts its magic
|
10
|
+
# Must be named "Chef..." otherwise TestKitchen won't understand that we intend to use chef
|
11
|
+
class ChefZeroShopify < ChefZero
|
12
|
+
def create_sandbox
|
13
|
+
tmpdir = Dir.mktmpdir
|
14
|
+
|
15
|
+
at_exit do
|
16
|
+
FileUtils.rm_rf(tmpdir)
|
17
|
+
end
|
18
|
+
|
19
|
+
Dir.glob(File.join(config[:roles_path], '**', '*.rb')).each do |rb_file|
|
20
|
+
obj = ::Chef::Role.new
|
21
|
+
obj.from_file(rb_file)
|
22
|
+
json_file = rb_file.sub(/\.rb$/, '.json').gsub(config[:roles_path], '').sub(/^\//, '').split('/').join('--')
|
23
|
+
File.write(File.join(tmpdir, json_file), ::Chef::JSONCompat.to_json_pretty(obj))
|
24
|
+
end
|
25
|
+
|
26
|
+
config[:roles_path] = tmpdir
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-shopify-provisioner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Hamel
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- kitchen-shopify-provisioner.gemspec
|
83
83
|
- lib/kitchen-shopify-provisioner/version.rb
|
84
|
-
- lib/kitchen/provisioner/
|
84
|
+
- lib/kitchen/provisioner/chef_zero_shopify.rb
|
85
85
|
- spec/spec_helper.rb
|
86
86
|
homepage: https://github.com/shopify/kitchen-shopify-provisioner
|
87
87
|
licenses:
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'find'
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
require 'chef/role'
|
6
|
-
require 'kitchen/provisioner/chef_zero'
|
7
|
-
|
8
|
-
module Kitchen
|
9
|
-
module Provisioner
|
10
|
-
|
11
|
-
# We'll sneak some code in before the default chef zero provisioner runs
|
12
|
-
# This will allow us to convert our roles to JSON, and flatten at once
|
13
|
-
class ShopifyChefZero < ChefZero
|
14
|
-
|
15
|
-
# Wedge our 'inject_roles' logic in between the other create_sandbox logic in the inheritance hierarchy
|
16
|
-
# This kind of monkey patching isn't fool proof: if ChefBase or ChefZero change the logic of their
|
17
|
-
# create_sandbox functions, those changes must be reflected here. We cannot simply call them, as
|
18
|
-
# they will try to call super, which we can't tolerate.
|
19
|
-
def create_sandbox
|
20
|
-
base_sandbox
|
21
|
-
inject_roles
|
22
|
-
chefbase_sandbox
|
23
|
-
chefzero_sandbox
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
# If the implementation of Base#create_sandbox changes, copy and paste the code here
|
29
|
-
def base_sandbox
|
30
|
-
Kitchen::Provisioner::Base.instance_method(:create_sandbox).bind(self).call
|
31
|
-
end
|
32
|
-
|
33
|
-
# If the implementation of ChefBase#create_sandbox changes, copy and paste the code here
|
34
|
-
def chefbase_sandbox
|
35
|
-
sanity_check_sandbox_options!
|
36
|
-
Chef::CommonSandbox.new(config, sandbox_path, instance).populate
|
37
|
-
end
|
38
|
-
|
39
|
-
# If the implementation of ChefZero#create_sandbox changes, copy and paste the code here
|
40
|
-
def chefzero_sandbox
|
41
|
-
send(:prepare_chef_client_zero_rb)
|
42
|
-
send(:prepare_validation_pem)
|
43
|
-
send(:prepare_client_rb)
|
44
|
-
end
|
45
|
-
|
46
|
-
def inject_roles
|
47
|
-
tmpdir = Dir.mktmpdir('chef-flattened-roles')
|
48
|
-
|
49
|
-
at_exit do
|
50
|
-
FileUtils.rm_rf(tmpdir)
|
51
|
-
end
|
52
|
-
|
53
|
-
roles_path = config[:roles_path] || remote_path_join(config[:root_path], "roles")
|
54
|
-
roles = []
|
55
|
-
Find.find(roles_path) { |f| roles << f if f =~ /\.rb$/ }
|
56
|
-
|
57
|
-
roles.each do |rb_file|
|
58
|
-
obj = ::Chef::Role.new
|
59
|
-
obj.from_file(rb_file)
|
60
|
-
json_file = rb_file.sub(/\.rb$/, '.json').gsub(roles_path, '').split('/').select { |x| x unless x.empty? }.join('--')
|
61
|
-
|
62
|
-
File.write(File.join(tmpdir, json_file), ::Chef::JSONCompat.to_json_pretty(obj))
|
63
|
-
end
|
64
|
-
|
65
|
-
config[:roles_path] = tmpdir
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|