mrkamel / heartbeat

Use Heartbeat to monitor your Hetzner Failover IP and automatically switch to another server.
53 stars 13 forks source link

the executable still depends on `hashr`'s deep_symbolize_keys #13

Closed tpo closed 3 years ago

tpo commented 3 years ago
/heartbeat # bin/heartbeat
I, [2021-06-11T06:40:27.272858 #122]  INFO -- : Reading configuration from config/heartbeat.invalid.yml.
#<Thread:0x00007f228acff7e8 bin/heartbeat:32 run> terminated with exception (report_on_exception is true):
bin/heartbeat:37:in `block (2 levels) in <main>': undefined method `deep_symbolize_keys' for {"base_url"=>"https://robot-ws.your-server.de", "basic_auth"=>{"username"=>"username", "password"=>"password"}, "failover_ip"=>"0.0.0.0", "ping_ip"=>"0.0.0.0", "ips"=>[{"ping"=>"1.1.1.1", "target"=>"1.1.1.1"}, {"ping"=>"2.2.2.2", "target"=>"2.2.2.2"}], "interval"=>30, "timeout"=>10, "tries"=>3, "dry"=>true, "only_once"=>true}:Hash (NoMethodError)

I suggest to leave the hashr gem dependency in, that is to revert these changes (the below diff is not real or correct, but instead freestyle edited to convey the idea):

commit 7eac3a2
Author: Benjamin Vetter <benjamin.vetter@wlw.de>
Date:   Tue Jun 8 22:51:41 2021 +0200

    Use minitest

diff --git Gemfile Gemfile
index cb01543..fa7f624 100644
--- Gemfile
+++ Gemfile
@@ -4,6 +4,6 @@ source "http://rubygems.org"
 gem "json"
 gem "httparty"
 gem "rake"
 gem "mocha", require: false
-gem "hashr"
 gem "minitest", require: false

diff --git lib/failover_ip.rb lib/failover_ip.rb
index dd4500e..86c1e61 100755
--- lib/failover_ip.rb
+++ lib/failover_ip.rb
@@ -2,7 +2,6 @@
 require "json"
 require "httparty"
 require "lib/hooks"
-require "hashr"

I suggest to fix that, use rebase with fixup to merge the fix into commit 7eac3a2 and then to force push the commits?

Removing hashr not only breaks the deep_symbolize_keys call, which would be trivial to remove, but it breaks subsequent

  def initialize(options)
    self.base_url = options[:base_url]

hash access. These could all be fixed by using string hash lookup notation:

  def initialize(options)
    self.base_url = options["base_url"]

which of course would also be OK instead of reintroducing the hashrdependendy. It's your call.

mrkamel commented 3 years ago

thx, fixed