kennel 1.136.0 → 1.137.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 231fc1b9543d397fd19883197e22058306c9878fbff6896d2724ade3952fc8ba
4
- data.tar.gz: 866c5ea66fdc460e3d63fea0dd57d4c6f658ccb76eb6fcafcdd17e95c17986b0
3
+ metadata.gz: f3e204dfd9daeee103d20e04defb8b03e00359a616fd7f061e1ace776a67de5d
4
+ data.tar.gz: e359b39128bb2f87466bb52a0ee550f7141fd96d59111c908c9f12dbf9d69a48
5
5
  SHA512:
6
- metadata.gz: 47333e0a70f48469dd4c860fbc1bf45b1f5574e0569a9205818ebc841d6be7e9f3a466da2182216c6fa3de0fe0d0da7eebda10ed33bcbf919c0fd817e15558d8
7
- data.tar.gz: 9111e4803467ef34acce47684254fcb008decd056df763cc8b69f6bd8a4a598b907c881983950030120dfe8886bd51d3618b27988adf13cd3af9c6a41875eef6
6
+ metadata.gz: 583d7848880bfc6f12a72de0ad9f492c08ddd0b5529ceab6127fe014da2159b99dcd58d83c9c7cc41cfa0e60d10550cc837412fea0d1224c5088b7f8c1f36819
7
+ data.tar.gz: 7d5cd7f3ea73274fb368c7908dcd8ca7c8acf346aee00bd7ff49cf0981c199cab33fa1de5911ee780c1d1d385815812d1b238d0020077484eb23c7c8d542e90d
@@ -18,7 +18,7 @@ module Kennel
18
18
  def ask?(question)
19
19
  Kennel.err.printf color(:red, "#{question} - press 'y' to continue: ", force: true)
20
20
  begin
21
- STDIN.gets.chomp == "y"
21
+ Kennel.in.gets.chomp == "y"
22
22
  rescue Interrupt # do not show a backtrace if user decides to Ctrl+C here
23
23
  Kennel.err.print "\n"
24
24
  exit 1
@@ -31,7 +31,6 @@ module Kennel
31
31
  min: "auto",
32
32
  max: "auto"
33
33
  },
34
- show_legend: true,
35
34
  time: {},
36
35
  title_align: "left",
37
36
  title_size: "16"
@@ -23,7 +23,8 @@ module Kennel
23
23
  no_data_timeframe: nil, # this works out ok since if notify_no_data is on, it would never be nil
24
24
  groupby_simple_monitor: false,
25
25
  variables: nil,
26
- on_missing_data: "default" # "default" is "evaluate as zero"
26
+ on_missing_data: "default", # "default" is "evaluate as zero"
27
+ notification_preset_name: nil
27
28
  }.freeze
28
29
  DEFAULT_ESCALATION_MESSAGE = ["", nil].freeze
29
30
  ALLOWED_PRIORITY_CLASSES = [NilClass, Integer].freeze
@@ -32,7 +33,8 @@ module Kennel
32
33
  settings(
33
34
  :query, :name, :message, :escalation_message, :critical, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
34
35
  :ok, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
35
- :threshold_windows, :scheduling_options, :new_host_delay, :new_group_delay, :priority, :validate_using_links, :variables, :on_missing_data
36
+ :threshold_windows, :scheduling_options, :new_host_delay, :new_group_delay, :priority, :validate_using_links, :variables, :on_missing_data,
37
+ :notification_preset_name
36
38
  )
37
39
 
38
40
  defaults(
@@ -55,7 +57,8 @@ module Kennel
55
57
  scheduling_options: -> { nil },
56
58
  priority: -> { MONITOR_DEFAULTS.fetch(:priority) },
57
59
  variables: -> { MONITOR_OPTION_DEFAULTS.fetch(:variables) },
58
- on_missing_data: -> { MONITOR_OPTION_DEFAULTS.fetch(:on_missing_data) }
60
+ on_missing_data: -> { MONITOR_OPTION_DEFAULTS.fetch(:on_missing_data) },
61
+ notification_preset_name: -> { MONITOR_OPTION_DEFAULTS.fetch(:notification_preset_name) }
59
62
  )
60
63
 
61
64
  def build_json
@@ -137,6 +140,11 @@ module Kennel
137
140
  options.delete :no_data_timeframe
138
141
  end
139
142
 
143
+ # only set when needed to avoid big diff
144
+ if (notification_preset_name = notification_preset_name())
145
+ options[:notification_preset_name] = notification_preset_name
146
+ end
147
+
140
148
  data
141
149
  end
142
150
 
data/lib/kennel/syncer.rb CHANGED
@@ -47,7 +47,7 @@ module Kennel
47
47
 
48
48
  def confirm
49
49
  return false if internal_plan.empty?
50
- return true if ENV["CI"] || !STDIN.tty? || !Kennel.err.tty?
50
+ return true if ENV["CI"] || !Kennel.in.tty? || !Kennel.err.tty?
51
51
  Console.ask?("Execute Plan ?")
52
52
  end
53
53
 
data/lib/kennel/tasks.rb CHANGED
@@ -82,15 +82,17 @@ namespace :kennel do
82
82
  bad = []
83
83
  Dir["generated/**/*.json"].each do |f|
84
84
  next unless message = JSON.parse(File.read(f))["message"]
85
- used = message.scan(/\s(@[^\s{,'"]+)/).flatten(1)
85
+ used = message
86
+ .scan(/(?:^|\s)(@[^\s{,'"]+)/)
87
+ .flatten(1)
86
88
  .grep(/^@.*@|^@.*-/) # ignore @here etc handles ... datadog uses @foo@bar.com for emails and @foo-bar for integrations
87
89
  (used - known).each { |v| bad << [f, v] }
88
90
  end
89
91
 
90
92
  if bad.any?
91
93
  url = Kennel::Utils.path_to_url "/account/settings"
92
- puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"
93
- bad.each { |f, v| puts "Invalid mention #{v} in monitor message of #{f}" }
94
+ Kennel.out.puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"
95
+ bad.each { |f, v| Kennel.out.puts "Invalid mention #{v} in monitor message of #{f}" }
94
96
  Kennel::Tasks.abort ENV["KNOWN_WARNING"]
95
97
  end
96
98
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.136.0"
3
+ VERSION = "1.137.1"
4
4
  end
data/lib/kennel.rb CHANGED
@@ -47,9 +47,10 @@ module Kennel
47
47
  GenerationAbortedError = Class.new(StandardError)
48
48
 
49
49
  class << self
50
- attr_accessor :out, :err
50
+ attr_accessor :in, :out, :err
51
51
  end
52
52
 
53
+ self.in = $stdin
53
54
  self.out = $stdout
54
55
  self.err = $stderr
55
56
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.136.0
4
+ version: 1.137.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-10 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs