batali-tk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3feaae7e7ce0593e46593b8d5ec1196a44699675
4
+ data.tar.gz: 015a4fd509a6b3c386f277face996d8cbc06a3e8
5
+ SHA512:
6
+ metadata.gz: bbc6204b08764247ee74e3bada0962f14086c5a515f110ab99b951c2dffda9793d97e785c16e7f517fa3f63a4d2d7eb2d9a49685c1288a2361962df2d9994a6d
7
+ data.tar.gz: 47e962e8c64e7224abd04f255f1ecf4342e296d943ab41e39c3fa871bbf5d8a9aff65ab02fad3dda4bb8179318f5644fe6542d655f330ec6ae92ba59379c56a0
@@ -0,0 +1,2 @@
1
+ # v0.1.0
2
+ * Initial release
@@ -0,0 +1,25 @@
1
+ # Contributing
2
+
3
+ ## Branches
4
+
5
+ ### `master` branch
6
+
7
+ The master branch is the current stable released version.
8
+
9
+ ### `develop` branch
10
+
11
+ The develop branch is the current edge of development.
12
+
13
+ ## Pull requests
14
+
15
+ * https://github.com/hw-labs/batali-tk
16
+
17
+ Please base all pull requests of the `develop` branch. Merges to
18
+ `master` only occur through the `develop` branch. Pull requests
19
+ based on `master` will likely be cherry picked.
20
+
21
+ ## Issues
22
+
23
+ Need to report an issue? Use the github issues:
24
+
25
+ * https://github.com/hw-labs/batali-tk
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2015 Chris Roberts
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,24 @@
1
+ # Batali TK
2
+
3
+ Batali for test-kitchen!
4
+
5
+ ## Usage
6
+
7
+ Batali support must be injected into test-kitchen. This is done by using
8
+ a wrapper command. Instead of calling kitchen directly:
9
+
10
+ ```
11
+ $ kitchen --help
12
+ ```
13
+
14
+ use the wrapper command:
15
+
16
+ ```
17
+ $ batali-tk --help
18
+ ```
19
+
20
+ This will hopefully not be needed for future versions of test kitchen.
21
+
22
+ # Info
23
+
24
+ * Repository: https://github.com/hw-labs/batali-tk
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
2
+ require 'batali-tk/version'
3
+ Gem::Specification.new do |s|
4
+ s.name = 'batali-tk'
5
+ s.version = BataliTk::VERSION.version
6
+ s.summary = 'Batali for test-kitchen'
7
+ s.author = 'Chris Roberts'
8
+ s.email = 'code@chrisroberts.org'
9
+ s.homepage = 'https://github.com/hw-labs/batali-tk'
10
+ s.description = 'Batali support injector for test kitchen'
11
+ s.require_path = 'lib'
12
+ s.license = 'Apache 2.0'
13
+ s.add_runtime_dependency 'batali', '>= 0.1.20', '< 1'
14
+ s.add_runtime_dependency 'test-kitchen', BataliTk::TK_CONSTRAINT
15
+ s.executables << 'batali-tk'
16
+ s.files = Dir['{lib,bin}/**/**/*'] + %w(batali-tk.gemspec README.md CHANGELOG.md CONTRIBUTING.md LICENSE)
17
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+
5
+ # Force `kitchen` name so we don't end up with batali-tk branding
6
+ require 'thor'
7
+
8
+ module Thor::Base::ClassMethods
9
+ def basename
10
+ 'kitchen'
11
+ end
12
+ end
13
+
14
+ require 'batali-tk'
15
+ require 'kitchen'
16
+ require 'kitchen/cli'
17
+ require 'kitchen/errors'
18
+
19
+
20
+ Kitchen.with_friendly_errors { Kitchen::CLI.start }
@@ -0,0 +1,4 @@
1
+ require 'batali-tk/version'
2
+ require 'kitchen'
3
+ require 'batali-tk/monkey'
4
+ require 'batali-tk/provisioner'
@@ -0,0 +1,86 @@
1
+ # Lets hook in batali support!
2
+ module BataliTk
3
+ module Box
4
+
5
+ def batali_file
6
+ File.join(config[:kitchen_root], "Batali")
7
+ end
8
+
9
+ def batali_prepare_cookbooks
10
+ if(File.exists?(batali_file))
11
+ resolve_with_batali
12
+ filter_only_cookbook_files
13
+ else
14
+ tk_prepare_cookbooks
15
+ end
16
+ end
17
+
18
+ def resolve_with_batali
19
+ Kitchen.mutex.synchronize do
20
+ Kitchen::Provisioner::Chef::Batali.new(batali_file, tmpbooks_dir, logger).resolve
21
+ end
22
+ end
23
+
24
+ class << self
25
+
26
+ def included(klass)
27
+ klass.class_eval do
28
+ alias_method :tk_prepare_cookbooks, :prepare_cookbooks
29
+ alias_method :prepare_cookbooks, :batali_prepare_cookbooks
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ module Base
38
+
39
+ def batali_file
40
+ File.join(config[:kitchen_root], "Batali")
41
+ end
42
+
43
+ def batali_load_needed_dependencies!
44
+ if(File.exists?(batali_file))
45
+ debug "Batali file found at #{batali_file}, loading Batali"
46
+ Kitchen::Provisioner::Chef::Batali.load!(logger)
47
+ else
48
+ tk_load_needed_dependencies!
49
+ end
50
+ end
51
+
52
+ class << self
53
+
54
+ def included(klass)
55
+ klass.class_eval do
56
+ alias_method :tk_load_needed_dependencies!, :load_needed_dependencies!
57
+ alias_method :load_needed_dependencies!, :batali_load_needed_dependencies!
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+ require 'kitchen/provisioner/base'
67
+ require 'kitchen/provisioner/chef_base'
68
+
69
+ begin
70
+ require 'kitchen/provisioner/chef/common_sandbox'
71
+
72
+ class Kitchen::Provisioner::ChefBase
73
+ include BataliTk::Base
74
+ end
75
+
76
+ class Kitchen::Provisioner::Chef::CommonSandbox
77
+ include BataliTk::Box
78
+ end
79
+ rescue LoadError
80
+
81
+ class Kitchen::Provisioner::ChefBase
82
+ include BataliTk::Base
83
+ include BataliTk::Box
84
+ end
85
+
86
+ end
@@ -0,0 +1,72 @@
1
+ require 'batali-tk'
2
+ require 'kitchen/provisioner'
3
+ require 'kitchen/provisioner/chef_base'
4
+ require 'kitchen/errors'
5
+ require 'kitchen/logging'
6
+
7
+ module Kitchen
8
+ module Provisioner
9
+ module Chef
10
+ # Chef cookbook resolver using Batali to calculate dependencies
11
+ class Batali
12
+
13
+ include Logging
14
+
15
+ class << self
16
+
17
+ # Load Batali
18
+ #
19
+ # @param logger [Logger]
20
+ def load!(logger=Kitchen.logger)
21
+ begin
22
+ require 'batali'
23
+ require 'stringio'
24
+ rescue LoadError => error
25
+ logger.fatal("Failed to load the `batali` gem! (#{e.class}: #{e})")
26
+ raise UserError.new "Failed to load the `batali` gem! (#{e.class}: #{e}"
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ # @return [Batali::BFile]
33
+ attr_reader :batali_file
34
+ # @return [String] path to vendor cookbooks
35
+ attr_reader :vendor_path
36
+ # @return [Logger]
37
+ attr_reader :logger
38
+
39
+ def initialize(b_file, path, logger=Kitchen.logger)
40
+ @batali_file = b_file
41
+ @vendor_path = path
42
+ @logger = logger
43
+ end
44
+
45
+ # Resolve cookbooks and install into vendor location
46
+ def resolve
47
+ info "Resolving cookbook dependencies with Batali #{::Batali::VERSION}..."
48
+ debug "Using Batail file located at: #{batali_file}"
49
+ output = ''
50
+ begin
51
+ ::Batali::Command::Update.new(
52
+ Smash.new(
53
+ :file => batali_file,
54
+ :path => vendor_path,
55
+ :ui => Bogo::Ui.new(
56
+ :app_name => 'Batali',
57
+ :output_to => StringIO.new(output)
58
+ ),
59
+ ),
60
+ []
61
+ ).execute!
62
+ rescue => e
63
+ error "Batali failed to install cookbooks! #{e.class}: #{e}"
64
+ debug output
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,6 @@
1
+ module BataliTk
2
+ # Library version
3
+ VERSION = Gem::Version.new('0.1.0')
4
+ # Constraint for test-kitchen dependency
5
+ TK_CONSTRAINT = '~> 1.3'
6
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: batali-tk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Roberts
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: batali
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.20
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.20
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: test-kitchen
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ description: Batali support injector for test kitchen
48
+ email: code@chrisroberts.org
49
+ executables:
50
+ - batali-tk
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - CHANGELOG.md
55
+ - CONTRIBUTING.md
56
+ - LICENSE
57
+ - README.md
58
+ - batali-tk.gemspec
59
+ - bin/batali-tk
60
+ - lib/batali-tk.rb
61
+ - lib/batali-tk/monkey.rb
62
+ - lib/batali-tk/provisioner.rb
63
+ - lib/batali-tk/version.rb
64
+ homepage: https://github.com/hw-labs/batali-tk
65
+ licenses:
66
+ - Apache 2.0
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.2.2
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Batali for test-kitchen
88
+ test_files: []
89
+ has_rdoc: