kennel 2.3.0 → 2.4.0

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: 9a72c925b5388b403514bc0be5c998595428bb41cdf41f97f91571a374716e14
4
- data.tar.gz: 6bcd5f992433b13f088c633e1cd3468c1966cada8df12a689a07343a17e23d2c
3
+ metadata.gz: 3e01b3965b78914228272c6db34282678f7804466ad2ce86bb74937f7ef22be7
4
+ data.tar.gz: a40663b9cc2a5a609635ca8507e5f70883716307da3927de7e2d52e8a4f6e522
5
5
  SHA512:
6
- metadata.gz: 713d35626d870aeaaa1148a73b56b73b25e515dfa2523a97e2e423f5f63dc84461b4bcadbe0fc928698717f2928e99fca47ccb9c7a755057635b4b3b51025acc
7
- data.tar.gz: 1d65adb907acd6c31f60c53be6dabf9d3849793f684d2d142403f7fa4b71439ec4544e72b325eb7d4181a50e81542b7704c1144ff2e7e79bb7d90716a9b0ce2e
6
+ metadata.gz: a70ca74dafb5e00e3cb02e85aa6a17b50ea86c38779749eca2623758d2eea649b7d708697f27216768f94b401e7f14a16aa3d85c03c9f4d4cae287357f260bc0
7
+ data.tar.gz: 6ade52de1bf22e7b5932e017b029a1d46fde06fa7e310d7e482a993d0e6540c64f6123bb7c2b0170e7a94e5a431dde172bac4076afc63b80ed0a68f82292fbe2
@@ -21,6 +21,12 @@ module Kennel
21
21
  data = @api.show(model.api_resource, id)
22
22
 
23
23
  id = data.fetch(:id) # keep native value
24
+ if resource == "slo"
25
+ # only set primary if needed to reduce clutter
26
+ if data[:thresholds] && data[:thresholds].min_by { |t| t[:timeframe].to_i }[:timeframe] != data[:timeframe]
27
+ data[:primary] = data[:timeframe]
28
+ end
29
+ end
24
30
  model.normalize({}, data) # removes id
25
31
  data[:id] = id
26
32
 
@@ -6,7 +6,7 @@ module Kennel
6
6
 
7
7
  READONLY_ATTRIBUTES = [
8
8
  *superclass::READONLY_ATTRIBUTES,
9
- :type_id, :monitor_tags, :target_threshold, :timeframe, :warning_threshold
9
+ :type_id, :monitor_tags
10
10
  ].freeze
11
11
  TRACKING_FIELD = :description
12
12
  DEFAULTS = {
@@ -40,20 +40,13 @@ module Kennel
40
40
  type: type
41
41
  )
42
42
 
43
- # Add timeframe and thresholds based on primary setting
44
- if primary
45
- data[:timeframe] = primary
46
-
43
+ # add top level timeframe and threshold settings based on `primary`
44
+ if (p = primary)
45
+ data[:timeframe] = p
47
46
  threshold =
48
- thresholds.detect { |t| t[:timeframe] == primary } ||
49
- raise("unable to find threshold with timeframe #{primary}")
50
-
51
- # Only add warning_threshold if it exists
52
- if threshold[:warning]
53
- data[:warning_threshold] = threshold[:warning]
54
- end
55
-
56
- # target is required
47
+ thresholds.detect { |t| t[:timeframe] == p } ||
48
+ raise(ArgumentError, "#{tracking_id} unable to find threshold with timeframe #{p}")
49
+ data[:warning_threshold] = threshold[:warning]
57
50
  data[:target_threshold] = threshold[:target]
58
51
  end
59
52
 
@@ -102,6 +95,12 @@ module Kennel
102
95
  expected[:tags]&.sort!
103
96
  actual[:tags].sort!
104
97
 
98
+ # do not show these in the diff if we automatically pick the primary timeframe,
99
+ # or we will have a permanent `something -> nil` diff
100
+ unless expected[:timeframe]
101
+ [:timeframe, :warning_threshold, :target_threshold].each { |k| actual.delete k }
102
+ end
103
+
105
104
  ignore_default(expected, actual, DEFAULTS)
106
105
  end
107
106
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.3.0"
3
+ VERSION = "2.4.0"
4
4
  end
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: 2.3.0
4
+ version: 2.4.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: 2025-10-10 00:00:00.000000000 Z
11
+ date: 2025-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs