chake 0.10 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f77ef7f899b9ce537667051750f06a7477a0fa79
4
- data.tar.gz: 6a34e5a9df879a762fc76de59ee1b0d931813c03
3
+ metadata.gz: a6c0ada57c6acd1ba0a23069a528397144d0e61c
4
+ data.tar.gz: 030adffa33315100225ab10a63a7038e9f6fd512
5
5
  SHA512:
6
- metadata.gz: 55237a960ac4ae67d3f0f173582b615b8306767ed16bda793828170965472356da69749b3597260e9be61ba29dd1072dd61c015fcba33e6ebc66585c7a565313
7
- data.tar.gz: 2fcf4ef7b8edb50beb1c18b87bd5e03c30dded4477ef4e1cf3e8ac53d52454497afe3b91a17692d78cd379b37670f2688ac854ac5879b7b979b0d7190ef57a42
6
+ metadata.gz: 866152de25dbedae6edc9b3ad993b425a468c04dfaf9e8fa13bb2ba597128801fbdc46f33ea101919dd02ea2e99a4de98e9c663ae72a12cfe84780ee7b527eac
7
+ data.tar.gz: 608ccff3b9143a48bb16ca44f9746964f10481389e42cc91cf566889d2fdf224956a0f164b73d6515a7c7d9fb09fee8ef7488f7d2ef50aaec7666687e41e3a88
@@ -1,3 +1,8 @@
1
+ # 0.10.1
2
+
3
+ * actually implement support for custom ports in Node URL's. Despite being
4
+ documented, that didn't actually work until now.
5
+
1
6
  # 0.10
2
7
 
3
8
  * Add hook functionality. See README/manpage for documentation.
data/Rakefile CHANGED
@@ -48,42 +48,6 @@ end
48
48
 
49
49
  task 'build:all' => ['build:debsrc', 'build:rpmsrc']
50
50
 
51
- task :obs => 'build:all' do
52
- if !File.exist?('tmp/obs/home:terceiro:chake/chake')
53
- mkdir_p 'tmp/obs'
54
- chdir 'tmp/obs' do
55
- sh 'osc', 'checkout', 'home:terceiro:chake', 'chake'
56
- end
57
- end
58
-
59
- # remove old files
60
- chdir 'tmp/obs/home:terceiro:chake/chake' do
61
- Dir.glob('*').each do |f|
62
- sh 'osc', 'remove', '--force', f
63
- end
64
- end
65
-
66
- # copy over new files
67
- [
68
- "pkg/#{pkg.name}-#{pkg.version}.tar.gz",
69
- "pkg/#{pkg.name}.spec",
70
- "pkg/#{pkg.name}_#{pkg.version}.orig.tar.gz",
71
- "pkg/#{pkg.name}_#{pkg.version}-1.debian.tar.xz",
72
- "pkg/#{pkg.name}_#{pkg.version}-1.dsc",
73
- ].each do |f|
74
- sh 'cp', '--dereference', f, 'tmp/obs/home:terceiro:chake/chake'
75
- end
76
-
77
- # push new files to the repository
78
- chdir 'tmp/obs/home:terceiro:chake/chake' do
79
- Dir.glob('*').each do |f|
80
- sh 'osc', 'add', f
81
- end
82
- sh 'osc', 'commit', '--message', "#{pkg.name}, version #{pkg.version}"
83
- end
84
-
85
- end
86
-
87
51
  desc 'lists changes since last release'
88
52
  task :changelog do
89
53
  last_tag = `git tag | sort -V`.split.last
@@ -108,6 +72,6 @@ task :check_changelog do
108
72
  end
109
73
 
110
74
  desc 'Makes a release'
111
- task :release => [:check_tag, :check_changelog, :test, 'bundler:release', :obs]
75
+ task :release => [:check_tag, :check_changelog, :test, 'bundler:release']
112
76
 
113
77
  task :default => :test
@@ -5,7 +5,7 @@ module Chake
5
5
  class Ssh < Backend
6
6
 
7
7
  def scp
8
- ['scp', ssh_config].flatten.compact
8
+ ['scp', ssh_config, scp_options].flatten.compact
9
9
  end
10
10
 
11
11
  def scp_dest
@@ -21,7 +21,7 @@ module Chake
21
21
  end
22
22
 
23
23
  def command_runner
