kanrisuru 0.15.0 → 0.16.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/kanrisuru.gemspec +7 -3
- data/lib/kanrisuru/command.rb +6 -3
- data/lib/kanrisuru/core/disk/commands/lsblk.rb +6 -11
- data/lib/kanrisuru/core/disk/constants.rb +9 -0
- data/lib/kanrisuru/core/disk/parser.rb +1 -0
- data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
- data/lib/kanrisuru/core/disk.rb +1 -0
- data/lib/kanrisuru/core/dmi/commands/dmi.rb +1 -1
- data/lib/kanrisuru/core/file/commands/chmod.rb +1 -1
- data/lib/kanrisuru/core/file/commands/copy.rb +1 -3
- data/lib/kanrisuru/core/file/commands/mkdir.rb +11 -6
- data/lib/kanrisuru/core/file/commands/rm.rb +4 -1
- data/lib/kanrisuru/core/file/commands/touch.rb +2 -1
- data/lib/kanrisuru/core/system/commands/kill.rb +1 -1
- data/lib/kanrisuru/core/user/commands/create_user.rb +9 -17
- data/lib/kanrisuru/core/user/commands/delete_user.rb +1 -1
- data/lib/kanrisuru/core/user/commands/update_user.rb +14 -23
- data/lib/kanrisuru/core/zypper/commands/add_repo.rb +1 -8
- data/lib/kanrisuru/core/zypper/commands/add_service.rb +4 -2
- data/lib/kanrisuru/core/zypper/commands/info.rb +1 -2
- data/lib/kanrisuru/core/zypper/commands/install.rb +2 -3
- data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +1 -7
- data/lib/kanrisuru/core/zypper/commands/modify_service.rb +3 -1
- data/lib/kanrisuru/core/zypper/commands/remove.rb +1 -2
- data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +3 -3
- data/lib/kanrisuru/core/zypper/commands/remove_service.rb +6 -1
- data/lib/kanrisuru/core/zypper/commands/search.rb +1 -3
- data/lib/kanrisuru/core/zypper/commands/source_install.rb +2 -0
- data/lib/kanrisuru/core/zypper/commands.rb +10 -1
- data/lib/kanrisuru/mode/permission.rb +103 -0
- data/lib/kanrisuru/mode.rb +2 -98
- data/lib/kanrisuru/os_package.rb +2 -0
- data/lib/kanrisuru/remote/host.rb +1 -3
- data/lib/kanrisuru/result.rb +15 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/archive_spec.rb +1 -1
- data/spec/functional/core/disk_spec.rb +77 -0
- data/spec/functional/core/dmi_spec.rb +78 -0
- data/spec/functional/core/file_spec.rb +284 -0
- data/spec/functional/core/group_spec.rb +62 -0
- data/spec/functional/core/{ip/ip_address_label_spec.rb → ip_address_label_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_address_spec.rb → ip_address_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_link_spec.rb → ip_link_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_maddress_spec.rb → ip_maddress_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_neighbour_spec.rb → ip_neighbour_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_route_spec.rb → ip_route_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_rule_spec.rb → ip_rule_spec.rb} +0 -0
- data/spec/functional/core/{ip/ip_spec.rb → ip_spec.rb} +0 -0
- data/spec/functional/core/system_spec.rb +135 -0
- data/spec/functional/core/user_spec.rb +97 -0
- data/spec/functional/core/zypper_spec.rb +708 -0
- data/spec/functional/result_spec.rb +91 -44
- data/spec/helper/stub_network.rb +7 -3
- data/spec/unit/command_spec.rb +2 -0
- data/spec/unit/core/ip_spec.rb +12 -0
- metadata +23 -12
@@ -57,72 +57,119 @@ RSpec.describe Kanrisuru::Result do
|
|
57
57
|
expect(result.to_s).to eq('output')
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
context 'with to_a' do
|
61
|
+
it 'returns to_a on array result' do
|
62
|
+
command.handle_status(0)
|
63
|
+
result = described_class.new(command) do |_cmd|
|
64
|
+
[0, 1, 2, 3]
|
65
|
+
end
|
66
|
+
|
67
|
+
expect(result.to_a).to eq([0, 1, 2, 3])
|
64
68
|
end
|
65
69
|
|
66
|
-
|
67
|
-
|
70
|
+
it 'returns to_a on non-array result' do
|
71
|
+
command.handle_status(0)
|
72
|
+
result = described_class.new(command) do |_cmd|
|
73
|
+
'output'
|
74
|
+
end
|
68
75
|
|
69
|
-
|
70
|
-
command.handle_status(0)
|
71
|
-
result = described_class.new(command) do |_cmd|
|
72
|
-
'output'
|
76
|
+
expect(result.to_a).to eq(['output'])
|
73
77
|
end
|
74
78
|
|
75
|
-
|
76
|
-
|
79
|
+
it 'returns to_i on integer return value' do
|
80
|
+
command.handle_status(0)
|
81
|
+
result = described_class.new(command) do |_cmd|
|
82
|
+
55
|
83
|
+
end
|
77
84
|
|
78
|
-
|
79
|
-
command.handle_status(0)
|
80
|
-
result = described_class.new(command) do |_cmd|
|
81
|
-
55
|
85
|
+
expect(result.to_i).to eq(55)
|
82
86
|
end
|
83
|
-
|
84
|
-
expect(result.to_i).to eq(55)
|
85
87
|
end
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
context 'with to_i' do
|
90
|
+
it 'returns to_i on non-integer return value' do
|
91
|
+
command.handle_status(0)
|
92
|
+
result = described_class.new(command) do |_cmd|
|
93
|
+
'100'
|
94
|
+
end
|
92
95
|
|
93
|
-
|
96
|
+
expect(result.to_i).to eq(100)
|
94
97
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
+
result = described_class.new(command) do |_cmd|
|
99
|
+
'hello'
|
100
|
+
end
|
98
101
|
|
99
|
-
|
102
|
+
expect(result.to_i).to eq(0)
|
100
103
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
+
result = described_class.new(command) do |_cmd|
|
105
|
+
[0, 1, 2, 3]
|
106
|
+
end
|
104
107
|
|
105
|
-
|
108
|
+
expect(result.to_i).to eq([0, 1, 2, 3])
|
106
109
|
|
107
|
-
|
108
|
-
|
110
|
+
result = described_class.new(command) do |_cmd|
|
111
|
+
%w[0 1 2 3]
|
112
|
+
end
|
113
|
+
|
114
|
+
expect(result.to_i).to eq([0, 1, 2, 3])
|
115
|
+
|
116
|
+
result = described_class.new(command)
|
117
|
+
expect(result.to_i).to be_nil
|
109
118
|
end
|
110
119
|
|
111
|
-
|
120
|
+
it 'raises error on to_i for invalid data type' do
|
121
|
+
command.handle_status(0)
|
122
|
+
result = described_class.new(command) do |_cmd|
|
123
|
+
{ 'hello' => 'world' }
|
124
|
+
end
|
112
125
|
|
113
|
-
|
114
|
-
|
126
|
+
expect do
|
127
|
+
result.to_i
|
128
|
+
end.to raise_error(NoMethodError)
|
129
|
+
end
|
115
130
|
end
|
116
131
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
132
|
+
context 'with to_f' do
|
133
|
+
it 'returns to_f on non-integer return value' do
|
134
|
+
command.handle_status(0)
|
135
|
+
result = described_class.new(command) do |_cmd|
|
136
|
+
'100.5'
|
137
|
+
end
|
138
|
+
|
139
|
+
expect(result.to_f).to eq(100.5)
|
140
|
+
|
141
|
+
result = described_class.new(command) do |_cmd|
|
142
|
+
'hello'
|
143
|
+
end
|
144
|
+
|
145
|
+
expect(result.to_f).to eq(0)
|
146
|
+
|
147
|
+
result = described_class.new(command) do |_cmd|
|
148
|
+
[0.1, 1.2, 2.3, 3.4]
|
149
|
+
end
|
150
|
+
|
151
|
+
expect(result.to_f).to eq([0.1, 1.2, 2.3, 3.4])
|
152
|
+
|
153
|
+
result = described_class.new(command) do |_cmd|
|
154
|
+
%w[0.1 1.2 2.3 3.4]
|
155
|
+
end
|
156
|
+
|
157
|
+
expect(result.to_f).to eq([0.1, 1.2, 2.3, 3.4])
|
158
|
+
|
159
|
+
result = described_class.new(command)
|
160
|
+
expect(result.to_f).to be_nil
|
121
161
|
end
|
122
162
|
|
123
|
-
|
124
|
-
|
125
|
-
|
163
|
+
it 'raises error on to_f for invalid data type' do
|
164
|
+
command.handle_status(0)
|
165
|
+
result = described_class.new(command) do |_cmd|
|
166
|
+
{ 'hello' => 'world' }
|
167
|
+
end
|
168
|
+
|
169
|
+
expect do
|
170
|
+
result.to_f
|
171
|
+
end.to raise_error(NoMethodError)
|
172
|
+
end
|
126
173
|
end
|
127
174
|
|
128
175
|
it 'returns success string variant on inspect' do
|
data/spec/helper/stub_network.rb
CHANGED
@@ -69,8 +69,12 @@ class StubNetwork
|
|
69
69
|
status = opts[:status] || 0
|
70
70
|
command.handle_status(status)
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
if opts[:return_value].nil?
|
73
|
+
Kanrisuru::Result.new(command, true) do |_cmd|
|
74
|
+
block.call(args)
|
75
|
+
end
|
76
|
+
else
|
77
|
+
opts[:return_value]
|
74
78
|
end
|
75
79
|
end
|
76
80
|
end
|
@@ -126,7 +130,7 @@ class StubNetwork
|
|
126
130
|
operating_system: 'GNU/Linux',
|
127
131
|
hardware_platform: 'x86_64',
|
128
132
|
processor: 'x86_64',
|
129
|
-
release: '
|
133
|
+
release: 'opensuse_leap',
|
130
134
|
version: 15.2
|
131
135
|
}
|
132
136
|
}
|
data/spec/unit/command_spec.rb
CHANGED
@@ -11,6 +11,7 @@ RSpec.describe Kanrisuru::Command do
|
|
11
11
|
expect(command).to respond_to(:success?)
|
12
12
|
expect(command).to respond_to(:failure?)
|
13
13
|
expect(command).to respond_to(:to_i)
|
14
|
+
expect(command).to respond_to(:to_f)
|
14
15
|
expect(command).to respond_to(:to_s)
|
15
16
|
expect(command).to respond_to(:to_a)
|
16
17
|
expect(command).to respond_to(:to_json)
|
@@ -26,6 +27,7 @@ RSpec.describe Kanrisuru::Command do
|
|
26
27
|
expect(command).to respond_to(:append_value)
|
27
28
|
expect(command).to respond_to(:append_arg)
|
28
29
|
expect(command).to respond_to(:append_flag)
|
30
|
+
expect(command).to respond_to(:append_flag_no)
|
29
31
|
expect(command).to respond_to(:append_valid_exit_code)
|
30
32
|
end
|
31
33
|
|
data/spec/unit/core/ip_spec.rb
CHANGED
@@ -35,6 +35,18 @@ RSpec.describe Kanrisuru::Core::IP do
|
|
35
35
|
])
|
36
36
|
)
|
37
37
|
|
38
|
+
expect(Kanrisuru::Core::IP::IP_FAMILIES).to(eq(%w[inet inet6 link]))
|
39
|
+
expect(Kanrisuru::Core::IP::IP_SCOPES).to(eq(%w[global site link host]))
|
40
|
+
expect(Kanrisuru::Core::IP::IP_LINK_TYPES).to(
|
41
|
+
eq(%w[
|
42
|
+
vlan veth vcan vxcan dummy ifb macvlan macvtap
|
43
|
+
bridge bond team ipoib ip6tnl ipip sit vxlan
|
44
|
+
gre gretap erspan ip6gre ip6gretap ip6erspan
|
45
|
+
vti nlmon team_slave bond_slave bridge_slave
|
46
|
+
ipvlan ipvtap geneve vrf macsec netdevsim rmnet
|
47
|
+
xfrm bareudp hsr
|
48
|
+
])
|
49
|
+
)
|
38
50
|
expect(Kanrisuru::Core::IP::IPLinkProperty.new).to respond_to(
|
39
51
|
:index, :name, :flags, :mtu,
|
40
52
|
:qdisc, :state, :group, :qlen,
|
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.
|
4
|
+
version: 0.16.3
|
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-12-
|
11
|
+
date: 2021-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel_tests
|
@@ -136,8 +136,8 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '6.1'
|
139
|
-
description: Kanrisuru helps manage remote servers with objected oriented ruby.
|
140
|
-
come back as structured data, parsed, prepared and ready
|
139
|
+
description: " Kanrisuru helps manage remote servers with objected oriented ruby.
|
140
|
+
\n Results come back as structured data, parsed, prepared and ready.\n"
|
141
141
|
email: ryan@avamia.com
|
142
142
|
executables: []
|
143
143
|
extensions: []
|
@@ -193,11 +193,13 @@ files:
|
|
193
193
|
- lib/kanrisuru/core/disk/commands/df.rb
|
194
194
|
- lib/kanrisuru/core/disk/commands/du.rb
|
195
195
|
- lib/kanrisuru/core/disk/commands/lsblk.rb
|
196
|
+
- lib/kanrisuru/core/disk/constants.rb
|
196
197
|
- lib/kanrisuru/core/disk/parser.rb
|
197
198
|
- lib/kanrisuru/core/disk/parsers/blkid.rb
|
198
199
|
- lib/kanrisuru/core/disk/parsers/df.rb
|
199
200
|
- lib/kanrisuru/core/disk/parsers/du.rb
|
200
201
|
- lib/kanrisuru/core/disk/parsers/lsblk.rb
|
202
|
+
- lib/kanrisuru/core/disk/parsers/lsblk_version.rb
|
201
203
|
- lib/kanrisuru/core/disk/types.rb
|
202
204
|
- lib/kanrisuru/core/dmi.rb
|
203
205
|
- lib/kanrisuru/core/dmi/commands.rb
|
@@ -415,6 +417,7 @@ files:
|
|
415
417
|
- lib/kanrisuru/core/zypper/types.rb
|
416
418
|
- lib/kanrisuru/logger.rb
|
417
419
|
- lib/kanrisuru/mode.rb
|
420
|
+
- lib/kanrisuru/mode/permission.rb
|
418
421
|
- lib/kanrisuru/os_package.rb
|
419
422
|
- lib/kanrisuru/os_package/collection.rb
|
420
423
|
- lib/kanrisuru/os_package/define.rb
|
@@ -439,22 +442,29 @@ files:
|
|
439
442
|
- lib/kanrisuru/version.rb
|
440
443
|
- spec/functional/core/apt_spec.rb
|
441
444
|
- spec/functional/core/archive_spec.rb
|
445
|
+
- spec/functional/core/disk_spec.rb
|
446
|
+
- spec/functional/core/dmi_spec.rb
|
447
|
+
- spec/functional/core/file_spec.rb
|
442
448
|
- spec/functional/core/find_spec.rb
|
443
|
-
- spec/functional/core/
|
444
|
-
- spec/functional/core/
|
445
|
-
- spec/functional/core/
|
446
|
-
- spec/functional/core/
|
447
|
-
- spec/functional/core/
|
448
|
-
- spec/functional/core/
|
449
|
-
- spec/functional/core/
|
450
|
-
- spec/functional/core/
|
449
|
+
- spec/functional/core/group_spec.rb
|
450
|
+
- spec/functional/core/ip_address_label_spec.rb
|
451
|
+
- spec/functional/core/ip_address_spec.rb
|
452
|
+
- spec/functional/core/ip_link_spec.rb
|
453
|
+
- spec/functional/core/ip_maddress_spec.rb
|
454
|
+
- spec/functional/core/ip_neighbour_spec.rb
|
455
|
+
- spec/functional/core/ip_route_spec.rb
|
456
|
+
- spec/functional/core/ip_rule_spec.rb
|
457
|
+
- spec/functional/core/ip_spec.rb
|
451
458
|
- spec/functional/core/mount_spec.rb
|
452
459
|
- spec/functional/core/path_spec.rb
|
453
460
|
- spec/functional/core/socket_spec.rb
|
454
461
|
- spec/functional/core/stat_spec.rb
|
455
462
|
- spec/functional/core/stream_spec.rb
|
463
|
+
- spec/functional/core/system_spec.rb
|
456
464
|
- spec/functional/core/transfer_spec.rb
|
465
|
+
- spec/functional/core/user_spec.rb
|
457
466
|
- spec/functional/core/yum_spec.rb
|
467
|
+
- spec/functional/core/zypper_spec.rb
|
458
468
|
- spec/functional/remote/cluster_spec.rb
|
459
469
|
- spec/functional/remote/cpu_spec.rb
|
460
470
|
- spec/functional/remote/env_spec.rb
|
@@ -677,6 +687,7 @@ licenses:
|
|
677
687
|
metadata:
|
678
688
|
source_code_uri: https://github.com/avamia/kanrisuru/
|
679
689
|
changelog_uri: https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md
|
690
|
+
rubygems_mfa_required: 'true'
|
680
691
|
post_install_message:
|
681
692
|
rdoc_options: []
|
682
693
|
require_paths:
|