flapjack 0.8.7 → 0.8.8

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
  SHA1:
3
- metadata.gz: 402e2bdf881bed38ea358f612379fb80d6447a28
4
- data.tar.gz: 8cb9bc4bb2956c611ceec529456a8908955d515a
3
+ metadata.gz: 72ee9f50915de6e7b9cf6b41ff8e8673521724be
4
+ data.tar.gz: f381a0c2be5382fe9f7cee78fb9216cd41234ca1
5
5
  SHA512:
6
- metadata.gz: 6fa99305fd86b34e3d3fa7460012c9b7d5f611b21c80d7e6619f218a4688f595ef5c0eb9670aa78a1831658fe1bd3ebac43480a41cbffafd2a96ccd0e5195fe3
7
- data.tar.gz: c348219851002bfcb5597a25a9d75888ae27e1f4129b62f7a1c2de6b19cbb1ba3056e1628410bd047be8302e9cbe979fcfe0b13ad3ee4beb92333ded6bf30740
6
+ metadata.gz: a11151cfb128667fd55e2d703e7a1faf56cb5e175d337c8507df68bc6f4a2cac9f6996012be16cec412de7d8409c1c2bfa16f28250ee701fd1edf01b110f5f9e
7
+ data.tar.gz: db3f5b366159a9250c1888850a63708fe3e8e7abb55221e11fc6a1f3053b46267f34f7d84e4f599c764915ff0bc03d1c83eeba017542da89bd9de710604e6519
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 0.8.8 - 2014-03-20
4
+ - Feature: Be able to disable automatic sched maint by setting duration to zero gh-457, gh-458 (@portertech)
5
+ - Bug: Make bin/flapjack-populator explicitly whinge about `-f` instead of dying gh-455 (@damncabbage)
6
+
3
7
  # 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)
8
+ - Feature: Added "tags" (array of strings) to event hash gh-453 (@portertech)
9
+ - Feature: Allow contacts to be associated with a common entity "ALL" gh-454 (@portertech)
6
10
 
7
11
  # 0.8.6 - 2014-03-14
8
12
  - Bug: tie Thin to < 2.0.0pre gh-442 (@mattdelves)
@@ -45,6 +45,12 @@ optparse = OptionParser.new do |opts|
45
45
  end
46
46
  optparse.parse!(ARGV)
47
47
 
48
+ bail_with_usage = proc do |message|
49
+ puts message
50
+ puts "\n#{optparse}"
51
+ exit(false)
52
+ end
53
+
48
54
  if options.help
49
55
  puts optparse
50
56
  exit
@@ -52,13 +58,12 @@ elsif options.version
52
58
  puts Flapjack::VERSION
53
59
  exit
54
60
  elsif !["import-contacts", "import-entities", "purge-events"].include?(ARGV[0])
55
- if ARGV.nil? || ARGV.empty?
56
- puts "No command provided"
57
- else
58
- puts "Unknown command provided: '#{ARGV[0]}'"
59
- end
60
- puts "\n#{optparse}"
61
- exit 1
61
+ message = if ARGV.nil? || ARGV.empty?
62
+ "No command provided"
63
+ else
64
+ "Unknown command provided: '#{ARGV[0]}'"
65
+ end
66
+ bail_with_usage.call message
62
67
  end
63
68
 
64
69
  FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'production'
@@ -73,14 +78,12 @@ if config_env.nil? || config_env.empty?
73
78
  exit(false)
74
79
  end
75
80
 
76
- if options.from
77
- filename = options.from
78
- file = File.new(filename)
79
- end
80
-
81
81
  case ARGV[0]
82
82
  when "import-contacts"
83
- contacts = Oj.load(file)
83
+ unless options.from
84
+ bail_with_usage.call "No import file provided with --from, eg. --from contacts.json"
85
+ end
86
+ contacts = Oj.load(File.new(options.from))
84
87
 
85
88
  if contacts && contacts.is_a?(Enumerable) && contacts.any? {|e| !e['id'].nil?}
86
89
  @persistence = Redis.new(redis_options)
@@ -95,7 +98,10 @@ when "import-contacts"
95
98
  end
96
99
 
97
100
  when "import-entities"
98
- entities = Oj.load(file)
101
+ unless options.from
102
+ bail_with_usage.call "No import file provided with --from, eg. --from contacts.json"
103
+ end
104
+ entities = Oj.load(File.new(options.from))
99
105
 
100
106
  if entities && entities.is_a?(Enumerable) && entities.any? {|e| !e['id'].nil?}
101
107
  @persistence = Redis.new(redis_options)
@@ -121,7 +127,6 @@ when "purge-events"
121
127
  @persistence.quit
122
128
 
123
129
  else
124
- puts "you need to give me something to do, eg a command like 'import-entities' or 'import-clients' etc"
125
- raise ArgumentError
130
+ bail_with_usage.call "You need to give me something to do, eg. a command like 'import-entities', 'import-clients', etc."
126
131
  end
127
132
 
@@ -78,3 +78,12 @@ test:
78
78
  When I run `bin/flapjack-populator import-entities --from tmp/cucumber_cli/flapjack-populator-entities.json --config tmp/cucumber_cli/flapjack-populator.yaml`
79
79
  Then the exit status should be 0
80
80
 
81
+ Scenario Outline: Running an flapjack-populator import command with a missing '--from' exits uncleanly and shows usage
82
+ When I run `bin/flapjack-populator <Command> example.json --config tmp/cucumber_cli/flapjack-populator.yaml`
83
+ Then the exit status should not be 0
84
+ And the output should contain "No import file provided with --from"
85
+ And the output should contain "Usage: flapjack-populator"
86
+ Examples:
87
+ | Command |
88
+ | import-entities |
89
+ | import-contacts |
@@ -36,7 +36,7 @@ module Flapjack
36
36
  @events_archive_maxage = @config['events_archive_maxage']
37
37
 
38
38
  ncsm_duration_conf = @config['new_check_scheduled_maintenance_duration'] || '100 years'
39
- @ncsm_duration = ChronicDuration.parse(ncsm_duration_conf)
39
+ @ncsm_duration = ChronicDuration.parse(ncsm_duration_conf, :keep_zero => true)
40
40
 
41
41
  @exit_on_queue_empty = !! @config['exit_on_queue_empty']
42
42
 
@@ -196,7 +196,7 @@ module Flapjack
196
196
  if previous_state.nil?
197
197
  @logger.info("No previous state for event #{event.id}")
198
198
 
199
- if @ncsm_duration >= 0
199
+ if @ncsm_duration > 0
200
200
  @logger.info("Setting scheduled maintenance for #{time_period_in_words(@ncsm_duration)}")
201
201
  entity_check.create_scheduled_maintenance(timestamp,
202
202
  @ncsm_duration, :summary => 'Automatically created for new check')
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.8.7"
4
+ VERSION = "0.8.8"
5
5
  end
6
+
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.7
4
+ version: 0.8.8
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-18 00:00:00.000000000 Z
13
+ date: 2014-03-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dante