kitchen-shopify-provisioner 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d06def47fb4d58f6f8cfa8205998c93548e55087
4
+ data.tar.gz: c218f81e545d5de917fde485bce4d4c6653cfd99
5
+ SHA512:
6
+ metadata.gz: a936ba9d5720b015098103d4116aca1dfcfd9d0382ff66748ab4b4df9ca83fb58c19ead7191adece4a0f2ecedbab33725d22d6695ecad51bece8fd64e798444e
7
+ data.tar.gz: e33b72e96309362c64146eee23a48df51a3c2321714e51b5959c0d2b8acf1dc290911382e6643ac7922e263d62282e905e01a90ad26a5318446f7e947a5299a5
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ tmp
3
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ install: bundle install
6
+ script: rspec
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 David Genord II
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # kitchen-shopify-provisioner
2
+ Shopify quirks for test kitchen
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
8
+ rescue LoadError
9
+ puts 'no rspec available'
10
+ end
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'kitchen-shopify-provisioner/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'kitchen-shopify-provisioner'
7
+ s.version = KitchenShopifyProvisioner::VERSION
8
+ s.license = 'MIT'
9
+ s.authors = ['Dale Hamel']
10
+ s.email = ['dale.hamel@shopify.com']
11
+
12
+ s.summary = 'Work around Shopify specific cookbook quirks'
13
+ s.description = s.summary
14
+ s.homepage = 'https://github.com/shopify/kitchen-shopify-provisioner'
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.test_files = s.files.grep(%r{spec})
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_runtime_dependency 'chef', ['~> 12']
21
+ s.add_runtime_dependency 'test-kitchen', ['~> 1.9']
22
+ s.add_development_dependency 'rspec', ['~> 3.4']
23
+ s.add_development_dependency 'rake', ['~> 10.4']
24
+ end
@@ -0,0 +1,3 @@
1
+ module KitchenShopifyProvisioner
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,69 @@
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
@@ -0,0 +1,9 @@
1
+ RSpec.configure do |config|
2
+ config.order = "random"
3
+ config.expect_with(:rspec) {|c| c.syntax = :expect }
4
+ end
5
+
6
+ class BogusInstance
7
+ def logger
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-shopify-provisioner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dale Hamel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-kitchen
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.4'
69
+ description: Work around Shopify specific cookbook quirks
70
+ email:
71
+ - dale.hamel@shopify.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - kitchen-shopify-provisioner.gemspec
83
+ - lib/kitchen-shopify-provisioner/version.rb
84
+ - lib/kitchen/provisioner/shopify_chef_zero.rb
85
+ - spec/spec_helper.rb
86
+ homepage: https://github.com/shopify/kitchen-shopify-provisioner
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.8
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Work around Shopify specific cookbook quirks
110
+ test_files:
111
+ - kitchen-shopify-provisioner.gemspec
112
+ - spec/spec_helper.rb