sensu-plugins-minio 0.0.7 → 1.0.0

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
  SHA256:
3
- metadata.gz: 5e9a263cc7dfaccc08b8b3e77912446cc57311b89847e321acba839bb6022438
4
- data.tar.gz: 6580bfe8d6f051eb608aada8707a6bcf3241751cb3c001bf3f868d6f6a353974
3
+ metadata.gz: 144a116c5c586f1fa6d951dc893d8f184ee70cfc4c90ef2fbd0ada0e04d7e8dd
4
+ data.tar.gz: 98fa400a4401388b7db16f015ab3e81bed2babb41459b5c0f7a7a13731100e6e
5
5
  SHA512:
6
- metadata.gz: 4f3d68b5e7e1038453e787ecbc3811c721cef660ed432f21853186aab00e2ea62bed66b423c2963cfb1d9318fbe08d611c2243131d0c9970d6838619c17f6b2b
7
- data.tar.gz: ca7f4fcb79c96f4a411d6137e321bb339cd758a634ca95f822022be0a6c652bb297638f3fa594704bbf10ae54fd9b183ce569a38babe554bc1bf10d97643d5c9
6
+ metadata.gz: 03e42dd27a201ba2c70b6086103c9515e08352625cc3785e83a51d0a01b1d1f374fde5eda47f81af3eaaacdd754425b1294e24fbf5a7b62fa72fcc3f1ee0e6f5
7
+ data.tar.gz: f274315e2f90356e0491dd8896c8c63e6d6b24e2fb8fa53f8f4c308087a5c5c18bdaf0f0f2cca833371f88202828c8a3f29c06736b3fbf2fa66a7ba3c66feb80
@@ -0,0 +1,30 @@
1
+ name: main
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby-version: ['2.3.3', '2.5.1', '2.7.0']
19
+
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby-version }}
26
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
27
+ - name: Lint
28
+ run: bundle exec rubocop
29
+ - name: Run specs
30
+ run: bundle exec rspec
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in sensu-plugin-minio.gemspec
6
6
  gemspec
7
+
8
+ gem 'parallel', '< 1.20.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sensu-plugins-minio (0.0.7)
4
+ sensu-plugins-minio (1.0.0)
5
5
  sensu-plugin (~> 2.1)
6
6
 
7
7
  GEM
@@ -17,7 +17,7 @@ GEM
17
17
  jaro_winkler (1.5.4)
18
18
  json (2.6.2)
19
19
  mixlib-cli (1.7.0)
20
- parallel (1.22.1)
20
+ parallel (1.19.2)
21
21
  parser (3.1.2.0)
22
22
  ast (~> 2.4.1)
23
23
  public_suffix (4.0.7)
@@ -60,6 +60,7 @@ PLATFORMS
60
60
 
61
61
  DEPENDENCIES
62
62
  bundler (~> 2.1)
63
+ parallel (< 1.20.0)
63
64
  rake (~> 13.0)
64
65
  rspec (~> 3.10)
65
66
  rubocop (~> 0.54, <= 0.81)
@@ -21,6 +21,8 @@ require 'open3'
21
21
  class CheckMinioUpdate < Sensu::Plugin::Check::CLI
22
22
  include Sensu::Plugin::Utils
23
23
 
24
+ RELEASE_PATTERN = /(?<release>RELEASE.\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}Z)/.freeze # rubocop:disable Layout/LineLength
25
+
24
26
  option :checkurl,
25
27
  description: 'Base URL to check for updates',
26
28
  short: '-u URL',
@@ -39,49 +41,55 @@ class CheckMinioUpdate < Sensu::Plugin::Check::CLI
39
41
  default: 30
40
42
 
41
43
  def run
42
- checkurl = config[:checkurl]
43
- platform = config[:platform]
44
- timeout = config[:timeout].to_i
45
-
46
- begin
47
- Timeout.timeout(timeout) do
48
- latest_version = get_latest_version(checkurl, platform)
49
-
50
- if local_version == latest_version
51
- ok 'No new minio version available'
52
- else
53
- critical "New minio version available #{latest_version}"
54
- end
44
+ Timeout.timeout(config[:timeout].to_i) do
45
+ if local_version == latest_version
46
+ ok 'No new minio version available'
47
+ else
48
+ critical "New minio version available #{latest_version}"
55
49
  end
