kitchen-provisioner-local_shell 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/kitchen-provisioner-local_shell.gemspec +22 -0
- data/lib/kitchen/provisioner/local_shell.rb +86 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc2cfe099b3e874da27b1c3956074e8cdf60d8b7
|
4
|
+
data.tar.gz: 11f36fe5db31efbb7e8a84fc5b6b98a499bb7980
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63210a5cba48a7bf1c2308492884c41745c49958313284688ec046533b65dec330d72a2359414a14ebe75186bb08ee08de94ea138fbae4f78b88617034f8d5d3
|
7
|
+
data.tar.gz: d6576c75d206f16f75066694372d2dbaa1e74fb908414fa647e5ae099e97a16d04e1183be0b72cfb52daa0d0432f754cd5927084e0576ef60611f516f2ae7de8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (C) 2015, SAWANOBORI Yukihiko (<sawanoboriyu@higanworks.com>)
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Kitchen::Provisioner::LocalShell
|
2
|
+
|
3
|
+
A Test-Kitchen Provisioner that execute some command from localhost.
|
4
|
+
|
5
|
+
This provisioner is made in reference to Shell-Verifier.
|
6
|
+
https://github.com/higanworks/kitchen-verifier-shell
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'kitchen-provisioner-local_shell'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install kitchen-provisioner-local_shell
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Pass driver's state via env, such as KITCHEN_HOSTNAME, KITCHEN_PORT, KITCHEN_CONTAINER_ID, etc...
|
27
|
+
|
28
|
+
- .kitchen.yml
|
29
|
+
|
30
|
+
```yml
|
31
|
+
----
|
32
|
+
platforms:
|
33
|
+
- name: ubuntu-14.04
|
34
|
+
provisioner:
|
35
|
+
name: local_shell
|
36
|
+
command: ./bin/itamae docker recipes/default.rb --container=$KITCHEN_CONTAINER_ID
|
37
|
+
driver:
|
38
|
+
name: docker_cli
|
39
|
+
transport:
|
40
|
+
name: docker_cli
|
41
|
+
suites:
|
42
|
+
- name: example
|
43
|
+
run_list:
|
44
|
+
- recipes/default.rb
|
45
|
+
```
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it ( https://github.com/marcy-terui/kitchen-provisioner-local_shell/fork )
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
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-provisioner-local_shell"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Masashi Terui"]
|
9
|
+
spec.email = ["marcy9114@gmail.com"]
|
10
|
+
spec.summary = %q{A Test-Kitchen Provisioner that execute some command from localhost.}
|
11
|
+
spec.description = %q{A Test-Kitchen Provisioner that execute some command from localhost.}
|
12
|
+
spec.homepage = "https://github.com/marcy-terui/kitchen-provisioner-local_shell"
|
13
|
+
spec.license = "Apache 2.0"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Masashi Terui (<marcy9114@gmail.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/provisioner/base"
|
20
|
+
|
21
|
+
module Kitchen
|
22
|
+
|
23
|
+
module Provisioner
|
24
|
+
|
25
|
+
# LocalShell Provisoner for Kitchen. This provisoner just execute shell command from local.
|
26
|
+
# This provisioner is made in reference to Shell-Verifier
|
27
|
+
#
|
28
|
+
# @author Masashi Terui (<marcy9114@gmail.com>)
|
29
|
+
class LocalShell < Base
|
30
|
+
require "mixlib/shellout"
|
31
|
+
|
32
|
+
kitchen_provisioner_api_version 2
|
33
|
+
|
34
|
+
plugin_version Kitchen::VERSION
|
35
|
+
|
36
|
+
default_config :sleep, 0
|
37
|
+
default_config :command, "true"
|
38
|
+
default_config :shellout_opts, {}
|
39
|
+
default_config :live_stream, $stdout
|
40
|
+
|
41
|
+
# (see Base#call)
|
42
|
+
def call(state)
|
43
|
+
info("[#{name}] Provison on instance=#{instance} with state=#{state}")
|
44
|
+
sleep_if_set
|
45
|
+
merge_state_to_env(state)
|
46
|
+
shellout
|
47
|
+
debug("[#{name}] Provison completed.")
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Sleep for a period of time, if a value is set in the config.
|
53
|
+
#
|
54
|
+
# @api private
|
55
|
+
def sleep_if_set
|
56
|
+
config[:sleep].to_i.times do
|
57
|
+
print "."
|
58
|
+
sleep 1
|
59
|
+
end
|
60
|
+
puts
|
61
|
+
end
|
62
|
+
|
63
|
+
def shellout
|
64
|
+
cmd = Mixlib::ShellOut.new(config[:command], config[:shellout_opts])
|
65
|
+
cmd.live_stream = config[:live_stream]
|
66
|
+
cmd.run_command
|
67
|
+
begin
|
68
|
+
cmd.error!
|
69
|
+
rescue Mixlib::ShellOut::ShellCommandFailed
|
70
|
+
raise ActionFailed, "Action #provision failed for #{instance.to_str}."
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def merge_state_to_env(state)
|
75
|
+
env_state = { :environment => {} }
|
76
|
+
env_state[:environment]["KITCHEN_INSTANCE"] = instance.name
|
77
|
+
env_state[:environment]["KITCHEN_PLATFORM"] = instance.platform.name
|
78
|
+
env_state[:environment]["KITCHEN_SUITE"] = instance.suite.name
|
79
|
+
state.each_pair do |key, value|
|
80
|
+
env_state[:environment]["KITCHEN_" + key.to_s.upcase] = value
|
81
|
+
end
|
82
|
+
config[:shellout_opts].merge!(env_state)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kitchen-provisioner-local_shell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masashi Terui
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A Test-Kitchen Provisioner that execute some command from localhost.
|
42
|
+
email:
|
43
|
+
- marcy9114@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- kitchen-provisioner-local_shell.gemspec
|
54
|
+
- lib/kitchen/provisioner/local_shell.rb
|
55
|
+
homepage: https://github.com/marcy-terui/kitchen-provisioner-local_shell
|
56
|
+
licenses:
|
57
|
+
- Apache 2.0
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.2.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: A Test-Kitchen Provisioner that execute some command from localhost.
|
79
|
+
test_files: []
|