kanrisuru 0.8.10 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +2 -2
- data/lib/kanrisuru/core/file.rb +24 -5
- data/lib/kanrisuru/remote/cluster.rb +1 -1
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/file_spec.rb +33 -5
- data/spec/functional/os_package_spec.rb +3 -3
- data/spec/functional/remote/cluster_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1537cdde3ded7563e59018ddb94f1c05bb17ff486c87f6113eaa1800b6f7c338
|
4
|
+
data.tar.gz: 571b0fef3b4d780d3fac4f485f7f1b1dd14bd3c73253a7b5649ae7e86975fd81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2351ae7e335b61a1362c15a08540977c5d366ae2c441882f4feff32bc7939da71312dc5f380fa707a6c3cb187e81d413d558ae55e31e395d069e1a3c5e3f2a08
|
7
|
+
data.tar.gz: 2fbb6a9649eb2a67c46bc0a617cd22965738dfcbb092b4b99da588ae70518b4a0dfc79aa2da55c58d53f760170a5c33c844a86aae97f56eeed4628c735a65546
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## Kanrisuru 0.8.14 (October 8, 20201)
|
2
|
+
* Update `Kanrisuru::Remote::Cluster` instantiation method to use array splat instead of passing array directly.
|
3
|
+
|
4
|
+
## Kanrisuru 0.8.13 (October 4, 20201)
|
5
|
+
* Fix `wc` command. Ensure result parsing is cast to integer values.
|
6
|
+
|
7
|
+
## Kanrisuru 0.8.12 (October 4, 20201)
|
8
|
+
* Refactor `rmdir` command to only work on empty directories.
|
9
|
+
|
10
|
+
## Kanrisuru 0.8.11 (October 1, 20201)
|
11
|
+
* Allow `Kanrisuru::Mode` as mode type option in mkdir method.
|
12
|
+
|
1
13
|
## Kanrisuru 0.8.10 (August 24, 20201)
|
2
14
|
* Fix bug with rspec test case.
|
3
15
|
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ result.path # => /home/ubuntu
|
|
48
48
|
|
49
49
|
### Cluster
|
50
50
|
```ruby
|
51
|
-
cluster = Kanrisuru::Remote::Cluster.new(
|
51
|
+
cluster = Kanrisuru::Remote::Cluster.new({
|
52
52
|
host: 'host1', username: 'ubuntu', keys: ['~/.ssh/id_rsa']
|
53
53
|
}, {
|
54
54
|
host: 'host2', username: 'alice', keys: ['~/.ssh/id_rsa']
|
@@ -72,7 +72,7 @@ host.execute(command)
|
|
72
72
|
command.success? #=> true
|
73
73
|
command.to_s #=> Linux
|
74
74
|
|
75
|
-
cluster = Kanrisuru::Remote::Cluster.new(
|
75
|
+
cluster = Kanrisuru::Remote::Cluster.new(host, {host: 'host2', username: 'alice', keys: ['~/.ssh/id_rsa']})
|
76
76
|
|
77
77
|
cluster.execute('uname') #=> {host: 'host1', result: 'Linux'}, {host: 'host2', result: 'Linux'}
|
78
78
|
```
|
data/lib/kanrisuru/core/file.rb
CHANGED
@@ -206,10 +206,19 @@ module Kanrisuru
|
|
206
206
|
Kanrisuru::Result.new(command)
|
207
207
|
end
|
208
208
|
|
209
|
-
def rmdir(
|
210
|
-
|
209
|
+
def rmdir(paths, opts = {})
|
210
|
+
paths = [paths] if paths.instance_of?(String)
|
211
|
+
paths.each do |path|
|
212
|
+
raise ArgumentError, "Can't delete root path" if path == '/' || realpath(path).path == '/'
|
213
|
+
end
|
214
|
+
|
215
|
+
command = Kanrisuru::Command.new("rmdir #{paths.join(' ')}")
|
216
|
+
command.append_flag('--ignore-fail-on-non-empty', opts[:silent])
|
217
|
+
command.append_flag('--parents', opts[:parents])
|
218
|
+
|
219
|
+
execute_shell(command)
|
211
220
|
|
212
|
-
|
221
|
+
Kanrisuru::Result.new(command)
|
213
222
|
end
|
214
223
|
|
215
224
|
def mkdir(path, opts = {})
|
@@ -219,7 +228,17 @@ module Kanrisuru
|
|
219
228
|
|
220
229
|
command = Kanrisuru::Command.new("mkdir #{path}")
|
221
230
|
command.append_flag('-p', opts[:silent])
|
222
|
-
|
231
|
+
|
232
|
+
if Kanrisuru::Util.present?(opts[:mode])
|
233
|
+
mode = opts[:mode]
|
234
|
+
if mode.instance_of?(Kanrisuru::Mode)
|
235
|
+
mode = mode.numeric
|
236
|
+
elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
|
237
|
+
mode = Kanrisuru::Mode.new(mode).numeric
|
238
|
+
end
|
239
|
+
|
240
|
+
command.append_arg('-m', mode)
|
241
|
+
end
|
223
242
|
|
224
243
|
execute_shell(command)
|
225
244
|
|
@@ -313,7 +332,7 @@ module Kanrisuru
|
|
313
332
|
execute_shell(command)
|
314
333
|
|
315
334
|
Kanrisuru::Result.new(command) do |cmd|
|
316
|
-
items = cmd.
|
335
|
+
items = cmd.to_s.split
|
317
336
|
FileCount.new(items[0].to_i, items[1].to_i, items[2].to_i)
|
318
337
|
end
|
319
338
|
end
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -40,8 +40,8 @@ RSpec.describe Kanrisuru::Core::File do
|
|
40
40
|
keys: [host_json['ssh_key']]
|
41
41
|
)
|
42
42
|
|
43
|
-
host.
|
44
|
-
host.
|
43
|
+
host.rm("#{host_json['home']}/.kanrisuru_spec_files", force: true, recursive: true)
|
44
|
+
host.rm("#{host_json['home']}/extract-tar-files", force: true, recursive: true) if host.dir?("#{host_json['home']}/extract-tar-files")
|
45
45
|
host.disconnect
|
46
46
|
end
|
47
47
|
|
@@ -322,16 +322,44 @@ RSpec.describe Kanrisuru::Core::File do
|
|
322
322
|
expect(host.empty_file?(path)).to eq(false)
|
323
323
|
end
|
324
324
|
|
325
|
+
it 'removes directories' do
|
326
|
+
result = host.mkdir("#{spec_dir}/directory/1", silent: true)
|
327
|
+
expect(result).to be_success
|
328
|
+
|
329
|
+
result = host.mkdir("#{spec_dir}/directory/2", silent: true)
|
330
|
+
expect(result).to be_success
|
331
|
+
|
332
|
+
result = host.mkdir("#{spec_dir}/directory/3", silent: true)
|
333
|
+
expect(result).to be_success
|
334
|
+
|
335
|
+
result = host.rmdir(["#{spec_dir}/directory/1", "#{spec_dir}/directory/2"])
|
336
|
+
expect(result).to be_success
|
337
|
+
|
338
|
+
## Can't delete non empty dir
|
339
|
+
result = host.rmdir("#{spec_dir}/directory")
|
340
|
+
expect(result).to be_failure
|
341
|
+
|
342
|
+
result = host.rmdir("#{spec_dir}/directory/3")
|
343
|
+
expect(result).to be_success
|
344
|
+
end
|
345
|
+
|
325
346
|
it 'counts a file' do
|
326
347
|
result = host.wc('/etc/hosts')
|
327
348
|
|
328
349
|
expect(result.success?).to eq(true)
|
329
350
|
expect(result).to respond_to(:lines, :words, :characters)
|
330
351
|
|
331
|
-
|
332
|
-
|
352
|
+
## Need to remap data including newline chars to get byte size
|
353
|
+
data = host.cat('/etc/hosts').command.raw_result
|
354
|
+
doc = data.map(&:lines).flatten
|
355
|
+
|
356
|
+
lines = doc.length
|
357
|
+
words = doc.map(&:split).flatten
|
358
|
+
chars = doc.map(&:length).flatten
|
333
359
|
|
334
|
-
expect(lines).to eq(
|
360
|
+
expect(result.lines).to eq(doc.length)
|
361
|
+
expect(result.words).to eq(words.length)
|
362
|
+
expect(result.characters).to eq(chars.sum)
|
335
363
|
end
|
336
364
|
end
|
337
365
|
end
|
@@ -111,7 +111,7 @@ RSpec.describe Kanrisuru::OsPackage do
|
|
111
111
|
host = Kanrisuru::Remote::Host.new(host: '127.0.0.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
|
112
112
|
host2 = Kanrisuru::Remote::Host.new(host: 'localhost', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
|
113
113
|
|
114
|
-
cluster = Kanrisuru::Remote::Cluster.new(
|
114
|
+
cluster = Kanrisuru::Remote::Cluster.new(host, host2)
|
115
115
|
|
116
116
|
expect(host).to respond_to(:tester)
|
117
117
|
expect(host.tester).to eq('hello ubuntu')
|
@@ -125,7 +125,7 @@ RSpec.describe Kanrisuru::OsPackage do
|
|
125
125
|
host = Kanrisuru::Remote::Host.new(host: '127.0.0.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
|
126
126
|
host2 = Kanrisuru::Remote::Host.new(host: 'localhost', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
|
127
127
|
|
128
|
-
cluster = Kanrisuru::Remote::Cluster.new(
|
128
|
+
cluster = Kanrisuru::Remote::Cluster.new(host, host2)
|
129
129
|
|
130
130
|
expect(host).to respond_to(:asdf)
|
131
131
|
expect(host.asdf).to respond_to(:tester)
|
@@ -151,7 +151,7 @@ RSpec.describe Kanrisuru::OsPackage do
|
|
151
151
|
host2 = Kanrisuru::Remote::Host.new(host: 'centos-host', username: 'centos', keys: ['~/.ssh/id_rsa'])
|
152
152
|
host3 = Kanrisuru::Remote::Host.new(host: 'opensuse-host', username: 'opensuse', keys: ['~/.ssh/id_rsa'])
|
153
153
|
|
154
|
-
cluster = Kanrisuru::Remote::Cluster.new(
|
154
|
+
cluster = Kanrisuru::Remote::Cluster.new(host1, host2, host3)
|
155
155
|
|
156
156
|
expect(host1).to respond_to(:output)
|
157
157
|
expect(host2).to respond_to(:output)
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
RSpec.describe Kanrisuru::Remote::Cluster do
|
6
6
|
context 'with ubuntu' do
|
7
7
|
it 'gets hostname for cluster' do
|
8
|
-
cluster = described_class.new(
|
8
|
+
cluster = described_class.new({
|
9
9
|
host: 'localhost',
|
10
10
|
username: 'ubuntu',
|
11
11
|
keys: ['~/.ssh/id_rsa']
|
@@ -13,7 +13,7 @@ RSpec.describe Kanrisuru::Remote::Cluster do
|
|
13
13
|
host: '127.0.0.1',
|
14
14
|
username: 'ubuntu',
|
15
15
|
keys: ['~/.ssh/id_rsa']
|
16
|
-
}
|
16
|
+
})
|
17
17
|
|
18
18
|
expect(cluster.hostname).to match([
|
19
19
|
{ host: 'localhost', result: 'ubuntu' },
|
@@ -24,7 +24,7 @@ RSpec.describe Kanrisuru::Remote::Cluster do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'can ping host cluster' do
|
27
|
-
cluster = described_class.new(
|
27
|
+
cluster = described_class.new({
|
28
28
|
host: 'localhost',
|
29
29
|
username: 'ubuntu',
|
30
30
|
keys: ['~/.ssh/id_rsa']
|
@@ -32,7 +32,7 @@ RSpec.describe Kanrisuru::Remote::Cluster do
|
|
32
32
|
host: '127.0.0.1',
|
33
33
|
username: 'ubuntu',
|
34
34
|
keys: ['~/.ssh/id_rsa']
|
35
|
-
}
|
35
|
+
})
|
36
36
|
|
37
37
|
expect(cluster.ping?).to match([
|
38
38
|
{ host: 'localhost', result: true },
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|