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
data/spec/kitchen/ssh_spec.rb
CHANGED
@@ -22,35 +22,6 @@ require "kitchen/ssh"
|
|
22
22
|
require "tmpdir"
|
23
23
|
require "net/ssh/test"
|
24
24
|
|
25
|
-
# Hack to sort results in `Dir.entries` only within the yielded block, to limit
|
26
|
-
# the "behavior pollution" to other code. This was needed for Net::SCP, as
|
27
|
-
# recursive directory upload doesn't sort the file and directory upload
|
28
|
-
# candidates which leads to different results based on the underlying
|
29
|
-
# filesystem (i.e. lexically sorted, inode insertion, mtime/atime, total
|
30
|
-
# randomness, etc.)
|
31
|
-
#
|
32
|
-
# See: https://github.com/net-ssh/net-scp/blob/a24948/lib/net/scp/upload.rb#L52
|
33
|
-
|
34
|
-
def with_sorted_dir_entries
|
35
|
-
Dir.class_exec do
|
36
|
-
class << self
|
37
|
-
alias_method :__entries__, :entries unless method_defined?(:__entries__)
|
38
|
-
|
39
|
-
def entries(*args) # rubocop:disable Lint/NestedMethodDefinition
|
40
|
-
send(:__entries__, *args).sort
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
yield
|
46
|
-
|
47
|
-
Dir.class_exec do
|
48
|
-
class << self
|
49
|
-
alias_method :entries, :__entries__
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
25
|
describe Kitchen::SSH do
|
55
26
|
include Net::SSH::Test
|
56
27
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
require_relative "../../spec_helper"
|
16
|
+
|
17
|
+
require "kitchen/transport/exec"
|
18
|
+
|
19
|
+
describe Kitchen::Transport::Ssh do
|
20
|
+
let(:logged_output) { StringIO.new }
|
21
|
+
let(:logger) { Logger.new(logged_output) }
|
22
|
+
let(:config) { Hash.new }
|
23
|
+
let(:state) { Hash.new }
|
24
|
+
|
25
|
+
let(:instance) do
|
26
|
+
stub(name: "coolbeans", logger: logger, to_str: "instance")
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:transport) do
|
30
|
+
Kitchen::Transport::Exec.new(config).finalize_config!(instance)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "provisioner api_version is 1" do
|
34
|
+
transport.diagnose_plugin[:api_version].must_equal 1
|
35
|
+
end
|
36
|
+
|
37
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
38
|
+
transport.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#connection" do
|
42
|
+
it "returns a Kitchen::Transport::Exec::Connection object" do
|
43
|
+
transport.connection(state).must_be_kind_of Kitchen::Transport::Exec::Connection
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe Kitchen::Transport::Exec::Connection do
|
49
|
+
let(:logged_output) { StringIO.new }
|
50
|
+
let(:logger) { Logger.new(logged_output) }
|
51
|
+
|
52
|
+
let(:options) do
|
53
|
+
{ logger: logger }
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:connection) do
|
57
|
+
Kitchen::Transport::Exec::Connection.new(options)
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#execute" do
|
61
|
+
it "runs the command" do
|
62
|
+
connection.expects(:run_command).with("do the thing")
|
63
|
+
connection.execute("do the thing")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "ignores nil" do
|
67
|
+
connection.expects(:run_command).never
|
68
|
+
connection.execute(nil)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#upload" do
|
73
|
+
it "copies files" do
|
74
|
+
FileUtils.expects(:mkdir_p).with("/tmp/kitchen")
|
75
|
+
FileUtils.expects(:cp_r).with("/tmp/sandbox/cookbooks", "/tmp/kitchen")
|
76
|
+
connection.upload(%w{/tmp/sandbox/cookbooks}, "/tmp/kitchen")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -21,35 +21,6 @@ require_relative "../../spec_helper"
|
|
21
21
|
require "kitchen/transport/ssh"
|
22
22
|
require "net/ssh/test"
|
23
23
|
|
24
|
-
# Hack to sort results in `Dir.entries` only within the yielded block, to limit
|
25
|
-
# the "behavior pollution" to other code. This was needed for Net::SCP, as
|
26
|
-
# recursive directory upload doesn't sort the file and directory upload
|
27
|
-
# candidates which leads to different results based on the underlying
|
28
|
-
# filesystem (i.e. lexically sorted, inode insertion, mtime/atime, total
|
29
|
-
# randomness, etc.)
|
30
|
-
#
|
31
|
-
# See: https://github.com/net-ssh/net-scp/blob/a24948/lib/net/scp/upload.rb#L52
|
32
|
-
|
33
|
-
def with_sorted_dir_entries
|
34
|
-
Dir.class_exec do
|
35
|
-
class << self
|
36
|
-
alias_method :__entries__, :entries unless method_defined?(:__entries__)
|
37
|
-
|
38
|
-
def entries(*args) # rubocop:disable Lint/NestedMethodDefinition
|
39
|
-
send(:__entries__, *args).sort
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
yield
|
45
|
-
|
46
|
-
Dir.class_exec do
|
47
|
-
class << self
|
48
|
-
alias_method :entries, :__entries__
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
24
|
describe Kitchen::Transport::Ssh do
|
54
25
|
let(:logged_output) { StringIO.new }
|
55
26
|
let(:logger) { Logger.new(logged_output) }
|
data/spec/spec_helper.rb
CHANGED
@@ -59,6 +59,32 @@ class IO
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
# Hack to sort results in `Dir.entries` only within the yielded block, to limit
|
63
|
+
# the "behavior pollution" to other code. This was needed for Net::SCP, as
|
64
|
+
# recursive directory upload doesn't sort the file and directory upload
|
65
|
+
# candidates which leads to different results based on the underlying
|
66
|
+
# filesystem (i.e. lexically sorted, inode insertion, mtime/atime, total
|
67
|
+
# randomness, etc.)
|
68
|
+
#
|
69
|
+
# See: https://github.com/net-ssh/net-scp/blob/a24948/lib/net/scp/upload.rb#L52
|
70
|
+
|
71
|
+
$_sort_dir_entries = false
|
72
|
+
Dir.singleton_class.prepend(Module.new do
|
73
|
+
def entries(*args)
|
74
|
+
super.tap do |rv|
|
75
|
+
rv.sort! if $_sort_dir_entries
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end)
|
79
|
+
|
80
|
+
def with_sorted_dir_entries(&block)
|
81
|
+
old_sort_dir_entries = $_sort_dir_entries
|
82
|
+
$_sort_dir_entries = true
|
83
|
+
yield
|
84
|
+
ensure
|
85
|
+
$_sort_dir_entries = old_sort_dir_entries
|
86
|
+
end
|
87
|
+
|
62
88
|
def with_fake_fs
|
63
89
|
FakeFS.activate!
|
64
90
|
FileUtils.mkdir_p("/tmp")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
$gem list busser
|
1
|
+
$gem list --no-versions | grep "^busser" 2>&1 >/dev/null
|
2
2
|
if test $? -ne 0; then
|
3
3
|
echo "-----> Installing Busser ($version)"
|
4
4
|
$gem install $gem_install_args
|
@@ -10,5 +10,12 @@ if test ! -f "$BUSSER_ROOT/bin/busser"; then
|
|
10
10
|
$busser setup
|
11
11
|
fi
|
12
12
|
|
13
|
-
|
14
|
-
$
|
13
|
+
for plugin in $plugins; do
|
14
|
+
$gem list --no-versions | grep "^$plugin$" 2>&1 >/dev/null
|
15
|
+
if test $? -ne 0; then
|
16
|
+
echo "-----> Installing Busser plugin: $plugin"
|
17
|
+
$busser plugin install $plugin
|
18
|
+
else
|
19
|
+
echo "-----> Busser plugin detected: $plugin"
|
20
|
+
fi
|
21
|
+
done
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -358,8 +358,6 @@ files:
|
|
358
358
|
- features/kitchen_console_command.feature
|
359
359
|
- features/kitchen_defaults.feature
|
360
360
|
- features/kitchen_diagnose_command.feature
|
361
|
-
- features/kitchen_driver_create_command.feature
|
362
|
-
- features/kitchen_driver_discover_command.feature
|
363
361
|
- features/kitchen_help_command.feature
|
364
362
|
- features/kitchen_init_command.feature
|
365
363
|
- features/kitchen_list_command.feature
|
@@ -379,7 +377,7 @@ files:
|
|
379
377
|
- lib/kitchen/command/action.rb
|
380
378
|
- lib/kitchen/command/console.rb
|
381
379
|
- lib/kitchen/command/diagnose.rb
|
382
|
-
- lib/kitchen/command/
|
380
|
+
- lib/kitchen/command/doctor.rb
|
383
381
|
- lib/kitchen/command/exec.rb
|
384
382
|
- lib/kitchen/command/list.rb
|
385
383
|
- lib/kitchen/command/login.rb
|
@@ -393,10 +391,10 @@ files:
|
|
393
391
|
- lib/kitchen/driver.rb
|
394
392
|
- lib/kitchen/driver/base.rb
|
395
393
|
- lib/kitchen/driver/dummy.rb
|
394
|
+
- lib/kitchen/driver/exec.rb
|
396
395
|
- lib/kitchen/driver/proxy.rb
|
397
396
|
- lib/kitchen/driver/ssh_base.rb
|
398
397
|
- lib/kitchen/errors.rb
|
399
|
-
- lib/kitchen/generator/driver_create.rb
|
400
398
|
- lib/kitchen/generator/init.rb
|
401
399
|
- lib/kitchen/instance.rb
|
402
400
|
- lib/kitchen/lazy_hash.rb
|
@@ -427,6 +425,7 @@ files:
|
|
427
425
|
- lib/kitchen/transport.rb
|
428
426
|
- lib/kitchen/transport/base.rb
|
429
427
|
- lib/kitchen/transport/dummy.rb
|
428
|
+
- lib/kitchen/transport/exec.rb
|
430
429
|
- lib/kitchen/transport/ssh.rb
|
431
430
|
- lib/kitchen/transport/winrm.rb
|
432
431
|
- lib/kitchen/util.rb
|
@@ -447,6 +446,7 @@ files:
|
|
447
446
|
- spec/kitchen/diagnostic_spec.rb
|
448
447
|
- spec/kitchen/driver/base_spec.rb
|
449
448
|
- spec/kitchen/driver/dummy_spec.rb
|
449
|
+
- spec/kitchen/driver/exec_spec.rb
|
450
450
|
- spec/kitchen/driver/proxy_spec.rb
|
451
451
|
- spec/kitchen/driver/ssh_base_spec.rb
|
452
452
|
- spec/kitchen/driver_spec.rb
|
@@ -473,6 +473,7 @@ files:
|
|
473
473
|
- spec/kitchen/state_file_spec.rb
|
474
474
|
- spec/kitchen/suite_spec.rb
|
475
475
|
- spec/kitchen/transport/base_spec.rb
|
476
|
+
- spec/kitchen/transport/exec_spec.rb
|
476
477
|
- spec/kitchen/transport/ssh_spec.rb
|
477
478
|
- spec/kitchen/transport/winrm_spec.rb
|
478
479
|
- spec/kitchen/transport_spec.rb
|
@@ -549,8 +550,6 @@ test_files:
|
|
549
550
|
- features/kitchen_console_command.feature
|
550
551
|
- features/kitchen_defaults.feature
|
551
552
|
- features/kitchen_diagnose_command.feature
|
552
|
-
- features/kitchen_driver_create_command.feature
|
553
|
-
- features/kitchen_driver_discover_command.feature
|
554
553
|
- features/kitchen_help_command.feature
|
555
554
|
- features/kitchen_init_command.feature
|
556
555
|
- features/kitchen_list_command.feature
|
@@ -571,6 +570,7 @@ test_files:
|
|
571
570
|
- spec/kitchen/diagnostic_spec.rb
|
572
571
|
- spec/kitchen/driver/base_spec.rb
|
573
572
|
- spec/kitchen/driver/dummy_spec.rb
|
573
|
+
- spec/kitchen/driver/exec_spec.rb
|
574
574
|
- spec/kitchen/driver/proxy_spec.rb
|
575
575
|
- spec/kitchen/driver/ssh_base_spec.rb
|
576
576
|
- spec/kitchen/driver_spec.rb
|
@@ -597,6 +597,7 @@ test_files:
|
|
597
597
|
- spec/kitchen/state_file_spec.rb
|
598
598
|
- spec/kitchen/suite_spec.rb
|
599
599
|
- spec/kitchen/transport/base_spec.rb
|
600
|
+
- spec/kitchen/transport/exec_spec.rb
|
600
601
|
- spec/kitchen/transport/ssh_spec.rb
|
601
602
|
- spec/kitchen/transport/winrm_spec.rb
|
602
603
|
- spec/kitchen/transport_spec.rb
|
@@ -1,64 +0,0 @@
|
|
1
|
-
Feature: Create a new Test Kitchen Driver project
|
2
|
-
In order to make plugin development a snap
|
3
|
-
As a user of Test Kitchen
|
4
|
-
I want a command to run that will give me a driver gem project scaffold
|
5
|
-
|
6
|
-
@spawn
|
7
|
-
Scenario: Displaying help
|
8
|
-
When I run `kitchen help driver create`
|
9
|
-
Then the output should contain:
|
10
|
-
"""
|
11
|
-
Usage:
|
12
|
-
kitchen driver create [NAME]
|
13
|
-
"""
|
14
|
-
And the exit status should be 0
|
15
|
-
|
16
|
-
Scenario: Running with default values
|
17
|
-
When I run `kitchen driver create qemu`
|
18
|
-
Then a directory named "kitchen-qemu" should exist
|
19
|
-
And the file "kitchen-qemu/CHANGELOG.md" should contain:
|
20
|
-
"""
|
21
|
-
## 0.1.0 / Unreleased
|
22
|
-
"""
|
23
|
-
And the file "kitchen-qemu/Gemfile" should contain "gemspec"
|
24
|
-
And the file "kitchen-qemu/Rakefile" should contain "task :stats"
|
25
|
-
And the file "kitchen-qemu/README.md" should contain:
|
26
|
-
"""
|
27
|
-
Kitchen::Qemu
|
28
|
-
"""
|
29
|
-
And the file "kitchen-qemu/kitchen-qemu.gemspec" should contain:
|
30
|
-
"""
|
31
|
-
require 'kitchen/driver/qemu_version'
|
32
|
-
"""
|
33
|
-
And the file "kitchen-qemu/LICENSE" should contain:
|
34
|
-
"""
|
35
|
-
Licensed under the Apache License, Version 2.0
|
36
|
-
"""
|
37
|
-
And the file "kitchen-qemu/.gitignore" should contain:
|
38
|
-
"""
|
39
|
-
Gemfile.lock
|
40
|
-
"""
|
41
|
-
And the file "kitchen-qemu/.tailor" should contain:
|
42
|
-
"""
|
43
|
-
config.file_set 'lib/**/*.rb'
|
44
|
-
"""
|
45
|
-
And the file "kitchen-qemu/.travis.yml" should contain:
|
46
|
-
"""
|
47
|
-
language: ruby
|
48
|
-
"""
|
49
|
-
And a file named "kitchen-qemu/.cane" should exist
|
50
|
-
And the file "kitchen-qemu/lib/kitchen/driver/qemu_version.rb" should contain:
|
51
|
-
"""
|
52
|
-
QEMU_VERSION = "0.1.0.dev"
|
53
|
-
"""
|
54
|
-
And the file "kitchen-qemu/lib/kitchen/driver/qemu.rb" should contain:
|
55
|
-
"""
|
56
|
-
class Qemu < Kitchen::Driver::SSHBase
|
57
|
-
"""
|
58
|
-
|
59
|
-
Scenario: Running with an alternate license
|
60
|
-
When I successfully run `kitchen driver create foo --license=reserved`
|
61
|
-
Then the file "kitchen-foo/LICENSE" should contain:
|
62
|
-
"""
|
63
|
-
All rights reserved - Do Not Redistribute
|
64
|
-
"""
|
@@ -1,25 +0,0 @@
|
|
1
|
-
Feature: Search RubyGems to discover new Test Kitchen Driver gems
|
2
|
-
In order to periodically check for new/updated Kitchen drivers
|
3
|
-
As a Test Kitchen user
|
4
|
-
I want to run a command which returns candidate Kitchen drivers
|
5
|
-
|
6
|
-
@spawn
|
7
|
-
Scenario: Displaying help
|
8
|
-
When I run `kitchen help driver discover`
|
9
|
-
Then the output should contain:
|
10
|
-
"""
|
11
|
-
Usage:
|
12
|
-
kitchen driver discover
|
13
|
-
"""
|
14
|
-
And the exit status should be 0
|
15
|
-
|
16
|
-
Scenario: Running driver discover returns live results
|
17
|
-
When I run `kitchen driver discover`
|
18
|
-
Then the exit status should be 0
|
19
|
-
And the output should contain "kitchen-bluebox"
|
20
|
-
|
21
|
-
Scenario: Running driver discover with the --chef-config-path parameter loads the chef config
|
22
|
-
Given an empty file named "kitchen_client.rb"
|
23
|
-
When I run `kitchen driver discover --chef-config-path=kitchen_client.rb`
|
24
|
-
Then the exit status should be 0
|
25
|
-
And the output should contain "kitchen-bluebox"
|
@@ -1,102 +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 "kitchen/command"
|
20
|
-
|
21
|
-
require "rubygems/spec_fetcher"
|
22
|
-
begin
|
23
|
-
require "chef-config/config"
|
24
|
-
require "chef-config/workstation_config_loader"
|
25
|
-
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
26
|
-
# This space left intentionally blank.
|
27
|
-
end
|
28
|
-
|
29
|
-
module Kitchen
|
30
|
-
module Command
|
31
|
-
# Command to discover drivers published on RubyGems.
|
32
|
-
#
|
33
|
-
# @author Fletcher Nichol <fnichol@nichol.ca>
|
34
|
-
class DriverDiscover < Kitchen::Command::Base
|
35
|
-
# Invoke the command.
|
36
|
-
def call
|
37
|
-
# We are introducing the idea of using the Chef configuration as a
|
38
|
-
# unified config for all the ChefDK tools. The first practical
|
39
|
-
# implementation of this is 1 location to setup proxy configurations.
|
40
|
-
if defined?(ChefConfig::WorkstationConfigLoader)
|
41
|
-
ChefConfig::WorkstationConfigLoader.new(options[:chef_config_path]).load
|
42
|
-
end
|
43
|
-
ChefConfig::Config.export_proxies if defined?(ChefConfig::Config.export_proxies)
|
44
|
-
|
45
|
-
specs = fetch_gem_specs.sort_by { |spec| spec[0] }
|
46
|
-
specs = specs[0, 49].push(["...", "..."]) if specs.size > 49
|
47
|
-
specs = specs.unshift(["Gem Name", "Latest Stable Release"])
|
48
|
-
print_table(specs, indent: 4)
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
# Fetches Kitchen-related RubyGems and returns an array of name/version
|
54
|
-
# tuples.
|
55
|
-
#
|
56
|
-
# @return [Array<Array>] an array of name/version tuples
|
57
|
-
# @api private
|
58
|
-
def fetch_gem_specs
|
59
|
-
req = Gem::Requirement.default
|
60
|
-
dep = Gem::Deprecate.skip_during do
|
61
|
-
Gem::Dependency.new(/kitchen-/i, req)
|
62
|
-
end
|
63
|
-
fetcher = Gem::SpecFetcher.fetcher
|
64
|
-
|
65
|
-
if fetcher.respond_to?(:find_matching)
|
66
|
-
fetch_gem_specs_pre_rubygems_2(fetcher, dep)
|
67
|
-
else
|
68
|
-
fetch_gem_specs_post_rubygems_2(fetcher, dep)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# Fetches gem specs for RubyGems 2 and later.
|
73
|
-
#
|
74
|
-
# @param fetcher [Gem::SpecFetcher] a gemspec fetcher
|
75
|
-
# @param dep [Gem::Dependency] a gem dependency object
|
76
|
-
# @return [Array<Array>] an array of name/version tuples
|
77
|
-
# @api private
|
78
|
-
def fetch_gem_specs_post_rubygems_2(fetcher, dep)
|
79
|
-
specs = fetcher.spec_for_dependency(dep, false)
|
80
|
-
specs.first.map { |t| [t.first.name, t.first.version] }
|
81
|
-
end
|
82
|
-
|
83
|
-
# Fetches gem specs for pre-RubyGems 2.
|
84
|
-
#
|
85
|
-
# @param fetcher [Gem::SpecFetcher] a gemspec fetcher
|
86
|
-
# @param dep [Gem::Dependency] a gem dependency object
|
87
|
-
# @return [Array<Array>] an array of name/version tuples
|
88
|
-
# @api private
|
89
|
-
def fetch_gem_specs_pre_rubygems_2(fetcher, dep)
|
90
|
-
specs = fetcher.find_matching(dep, false, false, false)
|
91
|
-
specs.map(&:first).map { |t| t[0, 2] }
|
92
|
-
end
|
93
|
-
|
94
|
-
# Print out a display table.
|
95
|
-
#
|
96
|
-
# @api private
|
97
|
-
def print_table(*args)
|
98
|
-
shell.print_table(*args)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|