kitchen-shopify-provisioner 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d06def47fb4d58f6f8cfa8205998c93548e55087
4
- data.tar.gz: c218f81e545d5de917fde485bce4d4c6653cfd99
3
+ metadata.gz: da1c921b079b138dfbd9c71d0ae83fdacadc1fb3
4
+ data.tar.gz: 866f35bb98f1515c2a5df128af9bfe868309d322
5
5
  SHA512:
6
- metadata.gz: a936ba9d5720b015098103d4116aca1dfcfd9d0382ff66748ab4b4df9ca83fb58c19ead7191adece4a0f2ecedbab33725d22d6695ecad51bece8fd64e798444e
7
- data.tar.gz: e33b72e96309362c64146eee23a48df51a3c2321714e51b5959c0d2b8acf1dc290911382e6643ac7922e263d62282e905e01a90ad26a5318446f7e947a5299a5
6
+ metadata.gz: fc5adf47ae3d103bcdf558d54649a86ccd94e1462bdca99f8cac2c220515dc614bc189b654f478bce4cc5084549081d225adf287a93750696450426b7783f03a
7
+ data.tar.gz: 5107dcf1a8363d390021a11eca386ece03f9f00033421bdabc3d7d4ae737d25c55ffd66ad05efbcb33df488780938ee11d05203ac4f0be3835262eaa2894b5b9
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 1.9.3
3
+ - 2.2.0
5
4
  install: bundle install
6
5
  script: rspec
@@ -1,5 +1,3 @@
1
- Copyright (c) 2013 David Genord II
2
-
3
1
  MIT License
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
@@ -1,3 +1,3 @@
1
1
  module KitchenShopifyProvisioner
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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.1
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/shopify_chef_zero.rb
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