test-kitchen 1.18.0 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -0
- data/ECOSYSTEM.md +6 -5
- data/lib/kitchen/cli.rb +24 -53
- data/lib/kitchen/command/doctor.rb +40 -0
- data/lib/kitchen/config.rb +6 -0
- data/lib/kitchen/configurable.rb +1 -1
- data/lib/kitchen/data_munger.rb +2 -0
- data/lib/kitchen/driver/base.rb +26 -1
- data/lib/kitchen/driver/dummy.rb +1 -0
- data/lib/kitchen/driver/exec.rb +71 -0
- data/lib/kitchen/driver/proxy.rb +2 -1
- data/lib/kitchen/instance.rb +13 -4
- data/lib/kitchen/provisioner/base.rb +8 -0
- data/lib/kitchen/provisioner/chef_base.rb +3 -1
- data/lib/kitchen/provisioner/shell.rb +21 -23
- data/lib/kitchen/transport/base.rb +8 -0
- data/lib/kitchen/transport/exec.rb +59 -0
- data/lib/kitchen/verifier/base.rb +8 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/config_spec.rb +13 -0
- data/spec/kitchen/driver/base_spec.rb +18 -0
- data/spec/kitchen/driver/exec_spec.rb +75 -0
- data/spec/kitchen/provisioner/chef_base_spec.rb +9 -0
- data/spec/kitchen/provisioner/chef_solo_spec.rb +1 -1
- data/spec/kitchen/provisioner/chef_zero_spec.rb +1 -1
- data/spec/kitchen/provisioner/shell_spec.rb +22 -20
- data/spec/kitchen/ssh_spec.rb +0 -29
- data/spec/kitchen/transport/exec_spec.rb +79 -0
- data/spec/kitchen/transport/ssh_spec.rb +0 -29
- data/spec/spec_helper.rb +26 -0
- data/support/busser_install_command.sh +10 -3
- metadata +9 -8
- data/features/kitchen_driver_create_command.feature +0 -64
- data/features/kitchen_driver_discover_command.feature +0 -25
- data/lib/kitchen/command/driver_discover.rb +0 -102
- data/lib/kitchen/generator/driver_create.rb +0 -174
@@ -1,174 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2013, Fletcher Nichol
|
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 "thor/group"
|
20
|
-
require "thor/util"
|
21
|
-
|
22
|
-
module Kitchen
|
23
|
-
module Generator
|
24
|
-
# A generator to create a new Kitchen Driver gem project.
|
25
|
-
#
|
26
|
-
# @author Fletcher Nichol <fnichol@nichol.ca>
|
27
|
-
class DriverCreate < Thor::Group
|
28
|
-
include Thor::Actions
|
29
|
-
|
30
|
-
argument :name, type: :string
|
31
|
-
|
32
|
-
class_option :license,
|
33
|
-
aliases: "-l",
|
34
|
-
default: "apachev2",
|
35
|
-
desc: "License type for gem (apachev2, mit, lgplv3, reserved)"
|
36
|
-
|
37
|
-
# Invoke the command.
|
38
|
-
def create
|
39
|
-
self.class.source_root(Kitchen.source_root.join("templates", "driver"))
|
40
|
-
|
41
|
-
create_core_files
|
42
|
-
create_source_files
|
43
|
-
initialize_git
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# Creates top-level project files.
|
49
|
-
#
|
50
|
-
# @api private
|
51
|
-
def create_core_files
|
52
|
-
empty_directory(target_dir)
|
53
|
-
|
54
|
-
create_template("CHANGELOG.md.erb", "CHANGELOG.md")
|
55
|
-
create_template("Gemfile.erb", "Gemfile")
|
56
|
-
create_template("Rakefile.erb", "Rakefile")
|
57
|
-
create_template("README.md.erb", "README.md")
|
58
|
-
create_template("gemspec.erb", "#{config[:gem_name]}.gemspec")
|
59
|
-
create_template("license_#{config[:license]}.erb", license_filename)
|
60
|
-
create_template("gitignore.erb", ".gitignore")
|
61
|
-
create_template("tailor.erb", ".tailor")
|
62
|
-
create_template("travis.yml.erb", ".travis.yml")
|
63
|
-
create_file(File.join(target_dir, ".cane"))
|
64
|
-
end
|
65
|
-
|
66
|
-
# Creates source code files.
|
67
|
-
#
|
68
|
-
# @api private
|
69
|
-
def create_source_files
|
70
|
-
empty_directory(File.join(target_dir, "lib/kitchen/driver"))
|
71
|
-
|
72
|
-
create_template(
|
73
|
-
"version.rb.erb",
|
74
|
-
"lib/kitchen/driver/#{name}_version.rb"
|
75
|
-
)
|
76
|
-
create_template(
|
77
|
-
"driver.rb.erb",
|
78
|
-
"lib/kitchen/driver/#{name}.rb"
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Initialize a git repository.
|
83
|
-
#
|
84
|
-
# @api private
|
85
|
-
def initialize_git
|
86
|
-
inside(target_dir) do
|
87
|
-
run("git init", capture: true)
|
88
|
-
run("git add .", capture: true)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# Render an ERb template to a destination file.
|
93
|
-
#
|
94
|
-
# @param erb [String] path to an ERb file
|
95
|
-
# @param dest [String] destination path for the rendered template
|
96
|
-
# @api private
|
97
|
-
def create_template(erb, dest)
|
98
|
-
template(erb, File.join(target_dir, dest), config)
|
99
|
-
end
|
100
|
-
|
101
|
-
# @return [String] the path to the gem skeleton project
|
102
|
-
# @api private
|
103
|
-
def target_dir
|
104
|
-
File.join(Dir.pwd, "kitchen-#{name}")
|
105
|
-
end
|
106
|
-
|
107
|
-
# @return [Hash] a configuration hash which can be used by templates as
|
108
|
-
# context
|
109
|
-
# @api private
|
110
|
-
def config
|
111
|
-
@config ||= {
|
112
|
-
name: name,
|
113
|
-
gem_name: "kitchen-#{name}",
|
114
|
-
gemspec: "kitchen-#{name}.gemspec",
|
115
|
-
klass_name: ::Thor::Util.camel_case(name),
|
116
|
-
constant_name: ::Thor::Util.snake_case(name).upcase,
|
117
|
-
author: author,
|
118
|
-
email: email,
|
119
|
-
license: options[:license],
|
120
|
-
license_string: license_string,
|
121
|
-
year: Time.now.year,
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
# @return [String] a default author name taken from git configuration if
|
126
|
-
# found
|
127
|
-
# @api private
|
128
|
-
def author
|
129
|
-
git_user_name = `git config user.name`.chomp
|
130
|
-
git_user_name.empty? ? "TODO: Write your name" : git_user_name
|
131
|
-
end
|
132
|
-
|
133
|
-
# @return [String] a default email address taken from git configuration
|
134
|
-
# if found
|
135
|
-
# @api private
|
136
|
-
def email
|
137
|
-
git_user_email = `git config user.email`.chomp
|
138
|
-
git_user_email.empty? ? "TODO: Write your email" : git_user_email
|
139
|
-
end
|
140
|
-
|
141
|
-
# @return [String] a rendered license string for a given license
|
142
|
-
# @api private
|
143
|
-
def license_string
|
144
|
-
case options[:license]
|
145
|
-
when "mit" then "MIT"
|
146
|
-
when "apachev2" then "Apache 2.0"
|
147
|
-
when "lgplv3" then "LGPL 3.0"
|
148
|
-
when "reserved" then "All rights reserved"
|
149
|
-
else
|
150
|
-
raise ArgumentError, "No such license #{options[:license]}"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# @return [String] the filename to use for the license file
|
155
|
-
# @api private
|
156
|
-
def license_filename
|
157
|
-
case options[:license]
|
158
|
-
when "mit" then "LICENSE.txt"
|
159
|
-
when "apachev2", "reserved" then "LICENSE"
|
160
|
-
when "lgplv3" then "COPYING"
|
161
|
-
else
|
162
|
-
raise ArgumentError, "No such license #{options[:license]}"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# @return [String] the license comment/preamble
|
167
|
-
# @api private
|
168
|
-
def license_comment
|
169
|
-
@license_comment ||= IO.read(File.join(target_dir, license_filename))
|
170
|
-
.gsub(/^/, "# ").gsub(/\s+$/, "")
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|