56
- rescue IOError => e
57
- unknown e.message.to_s
58
- rescue Timeout::Error
59
- unknown 'Connection timed out'
60
50
  end
51
+ rescue IOError => e
52
+ unknown e.message.to_s
53
+ rescue Timeout::Error
54
+ unknown 'Connection timed out'
61
55
  end
62
56
 
63
57
  private
64
58
 
65
- def get_latest_version(checkurl, platform)
66
- uri = URI.parse("#{checkurl}/#{platform}/minio.shasum")
67
- response = Net::HTTP.get_response(uri)
59
+ def latest_version
60
+ @latest_version ||= begin
61
+ uri = URI.parse("#{config[:checkurl]}/#{config[:platform]}/minio.shasum")
62
+ response = Net::HTTP.get_response(uri)
68
63
 
69
- unless response.is_a?(Net::HTTPSuccess)
70
- raise IOError, "Unable to gather latest minio version: #{response.body}"
71
- end
64
+ unless response.is_a?(Net::HTTPSuccess)
65
+ raise IOError, "Unable to gather latest minio version: #{response.body}"
66
+ end
72
67
 
73
- response.body.split.last.split('.', 2).last
68
+ extract_release(response.body)
69
+ end
74
70
  end
75
71
 
76
72
  def local_version
77
- stdout, stderr, status = Open3.capture3(
78
- { 'PATH' => ENV['PATH'] }, 'minio --version', unsetenv_others: true
79
- )
73
+ @local_version ||= begin
74
+ stdout, stderr, status = Open3.capture3(
75
+ { 'PATH' => ENV['PATH'] }, 'minio --version', unsetenv_others: true
76
+ )
77
+
78
+ unless status.success?
79
+ raise IOError, "Unable to gather local minio version: #{stderr}"
80
+ end
81
+
82
+ extract_release(stdout)
83
+ end
84
+ end
85
+
86
+ def extract_release(release_source_str)
87
+ match_data = RELEASE_PATTERN.match(release_source_str)
80
88
 
81
- unless status.success?
82
- raise IOError, "Unable to gather local minio version: #{stderr}"
89
+ if match_data.nil?
90
+ raise IOError, "Unable to extract release: #{release_source_str}"
83
91
  end
84
92
 
85
- stdout.lines.first.split.last
93
+ match_data[:release]
86
94
  end
87
95
  end
@@ -3,7 +3,7 @@
3
3
  module Sensu
4
4
  module Plugins
5
5
  module Minio
6
- VERSION = '0.0.7'
6
+ VERSION = '1.0.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-minio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hauke Altmann
8
8
  - Jonathan Schlue
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-07 00:00:00.000000000 Z
12
+ date: 2022-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sensu-plugin
@@ -109,6 +109,7 @@ executables:
109
109
  extensions: []
110
110
  extra_rdoc_files: []
111
111
  files:
112
+ - ".github/workflows/main.yml"
112
113
  - ".gitignore"
113
114
  - ".rubocop.yml"
114
115
  - ".ruby-version"
@@ -126,7 +127,7 @@ homepage: https://github.com/aboutsource/sensu-plugins-minio
126
127
  licenses:
127
128
  - MIT
128
129
  metadata: {}
129
- post_install_message:
130
+ post_install_message:
130
131
  rdoc_options: []
131
132
  require_paths:
132
133
  - lib
@@ -141,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  - !ruby/object:Gem::Version
142
143
  version: '0'
143
144
  requirements: []
144
- rubygems_version: 3.1.2
145
- signing_key:
145
+ rubygems_version: 3.3.15
146
+ signing_key:
146
147
  specification_version: 4
147
148
  summary: Check if there are updates for the local minio server instance
148
149
  test_files: []