kitchen-verifier-shell 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: e64ce9e0a619699c906a79f9d8f53c7b22c6f8af
4
+ data.tar.gz: 88718b7acba241c6ac3d8b61e56c2c051e9aab2e
5
+ SHA512:
6
+ metadata.gz: 00f43d751aa2378507b257fffd8ed7076a4f89a187f683593d12874fa7b5bb771af5b8fb60957acb6f58b3768a042c6611b84b3a4b02075b17a5abc6e3c78d33
7
+ data.tar.gz: 623bfdd3e5eb2f1a0cd15e69c453d3a3a56ce31425d7db7b55f172e3398df6208277a795b7cf56e140b9f7aab7f0b975358f75c3b183ec8a761da08324dc48db
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /bin/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kitchen-verifier-shell.gemspec
4
+ gemspec
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
@@ -0,0 +1,9 @@
1
+ # Kitchen::Verifier::Shell
2
+
3
+ Usage => https://github.com/test-kitchen/test-kitchen/pull/741.
4
+
5
+
6
+ ## License
7
+
8
+ The gem is available as open source under the terms of the Apache2.
9
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "kitchen-verifier-shell"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["sawanoboly"]
9
+ spec.email = ["sawanoboriyu@higanworks.com"]
10
+
11
+ spec.summary = %q{Shell verifier for Test-Kitehen}
12
+ spec.description = %q{Shell verifier for Test-Kitehen}
13
+ spec.homepage = "https://github.com/test-kitchen/test-kitchen/pull/741"
14
+ spec.license = "Apache2"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "test-kitchen", "~> 1.4"
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,82 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: SAWANOBORI Yukihiko (<sawanoboriyu@higanworks.com>)
4
+ #
5
+ # Copyright (C) 2015, HiganWorks LLC
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require "kitchen/verifier/base"
20
+
21
+ module Kitchen
22
+
23
+ module Verifier
24
+
25
+ # Shell verifier for Kitchen. This verifier just execute shell command from local.
26
+ #
27
+ # @author SAWANOBORI Yukihiko (<sawanoboriyu@higanworks.com>)
28
+ class Shell < Kitchen::Verifier::Base
29
+ require "mixlib/shellout"
30
+
31
+ kitchen_verifier_api_version 1
32
+
33
+ plugin_version Kitchen::VERSION
34
+
35
+ default_config :sleep, 0
36
+ default_config :command, "true"
37
+ default_config :shellout_opts, {}
38
+ default_config :live_stream, $stdout
39
+
40
+ # (see Base#call)
41
+ def call(state)
42
+ info("[#{name}] Verify on instance=#{instance} with state=#{state}")
43
+ sleep_if_set
44
+ merge_state_to_env(state)
45
+ shellout
46
+ debug("[#{name}] Verify completed.")
47
+ end
48
+
49
+ private
50
+
51
+ # Sleep for a period of time, if a value is set in the config.
52
+ #
53
+ # @api private
54
+ def sleep_if_set
55
+ config[:sleep].to_i.times do
56
+ print "."
57
+ sleep 1
58
+ end
59
+ puts
60
+ end
61
+
62
+ def shellout
63
+ cmd = Mixlib::ShellOut.new(config[:command], config[:shellout_opts])
64
+ cmd.live_stream = config[:live_stream]
65
+ cmd.run_command
66
+ begin
67
+ cmd.error!
68
+ rescue Mixlib::ShellOut::ShellCommandFailed
69
+ raise ActionFailed, "Action #verify failed for #{instance.to_str}."
70
+ end
71
+ end
72
+
73
+ def merge_state_to_env(state)
74
+ env_state = { :environment => {} }
75
+ state.each_pair do |key, value|
76
+ env_state[:environment]["KITCHEN_" + key.to_s.upcase] = value
77
+ end
78
+ config[:shellout_opts].merge!(env_state)
79
+ end
80
+ end
81
+ end
82
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-verifier-shell
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sawanoboly
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: test-kitchen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Shell verifier for Test-Kitehen
56
+ email:
57
+ - sawanoboriyu@higanworks.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - kitchen-verifier-shell.gemspec
68
+ - lib/kitchen/verifier/shell.rb
69
+ homepage: https://github.com/test-kitchen/test-kitchen/pull/741
70
+ licenses:
71
+ - Apache2
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.6
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Shell verifier for Test-Kitehen
93
+ test_files: []
94
+ has_rdoc: