cartage-remote 2.1 → 2.2.beta1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 57c1a21e0b093fd54009b0a6982bbbadf74eb7fc
4
- data.tar.gz: e2a2a4200d1782839088ef0db9b0231c15839534
2
+ SHA256:
3
+ metadata.gz: d8f8ebfcf0efff293cc6ab32a208d40e6c296e6453e396af0fd19a9f5bd2f1c5
4
+ data.tar.gz: 5c88daf9f76d3fb4ae8ad9c98fe33ea1e559c2bf0bee44e749b43428ce695ed1
5
5
  SHA512:
6
- metadata.gz: b82aace89ab4cdee5af0a14efde94ce6304e3619d8ddf16df6a439c0e850bee7fd12ddf7b0c93b78fa2c62ffafae72ab4d433bd3915b9ea2c879bd46c21425b8
7
- data.tar.gz: c6b01886a05159ad378711135c7601f37120ac871959023176f5f9bbe991d64f44ae1b8969bb04553cd9100be32b16e649e97cddc737d46abc21d2b73e37e994
6
+ metadata.gz: ec0e4445eb3dc157067af58f0179ba35771d05cf366618ef8913d1f77384934d3026526ab851afda0b5bc26d9ec98adc347c8e4c6287bb81b9484c08977fbf15
7
+ data.tar.gz: 6d0a9317618d908cbcaf1e28eab9b5b72bce6a753af980611954e37ec7ec03bc49f48253e32de4effeb2763cc9d8a70153602bbd95fd13f4752a2e7ca700a592
data/History.md CHANGED
@@ -1,7 +1,24 @@
1
+ === 2.2 / 2018-04-03
2
+
3
+ * 1 major enhancement:
4
+
5
+ * Turn on SSH Agent Forwarding by default and provide an option to
6
+ disable it.
7
+
8
+ * 1 major bugfix:
9
+
10
+ * Remove dependency on 'fog' in favour of 'fog-core'. This reduces the
11
+ number of packages accidentally included because I wanted to use the
12
+ convenience of Fog::SSH over raw Net::SSH.
13
+
14
+ * Test fixes:
15
+
16
+ * Add more configuration checks and fix subtly broken tests.
17
+
1
18
  === 2.1 / 2016-06-07
2
19
 
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
20
+ * Fix an issue discovered with connection when host keys are not set but are
21
+ overriding globally defined host keys or key data. Added
5
22
  Cartage::Remote::Host tests to ensure that this does not regress.
6
23
 
7
24
  === 2.0 / 2016-05-31
data/Licence.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This software is available under an MIT-style licence.
4
4
 
5
- * Copyright 2015–2016 Kinetic Cafe
5
+ * Copyright 2015–2018 Kinetic Cafe
6
6
 
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy of
8
8
  this software and associated documentation files (the "Software"), to deal in
@@ -33,13 +33,14 @@ configuration file.
33
33
  user: build
34
34
  address: build-machine
35
35
  port: 22
36
+ forward_agent: true # the default
36
37
  alternate: alternate@build-machine:2222
37
38
 
38
39
  == Install
39
40
 
40
41
  Add cartage-remote to your Gemfile:
41
42
 
42
- gem 'cartage-remote', '~> 2.0'
43
+ gem 'cartage-remote', '~> 2.2'
43
44
 
44
45
  Or manually install:
45
46
 
data/Rakefile CHANGED
@@ -24,8 +24,8 @@ spec = Hoe.spec 'cartage-remote' do
24
24
 
25
25
  extra_deps << ['cartage', '~> 2.0']
26
26
  extra_deps << ['micromachine', '~> 2.0']
27
- extra_deps << ['fog', '~> 1.27']
28
- extra_deps << ['net-ssh', '~> 3.0']
27
+ extra_deps << ['fog-core', '~> 2.1']
28
+ extra_deps << ['net-ssh', '~> 4.0']
29
29
  extra_deps << ['net-scp', '~> 1.2']
30
30
 
31
31
  extra_dev_deps << ['rake', '>= 10.0']
@@ -36,11 +36,7 @@ spec = Hoe.spec 'cartage-remote' do
36
36
  extra_dev_deps << ['hoe-travis', '~> 1.2']
37
37
  extra_dev_deps << ['minitest', '~> 5.4']
38
38
  extra_dev_deps << ['minitest-autotest', '~> 1.0']
39
- extra_dev_deps << ['minitest-bisect', '~> 1.2']
40
- extra_dev_deps << ['minitest-bonus-assertions', '~> 2.0']
41
- extra_dev_deps << ['minitest-focus', '~> 1.1']
42
39
  extra_dev_deps << ['minitest-moar', '~> 0.0']
43
- extra_dev_deps << ['minitest-pretty_diff', '~> 0.1']
44
40
  extra_dev_deps << ['simplecov', '~> 0.7']
45
41
  end
46
42
 
@@ -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.1' #:nodoc:
185
+ VERSION = '2.2.beta1' #:nodoc:
186
186
 
187
187
  # Build on the remote server.
188
188
  def build
@@ -215,10 +215,20 @@ class Cartage
215
215
 
216
216
  # Check that the configuration is correct. If +require_host+ is present, an
217
217
  # exception will be thrown if a host is required and not present.
218
- def check_config(require_host: false)
219
- hosts = cartage.config(for_plugin: :remote).hosts
220
- verify_hosts(hosts)
221
- fail "No host #{name} present" if require_host && !hosts.dig(name)
218
+ #
219
+ # The optional +notify+ block parameter is used primarily for testing.
220
+ def check_config(require_host: false, &notify)
221
+ config = cartage.config(for_plugin: :remote)
222
+
223
+ puts "#{__method__}: verify_hosts(#{config.hosts.inspect})"
224
+ verify_hosts(config.hosts, &notify)
225
+
226
+ if require_host
227
+ name = config.host || 'default'
228
+ fail "No host #{name} present" unless config.hosts.dig(name)
229
+ end
230
+
231
+ true
222
232
  end
223
233
 
224
234
  private
@@ -434,23 +444,29 @@ Remote error in stage #{stage.state}:
434
444
  path.to_s.sub(%r{\A~/}, '')
435
445
  end
436
446
 
437
- def verify_hosts(hosts)
447
+ def verify_hosts(hosts, &notify)
438
448
  fail ArgumentError, 'No hosts present' if hosts.nil? || hosts.to_h.empty?
439
449
 
440
450
  hosts.each_pair do |name, host|
441
- verify_host(name, host)
451
+ puts "#{__method__}: verify_host(#{name.inspect}, #{host.inspect})"
452
+ verify_host(name, host, &notify)
442
453
  end
443
454
  end
444
455
 
445
456
  def verify_host(name, host, &notify)
446
457
  notify ||= ->(message) { warn message }
447
458
 
448
- case host
449
- when OpenStruct
450
- host.dig(:address) || host.dig(:host)
451
- when String
452
- Cartage::Remote::Host::HOST_RE.match(host)[:address]
453
- end || notify.("Host #{name} invalid: No host address present")
459
+ address =
460
+ case host
461
+ when OpenStruct
462
+ host.dig(:address) || host.dig(:host)
463
+ when String
464
+ Cartage::Remote::Host::HOST_RE.match(host)[:address]
465
+ end
466
+
467
+ puts "#{__method__}: address=#{address.inspect}"
468
+
469
+ notify.("Host #{name} invalid: No host address present") unless address
454
470
  end
455
471
 
456
472
  def verify_host!(name, host)
@@ -9,6 +9,8 @@ class Cartage::Remote::Host
9
9
  attr_reader :address
10
10
  # The port of the SSH connection to the remote host.
11
11
  attr_reader :port
12
+ # Whether agent forwarding should be turned on or not. Defaults to +true+.
13
+ attr_reader :forward_agent
12
14
 
13
15
  # The (optional) build script defined as part of this host.
14
16
  attr_reader :build
@@ -44,6 +46,7 @@ class Cartage::Remote::Host
44
46
  @user = host.user
45
47
  @address = host.address || host.host
46
48
  @port = host.port
49
+ @forward_agent = host.to_h.fetch(:forward_agent, true)
47
50
 
48
51
  if host.keys.kind_of?(OpenStruct)
49
52
  @key_data = host.keys.to_h.values
@@ -65,6 +68,7 @@ class Cartage::Remote::Host
65
68
  @user = Regexp.last_match[:user]
66
69
  @address = Regexp.last_match[:address]
67
70
  @port = Regexp.last_match[:port]
71
+ @forward_agent = true
68
72
  end
69
73
 
70
74
  if address.nil? || address.empty?
@@ -79,22 +83,26 @@ class Cartage::Remote::Host
79
83
  # Configure the Fog::SSH and Fog::SCP connections using the provided
80
84
  # ssh_config.
81
85
  def configure_ssh(ssh_config)
82
- require 'fog'
86
+ require 'fog/core'
83
87
 
84
- if @key_data
85
- ssh_config[:key_data] = @key_data
88
+ if key_data
89
+ ssh_config[:key_data] = key_data
86
90
  ssh_config[:keys] = nil
