kennel 1.136.0 → 1.137.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: 231fc1b9543d397fd19883197e22058306c9878fbff6896d2724ade3952fc8ba
4
- data.tar.gz: 866c5ea66fdc460e3d63fea0dd57d4c6f658ccb76eb6fcafcdd17e95c17986b0
3
+ metadata.gz: b53cb18f3d669a49d841764bcf3c7909e9d297c09001779a586facb5af76ac82
4
+ data.tar.gz: 9260cff2d88fd8de017c9a020525cd634595e99028e0bc6fe75d36994b5aadb2
5
5
  SHA512:
6
- metadata.gz: 47333e0a70f48469dd4c860fbc1bf45b1f5574e0569a9205818ebc841d6be7e9f3a466da2182216c6fa3de0fe0d0da7eebda10ed33bcbf919c0fd817e15558d8
7
- data.tar.gz: 9111e4803467ef34acce47684254fcb008decd056df763cc8b69f6bd8a4a598b907c881983950030120dfe8886bd51d3618b27988adf13cd3af9c6a41875eef6
6
+ metadata.gz: ce2712664d1d3bca8475d37e4e358a3b1beacbd7f6fb1f2398e1be8bab19a51796bfaf1827f8294735e82073e87bc2587f9539ae7bf797401fcc4b028813cabd
7
+ data.tar.gz: 7f3112824f98bb008784b50550000ece752c62b09f94e6978822e1ca78fd78f43e08c33cdf8c461b1e0ba290c7a3a166797008a205991492e14a0a8a9ea642ef
@@ -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
@@ -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.0"
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.0
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-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs