cartage-remote 2.0 → 2.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 +4 -4
- data/History.md +7 -1
- data/Manifest.txt +1 -0
- data/lib/cartage/plugins/remote.rb +2 -2
- data/lib/cartage/remote/host.rb +14 -2
- data/test/minitest_config.rb +4 -0
- data/test/test_cartage_remote_host.rb +172 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57c1a21e0b093fd54009b0a6982bbbadf74eb7fc
|
4
|
+
data.tar.gz: e2a2a4200d1782839088ef0db9b0231c15839534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b82aace89ab4cdee5af0a14efde94ce6304e3619d8ddf16df6a439c0e850bee7fd12ddf7b0c93b78fa2c62ffafae72ab4d433bd3915b9ea2c879bd46c21425b8
|
7
|
+
data.tar.gz: c6b01886a05159ad378711135c7601f37120ac871959023176f5f9bbe991d64f44ae1b8969bb04553cd9100be32b16e649e97cddc737d46abc21d2b73e37e994
|
data/History.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
=== 2.
|
1
|
+
=== 2.1 / 2016-06-07
|
2
|
+
|
3
|
+
* Fix an issue discovered with connection when host keys are not set but
|
4
|
+
are overriding globally defined host keys or key data. Added
|
5
|
+
Cartage::Remote::Host tests to ensure that this does not regress.
|
6
|
+
|
7
|
+
=== 2.0 / 2016-05-31
|
2
8
|
|
3
9
|
* Rewrote for compatibility with cartage 2.0.
|
4
10
|
|
data/Manifest.txt
CHANGED
@@ -182,7 +182,7 @@ class Cartage
|
|
182
182
|
# bundle exec cartage --config-file %{config_file} pack &&
|
183
183
|
# bundle exec cartage --config-file %{config_file} s3 put
|
184
184
|
class Remote < Cartage::Plugin
|
185
|
-
VERSION = '2.
|
185
|
+
VERSION = '2.1' #:nodoc:
|
186
186
|
|
187
187
|
# Build on the remote server.
|
188
188
|
def build
|
@@ -377,7 +377,7 @@ cd #{paths.build_path} && git checkout #{cartage.release_hashref}
|
|
377
377
|
else
|
378
378
|
@keys = Array(config.keys || '~/.ssh/*id_[rd]sa').flat_map { |key|
|
379
379
|
Pathname.glob(Pathname(key).expand_path)
|
380
|
-
}
|
380
|
+
}.uniq
|
381
381
|
end
|
382
382
|
|
383
383
|
@build_root = Pathname(config.build_root || '~')
|
data/lib/cartage/remote/host.rb
CHANGED
@@ -17,6 +17,12 @@ class Cartage::Remote::Host
|
|
17
17
|
# The (optional) postbuild script defined as part of this host.
|
18
18
|
attr_reader :postbuild
|
19
19
|
|
20
|
+
# The (optional) array of SSH private key filenames defined as part of this
|
21
|
+
# host.
|
22
|
+
attr_reader :keys
|
23
|
+
# The (optional) array of SSH private keys defined as part of this host.
|
24
|
+
attr_reader :key_data
|
25
|
+
|
20
26
|
# The Fog::SSH instance for this server. Must run #configure_ssh before
|
21
27
|
# using.
|
22
28
|
attr_reader :ssh
|
@@ -41,11 +47,17 @@ class Cartage::Remote::Host
|
|
41
47
|
|
42
48
|
if host.keys.kind_of?(OpenStruct)
|
43
49
|
@key_data = host.keys.to_h.values
|
44
|
-
|
50
|
+
elsif host.keys
|
45
51
|
@keys = Array(host.keys).flat_map { |key|
|
46
52
|
Pathname.glob(Pathname(key).expand_path)
|
47
|
-
}
|
53
|
+
}.uniq
|
48
54
|
end
|
55
|
+
|
56
|
+
# If key_data or keys are empty, properly empty them so that they are
|
57
|
+
# handled improperly.
|
58
|
+
@key_data = nil if @key_data && @key_data.empty?
|
59
|
+
@keys = nil if @keys && @keys.empty?
|
60
|
+
|
49
61
|
@build = host.build
|
50
62
|
@prebuild = host.prebuild
|
51
63
|
@postbuild = host.postbuild
|
data/test/minitest_config.rb
CHANGED
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minitest_config'
|
4
|
+
|
5
|
+
describe 'Cartage::Remote::Host' do
|
6
|
+
let(:string_host) {
|
7
|
+
'suser@saddress:sport'
|
8
|
+
}
|
9
|
+
let(:hash_host) {
|
10
|
+
{
|
11
|
+
user: 'huser',
|
12
|
+
address: 'haddress',
|
13
|
+
host: 'hhost',
|
14
|
+
port: 'hport'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
let(:remote_config) {
|
19
|
+
{
|
20
|
+
hosts: {
|
21
|
+
default: hash_host
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
let(:config_hash) {
|
26
|
+
{
|
27
|
+
root_path: '/a/b/c',
|
28
|
+
name: 'test',
|
29
|
+
timestamp: 'value',
|
30
|
+
plugins: {
|
31
|
+
remote: remote_config
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
let(:config) { Cartage::Config.new(config_hash) }
|
36
|
+
let(:host) { Cartage::Remote::Host.new(config.plugins.remote.hosts.default) }
|
37
|
+
let(:ssh) { host.ssh }
|
38
|
+
|
39
|
+
describe '#initialize' do
|
40
|
+
it 'parses a string host correctly' do
|
41
|
+
host = Cartage::Remote::Host.new(string_host)
|
42
|
+
assert_equal 'suser', host.user
|
43
|
+
assert_equal 'saddress', host.address
|
44
|
+
assert_equal 'sport', host.port
|
45
|
+
assert_nil host.build
|
46
|
+
assert_nil host.prebuild
|
47
|
+
assert_nil host.postbuild
|
48
|
+
assert_nil host.keys
|
49
|
+
assert_nil host.key_data
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'with a config/OpenStruct host' do
|
53
|
+
it 'parses correctly' do
|
54
|
+
assert_equal 'huser', host.user
|
55
|
+
assert_equal 'haddress', host.address
|
56
|
+
assert_equal 'hport', host.port
|
57
|
+
assert_nil host.build
|
58
|
+
assert_nil host.prebuild
|
59
|
+
assert_nil host.postbuild
|
60
|
+
assert_nil host.keys
|
61
|
+
assert_nil host.key_data
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'parses host script overrides correctly' do
|
65
|
+
hash_host.update(
|
66
|
+
build: 'hbuild',
|
67
|
+
prebuild: 'hprebuild',
|
68
|
+
postbuild: 'hpostbuild'
|
69
|
+
)
|
70
|
+
|
71
|
+
assert_equal 'hbuild', host.build
|
72
|
+
assert_equal 'hprebuild', host.prebuild
|
73
|
+
assert_equal 'hpostbuild', host.postbuild
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'parses host keys overrides correctly' do
|
77
|
+
hash_host.update(keys: '~/.ssh/id_rsa')
|
78
|
+
|
79
|
+
stub Pathname, :glob, %w(/home/user/.ssh/id_rsa) do
|
80
|
+
assert_equal %w(/home/user/.ssh/id_rsa), host.keys
|
81
|
+
assert_nil host.key_data
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'parses host keys overrides correctly (removing duplicates)' do
|
86
|
+
hash_host.update(keys: %w(~/.ssh/id_rsa) * 2)
|
87
|
+
|
88
|
+
stub Pathname, :glob, %w(/home/user/.ssh/id_rsa) do
|
89
|
+
assert_equal %w(/home/user/.ssh/id_rsa), host.keys
|
90
|
+
assert_nil host.key_data
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'parses empty host keys overrides correctly (back to nil)' do
|
95
|
+
hash_host.update(keys: [])
|
96
|
+
|
97
|
+
stub Pathname, :glob, %w(/home/user/.ssh/id_rsa) do
|
98
|
+
assert_nil host.keys
|
99
|
+
assert_nil host.key_data
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'parses host key_data overrides correctly' do
|
104
|
+
hash_host.update(
|
105
|
+
keys: {
|
106
|
+
custom: 'Host ASCII-Armored Private Key'
|
107
|
+
}
|
108
|
+
)
|
109
|
+
|
110
|
+
assert_nil host.keys
|
111
|
+
assert_equal [ 'Host ASCII-Armored Private Key' ], host.key_data
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'parses empty host key_data overrides correctly (back to nil)' do
|
115
|
+
hash_host.update(keys: {})
|
116
|
+
|
117
|
+
assert_nil host.keys
|
118
|
+
assert_nil host.key_data
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#configure_ssh' do
|
124
|
+
def assert_ssh_value(expected, name)
|
125
|
+
assert_equal expected, ssh.instance_variable_get(:"@#{name}")
|
126
|
+
end
|
127
|
+
|
128
|
+
def assert_ssh_option(expected, name)
|
129
|
+
assert_equal expected, ssh.instance_variable_get(:@options)[name]
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'configures SSH properly' do
|
133
|
+
host.configure_ssh({})
|
134
|
+
assert_ssh_value 'haddress', :address
|
135
|
+
assert_ssh_value 'huser', :username
|
136
|
+
assert_ssh_option 'hport', :port
|
137
|
+
assert_ssh_option true, :paranoid
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'uses the provided key_data if there is no host override' do
|
141
|
+
host.configure_ssh(key_data: [ 'Global ASCII-Armored Private Key' ])
|
142
|
+
assert_ssh_option [ 'Global ASCII-Armored Private Key' ], :key_data
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'uses the provided keys if there is no host override' do
|
146
|
+
host.configure_ssh(keys: %w(path/to/a/key/file))
|
147
|
+
assert_ssh_option %w(path/to/a/key/file), :keys
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'uses the host keys if present' do
|
151
|
+
hash_host.update(keys: '~/.ssh/id_rsa')
|
152
|
+
|
153
|
+
stub Pathname, :glob, %w(/home/user/.ssh/id_rsa) do
|
154
|
+
host.configure_ssh(keys: [ 'path/to/a/key/file' ])
|
155
|
+
end
|
156
|
+
|
157
|
+
assert_ssh_option %w(/home/user/.ssh/id_rsa), :keys
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'uses the provided keys if host keys is empty' do
|
161
|
+
hash_host.update(keys: [])
|
162
|
+
host.configure_ssh(keys: %w(path/to/a/key/file))
|
163
|
+
assert_ssh_option %w(path/to/a/key/file), :keys
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'uses the provided key_data if host key_data is empty' do
|
167
|
+
hash_host.update(keys: {})
|
168
|
+
host.configure_ssh(key_data: [ 'Global ASCII-Armored Private Key' ])
|
169
|
+
assert_ssh_option [ 'Global ASCII-Armored Private Key' ], :key_data
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartage-remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cartage
|
@@ -319,6 +319,7 @@ files:
|
|
319
319
|
- lib/cartage/remote/host.rb
|
320
320
|
- test/minitest_config.rb
|
321
321
|
- test/test_cartage_remote.rb
|
322
|
+
- test/test_cartage_remote_host.rb
|
322
323
|
homepage: https://github.com/KineticCafe/cartage-remote/
|
323
324
|
licenses:
|
324
325
|
- MIT
|