kennel 2.2.1 → 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: f9945e9a42b446b95f53152f08d74765e4f7c228a4a4e9d3f5770eb6006338a0
4
- data.tar.gz: 3cc6fd5ff0cece1763b9a4e798ac9da97df80c6b27b613caf45abe7f9ef4a1eb
3
+ metadata.gz: 3e01b3965b78914228272c6db34282678f7804466ad2ce86bb74937f7ef22be7
4
+ data.tar.gz: a40663b9cc2a5a609635ca8507e5f70883716307da3927de7e2d52e8a4f6e522
5
5
  SHA512:
6
- metadata.gz: c43fb32a753b1e59aca9728195612568ec2a11d7d83e7a74daad064bbc5ec2d9f29951d0e0ff66e290d25e357b5a3e2d310cbac0b335ebccb1da7cbb5752a225
7
- data.tar.gz: 61f079c7c9a0d8c746c529badc5e2d67fe4c3e8c19e2025ab95516be2667f4b1788d288d3e8420b929dc2fa85a98cd5c6f23b9395c3a066785194f44a02cb0a9
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 = {
@@ -14,10 +14,11 @@ module Kennel
14
14
  query: nil,
15
15
  groups: nil,
16
16
  monitor_ids: [],
17
- thresholds: []
17
+ thresholds: [],
18
+ primary: nil
18
19
  }.freeze
19
20
 
20
- settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name, :groups, :sli_specification
21
+ settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name, :groups, :sli_specification, :primary
21
22
 
22
23
  defaults(
23
24
  tags: -> { @project.tags },
@@ -25,7 +26,8 @@ module Kennel
25
26
  description: -> { DEFAULTS.fetch(:description) },
26
27
  monitor_ids: -> { DEFAULTS.fetch(:monitor_ids) },
27
28
  thresholds: -> { DEFAULTS.fetch(:thresholds) },
28
- groups: -> { DEFAULTS.fetch(:groups) }
29
+ groups: -> { DEFAULTS.fetch(:groups) },
30
+ primary: -> { DEFAULTS.fetch(:primary) }
29
31
  )
30
32
 
31
33
  def build_json
@@ -38,6 +40,16 @@ module Kennel
38
40
  type: type
39
41
  )
40
42
 
43
+ # add top level timeframe and threshold settings based on `primary`
44
+ if (p = primary)
45
+ data[:timeframe] = p
46
+ threshold =
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]
50
+ data[:target_threshold] = threshold[:target]
51
+ end
52
+
41
53
  if type == "time_slice"
42
54
  data[:sli_specification] = sli_specification
43
55
  elsif (v = query)
@@ -83,6 +95,12 @@ module Kennel
83
95
  expected[:tags]&.sort!
84
96
  actual[:tags].sort!
85
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
+
86
104
  ignore_default(expected, actual, DEFAULTS)
87
105
  end
88
106
 
@@ -97,6 +115,11 @@ module Kennel
97
115
  invalid! :tags_are_upper_case, "Tags must not be upper case (bad tags: #{bad_tags.sort.inspect})"
98
116
  end
99
117
 
118
+ # Check that thresholds are not empty
119
+ if !data[:thresholds] || data[:thresholds].empty?
120
+ invalid! :thresholds_empty, "SLO must have at least one threshold defined"
121
+ end
122
+
100
123
  # prevent "Invalid payload: The target is incorrect: target must be a positive number between (0.0, 100.0)"
101
124
  data[:thresholds]&.each do |threshold|
102
125
  target = threshold.fetch(:target)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.2.1"
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.2.1
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-03 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