Skip to content

Commit

Permalink
remove locked attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
brianburnszd committed Mar 29, 2024
1 parent 6e6da95 commit 53a202e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/kennel/models/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def build_json
include_tags: true,
escalation_message: Utils.presence(escalation_message.strip),
evaluation_delay: evaluation_delay,
locked: false, # setting this to true prevents any edit and breaks updates when using replace workflow
locked: false, # deprecated: setting this to true will likely fail
renotify_interval: renotify_interval || 0,
variables: variables
}
Expand Down Expand Up @@ -153,6 +153,9 @@ def build_json
options[:notification_preset_name] = notification_preset_name
end

# locked is deprecated, will fail if used
options.delete :locked

data
end

Expand Down Expand Up @@ -231,6 +234,9 @@ def self.normalize(expected, actual)
options.delete(:escalation_message)
expected_options.delete(:escalation_message)
end
# locked is deprecated: ignored when diffing
options.delete(:locked)
expected_options.delete(:locked)
end

private
Expand Down
8 changes: 7 additions & 1 deletion test/kennel/models/monitor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def monitor(options = {})
include_tags: true,
escalation_message: nil,
evaluation_delay: nil,
locked: false,
renotify_interval: 0,
thresholds: { critical: 123.0 },
variables: nil
Expand Down Expand Up @@ -581,6 +580,13 @@ def diff_resource(e, a)
diff_resource({ type: -> { "query alert" } }, {}).must_equal []
end

describe "#locked" do
it "ignores deprecated option locked" do
expected_basic_json[:options].delete(:locked)
diff_resource({}, {}).must_equal []
end
end

describe "#escalation_message" do
it "ignores missing escalation_message" do
expected_basic_json[:options].delete(:escalation_message)
Expand Down

0 comments on commit 53a202e

Please sign in to comment.