24
- [ssh_prefix, 'ssh', ssh_config, ssh_target].flatten.compact
24
+ [ssh_prefix, 'ssh', ssh_config, ssh_options, ssh_target].flatten.compact
25
25
  end
26
26
 
27
27
  def shell_command
@@ -31,7 +31,21 @@ module Chake
31
31
  private
32
32
 
33
33
  def rsync_ssh
34
- File.exist?(ssh_config_file) && ['-e', 'ssh -F ' + ssh_config_file ] || []
34
+ @rsync_ssh ||=
35
+ begin
36
+ ssh_command = 'ssh'
37
+ if File.exist?(ssh_config_file)
38
+ ssh_command += ' -F ' + ssh_config_file
39
+ end
40
+ if node.port
41
+ ssh_command += ' -p ' + node.port.to_s
42
+ end
43
+ if ssh_command == 'ssh'
44
+ []
45
+ else
46
+ ['-e', ssh_command]
47
+ end
48
+ end
35
49
  end
36
50
 
37
51
  def ssh_config
@@ -50,6 +64,14 @@ module Chake
50
64
  [node.remote_username, node.hostname].compact.join('@')
51
65
  end
52
66
 
67
+ def ssh_options
68
+ node.port && ['-p', node.port.to_s] || []
69
+ end
70
+
71
+ def scp_options
72
+ node.port && ['-P', node.port.to_s] || []
73
+ end
74
+
53
75
  end
54
76
 
55
77
  end
@@ -11,6 +11,7 @@ module Chake
11
11
  extend Forwardable
12
12
 
13
13
  attr_reader :hostname
14
+ attr_reader :port
14
15
  attr_reader :username
15
16
  attr_reader :remote_username
16
17
  attr_reader :path
@@ -25,16 +26,17 @@ module Chake
25
26
 
26
27
  def initialize(hostname, data = {})
27
28
  uri = URI.parse(hostname)
28
- if !uri.scheme && !uri.host && uri.path
29
+ if !uri.host && ((!uri.scheme && uri.path) || (uri.scheme && uri.opaque))
29
30
  uri = URI.parse("ssh://#{hostname}")
30
31
  end
31
- if uri.path.empty?
32
+ if uri.path && uri.path.empty?
32
33
  uri.path = nil
33
34
  end
34
35
 
35
36
  @backend_name = uri.scheme
36
37
 
37
38
  @hostname = uri.host
39
+ @port = uri.port
38
40
  @username = uri.user || Etc.getpwuid.name
39
41
  @remote_username = uri.user
40
42
  @path = uri.path || "/var/tmp/chef.#{username}"
@@ -1,3 +1,3 @@
1
1
  module Chake
2
- VERSION = "0.10"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -21,4 +21,17 @@ describe Chake::Backend::Ssh do
21
21
  expect(node.remote_username).to eq('myuser')
22
22
  end
23
23
 
24
+ context 'with a custom port' do
25
+ let(:node) { Chake::Node.new('ssh://myhost:2222') }
26
+ it 'uses port with ssh' do
27
+ expect(backend.command_runner).to eq(['ssh', '-p', '2222', 'myhost'])
28
+ end
29
+ it 'uses port with scp' do
30
+ expect(backend.scp).to eq(['scp', '-P', '2222'])
31
+ end
32
+ it 'uses port with rsync' do
33
+ expect(backend.send(:rsync_ssh)).to eq(['-e', 'ssh -p 2222'])
34
+ end
35
+ end
36
+
24
37
  end
@@ -34,6 +34,17 @@ describe Chake::Node do
34
34
  expect(with_data.data).to be_a(Hash)
35
35
  end
36
36
 
37
+ let(:with_port) { Chake::Node.new('ssh://foo.bar.com:2222') }
38
+ it('accepts a port specification') do
39
+ expect(with_port.port).to eq(2222)
40
+ end
41
+
42
+ let(:with_port_but_no_scheme) { Chake::Node.new('foo.bar.com:2222') }
43
+ it('accepts a port specification without a scheme') do
44
+ expect(with_port_but_no_scheme.port).to eq(2222)
45
+ expect(with_port_but_no_scheme.backend.to_s).to eq('ssh')
46
+ end
47
+
37
48
  [:run, :run_as_root, :rsync_dest].each do |method|
38
49
  it("delegates #{method} to backend") do
39
50
  node = simple
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chake
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.10'
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Terceiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler