flapjack 0.8.6 → 0.8.7

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
  SHA1:
3
- metadata.gz: 7fc94944c2fb13e947e99bdfe54b0fe6f69a80e3
4
- data.tar.gz: 7f090f5ca4504a757a5e773937af868c7eed16ee
3
+ metadata.gz: 402e2bdf881bed38ea358f612379fb80d6447a28
4
+ data.tar.gz: 8cb9bc4bb2956c611ceec529456a8908955d515a
5
5
  SHA512:
6
- metadata.gz: b63e5c995f7790525b8eb152a52621e5edb9a1eed65b5abef6e3c0068b8217df0ab34ef6f33c48f694bc19eefd6f247013b8e2eb3e8dd7c480e77c3e4745a5b0
7
- data.tar.gz: 6d96a660e3bf02e1bbf820b7ba4d6f14322dc6db76ae621a89266d3d0da5aefa433aa5c4dadd69315a8f317631d649f654d308dddf1316220d331052ff06b2b3
6
+ metadata.gz: 6fa99305fd86b34e3d3fa7460012c9b7d5f611b21c80d7e6619f218a4688f595ef5c0eb9670aa78a1831658fe1bd3ebac43480a41cbffafd2a96ccd0e5195fe3
7
+ data.tar.gz: c348219851002bfcb5597a25a9d75888ae27e1f4129b62f7a1c2de6b19cbb1ba3056e1628410bd047be8302e9cbe979fcfe0b13ad3ee4beb92333ded6bf30740
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 0.8.7 - 2014-03-19
4
+ - Added "tags" (array of strings) to event hash gh-453 (@portertech)
5
+ - Allow contacts to be associated with a common entity "ALL" gh-454 (@portertech)
6
+
3
7
  # 0.8.6 - 2014-03-14
4
8
  - Bug: tie Thin to < 2.0.0pre gh-442 (@mattdelves)
5
9
  - Feature: Allow site-specific ERB templates for messages. gh-443 (@jswoods)
@@ -32,7 +32,7 @@ module Flapjack
32
32
  raise "Redis connection not set" unless redis = options[:redis]
33
33
  raise "Entity name not provided" unless entity['name'] && !entity['name'].empty?
34
34
 
35
- #FIXME: should probably raise an exception if trying to create a new entity with the
35
+ #FIXME: should probably raise an exception if trying to create a new entity with the
36
36
  # same name or id as an existing entity. (Go away and use update instead.)
37
37
  if entity['id']
38
38
  existing_name = redis.hget("entity:#{entity['id']}", 'name')
@@ -132,7 +132,8 @@ module Flapjack
132
132
  end
133
133
 
134
134
  def contacts
135
- contact_ids = @redis.smembers("contacts_for:#{id}")
135
+ contact_ids = @redis.smembers("contacts_for:#{id}") +
136
+ @redis.smembers("contacts_for:ALL")
136
137
 
137
138
  if @logger
138
139
  @logger.debug("#{contact_ids.length} contact(s) for #{id} (#{name}): " +
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'oj'
4
+ require 'flapjack/data/tag_set'
4
5
 
5
6
  module Flapjack
6
7
  module Data
@@ -11,7 +12,7 @@ module Flapjack
11
12
  attr_reader :check, :summary, :details, :acknowledgement_id
12
13
 
13
14
  REQUIRED_KEYS = ['type', 'state', 'entity', 'check', 'summary']
14
- OPTIONAL_KEYS = ['time', 'details', 'acknowledgement_id', 'duration']
15
+ OPTIONAL_KEYS = ['time', 'details', 'acknowledgement_id', 'duration', 'tags']
15
16
 
16
17
  VALIDATIONS = {
17
18
  proc {|e| e['type'].is_a?(String) &&
@@ -50,6 +51,11 @@ module Flapjack
50
51
  e['duration'].is_a?(Integer) ||
51
52
  (e['duration'].is_a?(String) && !!(e['duration'] =~ /^\d+$/)) } =>
52
53
  "duration must be a positive integer, or a string castable to one",
54
+
55
+ proc {|e| e['tags'].nil? ||
56
+ (e['tags'].is_a?(Array) &&
57
+ e['tags'].all? {|tag| tag.is_a?(String)}) } =>
58
+ "tags must be an array of strings",
53
59
  }
54
60
 
55
61
  # Helper method for getting the next event.
@@ -203,6 +209,10 @@ module Flapjack
203
209
  end
204
210
  # details is optional. set it to nil if it only contains whitespace
205
211
  @details = (@details.is_a?(String) && ! @details.strip.empty?) ? @details.strip : nil
212
+ if attrs['tags']
213
+ @tags = Flapjack::Data::TagSet.new
214
+ attrs['tags'].each {|tag| @tags.add(tag)}
215
+ end
206
216
  end
207
217
 
208
218
  def state
@@ -261,4 +271,3 @@ module Flapjack
261
271
  end
262
272
  end
263
273
  end
264
-
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.8.6"
4
+ VERSION = "0.8.7"
5
5
  end
@@ -14,10 +14,11 @@ describe Flapjack::Data::Event do
14
14
  'entity' => entity_name,
15
15
  'check' => check,
16
16
  'time' => time.to_i,
17
- 'summary' => "timeout",
17
+ 'summary' => 'timeout',
18
18
  'details' => "couldn't access",
19
19
  'acknowledgement_id' => '1234',
20
- 'duration' => (60 * 60) }
20
+ 'duration' => (60 * 60),
21
+ 'tags' => ['dev'] }
21
22
  }
22
23
 
23
24
  context 'class' do
@@ -149,7 +150,7 @@ describe Flapjack::Data::Event do
149
150
  end
150
151
  end
151
152
 
152
- ['time', 'details', 'acknowledgement_id', 'duration'].each do |optional_key|
153
+ ['time', 'details', 'acknowledgement_id', 'duration', 'tags'].each do |optional_key|
153
154
  it "rejects an event with invalid '#{optional_key}' key (archiving)" do
154
155
  bad_event_data = event_data.clone
155
156
  bad_event_data[optional_key] = {'hello' => 'there'}
@@ -300,6 +301,9 @@ describe Flapjack::Data::Event do
300
301
  expect(event.time).to eq(event_data['time'])
301
302
  expect(event.id).to eq('xyz-example.com:ping')
302
303
  expect(event.type).to eq('service')
304
+ expect(event.tags).to be_an_instance_of(Flapjack::Data::TagSet)
305
+ expect(event.tags).to include('dev')
306
+ expect(event.tags).to_not include('prod')
303
307
 
304
308
  expect(event).to be_a_service
305
309
  expect(event).to be_a_service
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-14 00:00:00.000000000 Z
13
+ date: 2014-03-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dante