philae 0.2.12 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/philae/etcd_probe.rb +20 -20
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98c6b24b9ffa3987fffbb4a47f404e8d20e728663be1dd3a6953972bfab2a7d6
4
- data.tar.gz: f646a2b162c96cf3eced95b894f75ab74e64a13fb9dc40618ebf6757a721a068
3
+ metadata.gz: 4058dbbd9d47df1d46c0bb68315c17dfd38981a3d8d884be768df8aca9fa68d0
4
+ data.tar.gz: f745431b27b4371084f53ae649c94b362164ce68ab88353a7c8cee6213ccd014
5
5
  SHA512:
6
- metadata.gz: c0a665aee100b59fa4057f1cb688aebf8fcf52282408142b3186d53da9e236522ad74c2945c26f0be66e38a377329cfb494863e24a85acde4f7ac72b4a7102e8
7
- data.tar.gz: 8316c82012b480bb5cd6b43b2992a5b6e3712a78337031c51760903cc9d79a6962f71aeef5e1ed3a426a33c4d4ede4ddc0c99218c47835a5f881363cd4afd417
6
+ metadata.gz: c3a8c85060058e306066489391a38abf0cd81dbc03f505b7bd033f75eb282dc9f9a1cc77f285755c32a92cf8739f5aba77c1d01018dbf27b29dad73c997cd1fa
7
+ data.tar.gz: 96aab47fb98d8d03b6260046a4b3aa8bd6933ebf0c25126b25487bb8dead8d08db6d4ebdb00abb89b29cc8d0d67212f9ba68ca68b923f46b28cd9490aa284035
@@ -14,15 +14,12 @@ module Philae
14
14
 
15
15
  # @param [Integer] read_timeout Timeout in second for the HTTP request
16
16
  def initialize(name, host, port, read_timeout: 1, cacert: nil, ssl_cert: nil, ssl_key: nil)
17
- if not cacert.nil?
18
- if !File.exists? cacert
19
- raise InvalidSSLConfig, "cacert"
20
- elsif ssl_cert.nil? or !File.exists? ssl_cert
21
- raise InvalidSSLConfig, "ssl_cert"
22
- elsif ssl_key.nil? or !File.exists? ssl_key
23
- raise InvalidSSLConfig, "ssl_key"
24
- end
17
+ if !cacert.nil?
18
+ raise InvalidSSLConfig, 'cacert' if !File.exist?(cacert)
19
+ raise InvalidSSLConfig, 'ssl_cert' if ssl_cert.nil? || !File.exist?(ssl_cert)
20
+ raise InvalidSSLConfig, 'ssl_key' if ssl_key.nil? || !File.exist?(ssl_key)
25
21
  end
22
+
26
23
  @name = name
27
24
  @host = host
28
25
  @port = port
@@ -34,22 +31,25 @@ module Philae
34
31
 
35
32
  def check
36
33
  begin
37
- if not @cacert.nil?
38
- client = Etcd.client host: @host, port: @port, read_timeout: @read_timeout do |c|
39
- c.use_ssl = true
40
- c.ca_file = @cacert
41
- c.ssl_cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
42
- c.ssl_key = OpenSSL::PKey::RSA.new(File.read(@ssl_key))
43
- end
44
- else
45
- client = Etcd.client host: @host, port: @port, read_timeout: @read_timeout
46
- end
47
- client.get '/'
48
- rescue Exception => e
34
+ etcd_client.get '/'
35
+ rescue StandardError => e
49
36
  return { healthy: false, comment: "Unable to contact etcd (#{e.message})" }
50
37
  end
51
38
 
52
39
  return { healthy: true, comment: '' }
53
40
  end
41
+
42
+ protected
43
+
44
+ def etcd_client
45
+ return Etcd.client host: @host, port: @port, read_timeout: @read_timeout do |c|
46
+ next if @cacert.nil?
47
+
48
+ c.use_ssl = true
49
+ c.ca_file = @cacert
50
+ c.ssl_cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
51
+ c.ssl_key = OpenSSL::PKey::RSA.new(File.read(@ssl_key))
52
+ end
53
+ end
54
54
  end
55
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo@scalingo.com
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-30 00:00:00.000000000 Z
13
+ date: 2019-10-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: docker-api