itamae 1.2.14 → 1.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/itamae.gemspec +1 -0
- data/lib/itamae/backend.rb +14 -7
- data/lib/itamae/version.txt +1 -1
- data/spec/unit/lib/itamae/backend_spec.rb +94 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ca0bac3e644c84e79f48f7a79d593cb5abdaf19
|
4
|
+
data.tar.gz: 30ddcc2257758291ffe1202e9c4bdb70dafce38a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef86975d368cab1285c77e7ea78aba0f14bf50aba625405db6f6929df30a7150e0b18c340a8041d3f8f97c2cbfec2dbe6ed2d4ba4e56a0511dbb5c89f3f3a930
|
7
|
+
data.tar.gz: 7bf26d88e69315df198c28cef5ea9c1443d374dc86fb27ec0c1a8129dfb283b3a788193f54fe19a25d7fea1f5f1da3ccea4ed7347a2e998126976cc58c0e7c9e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v1.2.15
|
2
|
+
|
3
|
+
Bugfixes
|
4
|
+
|
5
|
+
- [Fix --no-sudo to work properly (by @evalphobia)](https://github.com/itamae-kitchen/itamae/pull/126)
|
6
|
+
- [Fix a glitch on raising exception when source doesn't exist (by @mozamimy)](https://github.com/itamae-kitchen/itamae/pull/125)
|
7
|
+
|
1
8
|
## v1.2.14
|
2
9
|
|
3
10
|
Features
|
data/itamae.gemspec
CHANGED
data/lib/itamae/backend.rb
CHANGED
@@ -26,6 +26,7 @@ module Itamae
|
|
26
26
|
module Backend
|
27
27
|
UnknownBackendTypeError = Class.new(StandardError)
|
28
28
|
CommandExecutionError = Class.new(StandardError)
|
29
|
+
SourceNotExistError = Class.new(StandardError)
|
29
30
|
|
30
31
|
class << self
|
31
32
|
def create(type, opts = {})
|
@@ -119,18 +120,21 @@ module Itamae
|
|
119
120
|
def send_file(src, dst)
|
120
121
|
Logger.debug "Sending a file from '#{src}' to '#{dst}'..."
|
121
122
|
unless ::File.exist?(src)
|
122
|
-
raise
|
123
|
+
raise SourceNotExistError, "The file '#{src}' doesn't exist."
|
124
|
+
end
|
125
|
+
unless ::File.file?(src)
|
126
|
+
raise SourceNotExistError, "'#{src}' is not a file."
|
123
127
|
end
|
124
128
|
@backend.send_file(src, dst)
|
125
129
|
end
|
126
130
|
|
127
131
|
def send_directory(src, dst)
|
128
132
|
Logger.debug "Sending a directory from '#{src}' to '#{dst}'..."
|
129
|
-
unless ::File.directory?(src)
|
130
|
-
raise Error, "'#{src}' is not directory."
|
131
|
-
end
|
132
133
|
unless ::File.exist?(src)
|
133
|
-
raise
|
134
|
+
raise SourceNotExistError, "The directory '#{src}' doesn't exist."
|
135
|
+
end
|
136
|
+
unless ::File.directory?(src)
|
137
|
+
raise SourceNotExistError, "'#{src}' is not a directory."
|
134
138
|
end
|
135
139
|
@backend.send_directory(src, dst)
|
136
140
|
end
|
@@ -164,7 +168,7 @@ module Itamae
|
|
164
168
|
Specinfra::Backend::Ssh.new(
|
165
169
|
request_pty: true,
|
166
170
|
host: ssh_options[:host_name],
|
167
|
-
disable_sudo:
|
171
|
+
disable_sudo: disable_sudo?,
|
168
172
|
ssh_options: ssh_options,
|
169
173
|
)
|
170
174
|
end
|
@@ -179,7 +183,6 @@ module Itamae
|
|
179
183
|
opts[:user] = @options[:user] || opts[:user] || Etc.getlogin
|
180
184
|
opts[:keys] = [@options[:key]] if @options[:key]
|
181
185
|
opts[:port] = @options[:port] if @options[:port]
|
182
|
-
opts[:disable_sudo] = true unless @options[:sudo]
|
183
186
|
|
184
187
|
if @options[:vagrant]
|
185
188
|
config = Tempfile.new('', Dir.tmpdir)
|
@@ -197,6 +200,10 @@ module Itamae
|
|
197
200
|
|
198
201
|
opts
|
199
202
|
end
|
203
|
+
|
204
|
+
def disable_sudo?
|
205
|
+
!@options[:sudo]
|
206
|
+
end
|
200
207
|
end
|
201
208
|
|
202
209
|
class Docker < Base
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.15
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
module Itamae
|
5
|
+
module Backend
|
6
|
+
describe Base do
|
7
|
+
include FakeFS::SpecHelpers
|
8
|
+
|
9
|
+
class Klass < Itamae::Backend::Base
|
10
|
+
def initialize(_)
|
11
|
+
@backend = Object.new
|
12
|
+
@backend.stub(:send_file)
|
13
|
+
@backend.stub(:send_directory)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".send_file" do
|
18
|
+
context "the source file doesn't exist" do
|
19
|
+
subject { -> { Klass.new("dummy").send_file("src", "dst") } }
|
20
|
+
it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "The file 'src' doesn't exist.") }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "the source file exist, but it is not a regular file" do
|
24
|
+
before { Dir.mkdir("src") }
|
25
|
+
subject { -> { Klass.new("dummy").send_file("src", "dst") } }
|
26
|
+
it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "'src' is not a file.") }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "the source file is a regular file" do
|
30
|
+
before { FileUtils.touch("src") }
|
31
|
+
subject { -> { Klass.new("dummy").send_file("src", "dst") } }
|
32
|
+
it { expect { subject }.not_to raise_error }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".send_directory" do
|
37
|
+
context "the source directory doesn't exist" do
|
38
|
+
subject { -> { Klass.new("dummy").send_directory("src", "dst") } }
|
39
|
+
it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "The directory 'src' doesn't exist.") }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "the source directory exist, but it is not a directory" do
|
43
|
+
before { FileUtils.touch("src") }
|
44
|
+
subject { -> { Klass.new("dummy").send_directory("src", "dst") } }
|
45
|
+
it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "'src' is not a directory.") }
|
46
|
+
end
|
47
|
+
|
48
|
+
context "the source directory is a directory" do
|
49
|
+
before { Dir.mkdir("src") }
|
50
|
+
subject { -> { Klass.new("dummy").send_directory("src", "dst") } }
|
51
|
+
it { expect { subject }.not_to raise_error }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe Ssh do
|
57
|
+
|
58
|
+
describe "#ssh_options" do
|
59
|
+
subject { ssh.send(:ssh_options) }
|
60
|
+
|
61
|
+
let!(:ssh) { described_class.new(options) }
|
62
|
+
let!(:host_name) { "example.com" }
|
63
|
+
let!(:default_option) do
|
64
|
+
opts = {}
|
65
|
+
opts[:host_name] = nil
|
66
|
+
opts.merge!(Net::SSH::Config.for(host_name))
|
67
|
+
opts[:user] = opts[:user] || Etc.getlogin
|
68
|
+
opts
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with host option" do
|
72
|
+
let(:options) { {host: host_name} }
|
73
|
+
it { is_expected.to eq( default_option.merge({host_name: host_name}) ) }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#disable_sudo?" do
|
78
|
+
subject { ssh.send(:disable_sudo?) }
|
79
|
+
|
80
|
+
let!(:ssh) { described_class.new(options)}
|
81
|
+
|
82
|
+
context "when sudo option is true" do
|
83
|
+
let(:options) { {sudo: true} }
|
84
|
+
it { is_expected.to eq(false) }
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when sudo option is false" do
|
88
|
+
let(:options) { {sudo: false} }
|
89
|
+
it { is_expected.to eq(true) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -170,6 +170,20 @@ dependencies:
|
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '1.20'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: fakefs
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
173
187
|
description:
|
174
188
|
email:
|
175
189
|
- ryota.arai@gmail.com
|
@@ -233,6 +247,7 @@ files:
|
|
233
247
|
- spec/integration/recipes/redefine.rb
|
234
248
|
- spec/integration/recipes/templates/template_auto.erb
|
235
249
|
- spec/integration/spec_helper.rb
|
250
|
+
- spec/unit/lib/itamae/backend_spec.rb
|
236
251
|
- spec/unit/lib/itamae/config_spec.rb
|
237
252
|
- spec/unit/lib/itamae/logger_spec.rb
|
238
253
|
- spec/unit/lib/itamae/node_spec.rb
|
@@ -281,6 +296,7 @@ test_files:
|
|
281
296
|
- spec/integration/recipes/redefine.rb
|
282
297
|
- spec/integration/recipes/templates/template_auto.erb
|
283
298
|
- spec/integration/spec_helper.rb
|
299
|
+
- spec/unit/lib/itamae/backend_spec.rb
|
284
300
|
- spec/unit/lib/itamae/config_spec.rb
|
285
301
|
- spec/unit/lib/itamae/logger_spec.rb
|
286
302
|
- spec/unit/lib/itamae/node_spec.rb
|