87
- elsif @keys
91
+ elsif keys
88
92
  ssh_config[:key_data] = nil
89
- ssh_config[:keys] = @keys
93
+ ssh_config[:keys] = keys
90
94
  end
91
95
 
92
- options = { paranoid: true, port: port }.
96
+ ssh_options = { paranoid: true, port: port, forward_agent: !!forward_agent }.
93
97
  merge(ssh_config).
94
98
  delete_if { |_, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) }
95
99
 
96
- @ssh = Fog::SSH.new(address, user, options)
97
- @scp = Fog::SCP.new(address, user, options)
100
+ scp_options = { paranoid: true, port: port }.
101
+ merge(ssh_config).
102
+ delete_if { |_, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) }
103
+
104
+ @ssh = Fog::SSH.new(address, user, ssh_options)
105
+ @scp = Fog::SCP.new(address, user, scp_options)
98
106
  end
99
107
 
100
108
  # This Host, formatted nicely.
@@ -107,7 +115,10 @@ class Cartage::Remote::Host
107
115
  {
108
116
  user: user,
109
117
  address: address,
110
- port: port
118
+ port: port,
119
+ forward_agent: forward_agent
111
120
  }.delete_if { |_, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) }
112
121
  end
122
+
123
+ alias to_h to_hash
113
124
  end
@@ -2,14 +2,10 @@
2
2
 
3
3
  gem 'minitest'
4
4
  require 'minitest/autorun'
5
- require 'minitest/pretty_diff'
6
- require 'minitest/focus'
7
5
  require 'minitest/moar'
8
- require 'minitest/bisect'
9
- require 'minitest-bonus-assertions'
10
6
 
11
7
  require 'cartage/minitest'
12
8
  require 'cartage/plugins/remote'
13
- require 'fog'
9
+ require 'fog/core'
14
10
 
15
11
  Fog.mock!
@@ -6,12 +6,13 @@ describe 'Cartage::Remote' do
6
6
  let(:string_host) {
7
7
  'suser@saddress:sport'
8
8
  }
9
+
9
10
  let(:hash_host) {
10
11
  {
11
12
  user: 'huser',
12
13
  address: 'haddress',
13
- host: 'hhost',
14
- port: 'hport'
14
+ port: 'hport',
15
+ forward_agent: true
15
16
  }
16
17
  }
17
18
 
@@ -22,6 +23,7 @@ describe 'Cartage::Remote' do
22
23
  }
23
24
  }
24
25
  }
26
+
25
27
  let(:config_hash) {
26
28
  {
27
29
  root_path: '/a/b/c',
@@ -32,42 +34,34 @@ describe 'Cartage::Remote' do
32
34
  }
33
35
  }
34
36
  }
37
+
35
38
  let(:config) { Cartage::Config.new(config_hash) }
36
39
  let(:cartage) { Cartage.new(config) }
37
40
  let(:subject) { cartage.remote }
41
+ let(:hashify) { config.method(:hashify) }
38
42
 
39
- def self.it_verifies_configuration(focus: false, &block)
40
- self.focus if focus
41
- it 'fails if there is no host with the given name' do
42
- remote_config[:host] = 'foo'
43
- ex = assert_raises RuntimeError do
44
- instance_exec(&block)
45
- end
46
- assert_equal 'No host foo present', ex.message
43
+ it 'fails if there is no host with the given name' do
44
+ remote_config[:host] = 'foo'
45
+ ex = assert_raises RuntimeError do
46
+ cartage.remote.check_config(require_host: true)
47
47
  end
48
+ assert_equal 'No host foo present', ex.message
49
+ end
48
50
 
49
- self.focus if focus
50
- it 'fails if there are no hosts present' do
51
- remote_config[:hosts] = {}
51
+ it 'fails if there are no hosts present' do
52
+ remote_config[:hosts] = {}
52
53
 
53
- ex = assert_raises ArgumentError do
54
- instance_exec(&block)
55
- end
56
- assert_equal 'No hosts present', ex.message
54
+ ex = assert_raises ArgumentError do
55
+ cartage.remote.check_config(require_host: true)
57
56
  end
57
+ assert_equal 'No hosts present', ex.message
58
+ end
58
59
 
59
- self.focus if focus
60
- it 'warns if a host is missing some configuration' do
61
- remote_config[:hosts][:foo] = {}
62
-
63
- error = <<-EOS
64
- Host foo invalid: No host address present
65
- EOS
66
-
67
- assert_output nil, error do
68
- instance_exec(&block)
69
- end
70
- end
60
+ it 'warns if a host is missing some configuration' do
61
+ remote_config[:hosts][:foo] = {}
62
+ messages = []
63
+ cartage.remote.check_config(require_host: true, &->message { messages << message })
64
+ assert_equal ['Host foo invalid: No host address present'], messages
71
65
  end
72
66
 
73
67
  describe '#resolve_plugin_config!' do
@@ -92,11 +86,26 @@ Host foo invalid: No host address present
92
86
  end
93
87
 
94
88
  it 'converts the implicit default into explicit' do
95
- remote_config.delete(:hosts)
89
+ expected = hashify.(remote_config.delete(:hosts))
96
90
  remote_config[:server] = hash_host
97
91
 
98
- assert_equal remote_config[:hosts], cartage.config(for_plugin: :remote).
99
- dig(:hosts).to_hash
92
+ actual = hashify.(cartage.config(for_plugin: :remote).dig(:hosts))
93
+
94
+ assert_equal expected, actual
95
+ end
96
+
97
+ it 'sets forward_agent to true if missing' do
98
+ expected = hashify.(remote_config.dig(:hosts, :default))
99
+ remote_config.dig(:hosts, :default).delete(:forward_agent)
100
+ actual = hashify.(cartage.config(for_plugin: :remote).dig(:hosts, :default))
101
+ assert_equal expected, actual
102
+ end
103
+
104
+ it 'keeps forward_agent as false if specified' do
105
+ hash_host[:forward_agent] = false
106
+ expected = hashify.(remote_config.dig(:hosts, :default))
107
+ actual = hashify.(cartage.config(for_plugin: :remote).dig(:hosts, :default))
108
+ assert_equal expected, actual
100
109
  end
101
110
  end
102
111
  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.1'
4
+ version: 2.2.beta1
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-06-07 00:00:00.000000000 Z
11
+ date: 2018-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cartage
@@ -39,33 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: fog
42
+ name: fog-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.27'
47
+ version: '2.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.27'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: net-ssh
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '4.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: net-scp
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '5.9'
89
+ version: '5.11'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '5.9'
96
+ version: '5.11'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rdoc
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '4.0'
103
+ version: '10.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '4.0'
110
+ version: '10.0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rake
112
+ name: rdoc
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '10.0'
117
+ version: '4.2'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '10.0'
124
+ version: '4.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: hoe-doofus
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -192,48 +192,6 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '1.0'
195
- - !ruby/object:Gem::Dependency
196
- name: minitest-bisect
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '1.2'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '1.2'
209
- - !ruby/object:Gem::Dependency
210
- name: minitest-bonus-assertions
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '2.0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '2.0'
223
- - !ruby/object:Gem::Dependency
224
- name: minitest-focus
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '1.1'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: '1.1'
237
195
  - !ruby/object:Gem::Dependency
238
196
  name: minitest-moar
239
197
  requirement: !ruby/object:Gem::Requirement
@@ -248,20 +206,6 @@ dependencies:
248
206
  - - "~>"
249
207
  - !ruby/object:Gem::Version
250
208
  version: '0.0'
251
- - !ruby/object:Gem::Dependency
252
- name: minitest-pretty_diff
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - "~>"
256
- - !ruby/object:Gem::Version
257
- version: '0.1'
258
- type: :development
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - "~>"
263
- - !ruby/object:Gem::Version
264
- version: '0.1'
265
209
  - !ruby/object:Gem::Dependency
266
210
  name: simplecov
267
211
  requirement: !ruby/object:Gem::Requirement
@@ -282,14 +226,14 @@ dependencies:
282
226
  requirements:
283
227
  - - "~>"
284
228
  - !ruby/object:Gem::Version
285
- version: '3.15'
229
+ version: '3.17'
286
230
  type: :development
287
231
  prerelease: false
288
232
  version_requirements: !ruby/object:Gem::Requirement
289
233
  requirements:
290
234
  - - "~>"
291
235
  - !ruby/object:Gem::Version
292
- version: '3.15'
236
+ version: '3.17'
293
237
  description: |-
294
238
  cartage-remote is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]
295
239
  to build a package on a remote machine with cartage.
@@ -337,12 +281,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
281
  version: '2.0'
338
282
  required_rubygems_version: !ruby/object:Gem::Requirement
339
283
  requirements:
340
- - - ">="
284
+ - - ">"
341
285
  - !ruby/object:Gem::Version
342
- version: '0'
286
+ version: 1.3.1
343
287
  requirements: []
344
288
  rubyforge_project:
345
- rubygems_version: 2.6.4
289
+ rubygems_version: 2.7.6
346
290
  signing_key:
347
291
  specification_version: 4
348
292
  summary: cartage-remote is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]