sport_ngin_aws_auditor 3.8.3 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/CHANGELOG.markdown +5 -0
- data/lib/sport_ngin_aws_auditor/commands/audit.rb +1 -0
- data/lib/sport_ngin_aws_auditor/notify_slack.rb +13 -9
- data/lib/sport_ngin_aws_auditor/scripts/audit.rb +4 -4
- data/lib/sport_ngin_aws_auditor/version.rb +1 -1
- data/spec/sport_ngin_aws_auditor/notify_slack_spec.rb +15 -2
- data/sport_ngin_aws_auditor.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beef821f62dfeb8b9235d25a120b2faf8ddec09a
|
4
|
+
data.tar.gz: f0c504bfd3cbd9fbdd8f305c733f8eba50ce7ac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62da765c56b2599a4817d1b585bd3844bec7397e4a1c2cd93ab7e1d409c0e255fa5123b2fecf56e0463cce87e497436620764a34c4caba67accba942f4317d5c
|
7
|
+
data.tar.gz: 71545feabd3057e6062725598b98b565cc31a99ed1c2847edc9867ae2ae721b8e78826395ad181657e4faa60277cbb12b7426eb7f47a74389db50484ddbc267a
|
data/.travis.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -7,6 +7,7 @@ command 'audit' do |c|
|
|
7
7
|
c.switch [:r, :reserved], :desc => "Shows reserved instance counts"
|
8
8
|
c.switch [:i, :instances], :desc => "Shows current instance counts"
|
9
9
|
c.flag [:t, :tag], :default_value => "no-reserved-instance", :desc => "Read a tag and group separately during audit"
|
10
|
+
c.flag [:h, :config_json], :default_value => nil, :desc => "Print the audit according to this config json object instead of to config file"
|
10
11
|
c.switch [:n, :no_tag], :desc => "Ignore all tags during audit"
|
11
12
|
c.switch [:s, :slack], :desc => "Will print condensed version of audit to a Slack channel"
|
12
13
|
c.action do |global_options, options, args|
|
@@ -1,24 +1,28 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module SportNginAwsAuditor
|
4
5
|
class NotifySlack
|
5
|
-
attr_accessor :text, :channel, :webhook, :username, :icon_url, :icon_emoji, :attachments
|
6
|
+
attr_accessor :text, :channel, :webhook, :username, :icon_url, :icon_emoji, :attachments, :config
|
6
7
|
|
7
|
-
def initialize(text)
|
8
|
+
def initialize(text, config_params)
|
8
9
|
self.text = text
|
9
10
|
self.attachments = []
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
self.
|
11
|
+
config_file = SportNginAwsAuditor::Config.slack.to_h || {}
|
12
|
+
self.config = config_params ? config_file.merge(JSON.parse(config_params)) : config_file
|
13
|
+
|
14
|
+
if self.config
|
15
|
+
self.channel = self.config['channel']
|
16
|
+
self.username = self.config['username']
|
17
|
+
self.webhook = self.config['webhook']
|
18
|
+
self.icon_url = self.config['icon_url']
|
15
19
|
else
|
16
|
-
puts "To use Slack, you must provide a separate config file. See the README for more information."
|
20
|
+
puts "To use Slack, you must provide either a separate config file or a hash of config data. See the README for more information."
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def perform
|
21
|
-
if
|
25
|
+
if config
|
22
26
|
options = {text: text,
|
23
27
|
webhook: webhook,
|
24
28
|
channel: channel,
|
@@ -126,7 +126,7 @@ module SportNginAwsAuditor
|
|
126
126
|
|
127
127
|
def self.print_discrepancies(discrepancy_array, audit_results, class_type, environment)
|
128
128
|
title = "Some #{class_type} discrepancies for #{environment} exist:\n"
|
129
|
-
slack_instances = NotifySlack.new(title)
|
129
|
+
slack_instances = NotifySlack.new(title, options[:config_json])
|
130
130
|
|
131
131
|
discrepancy_array.each do |discrepancy|
|
132
132
|
type = discrepancy.type
|
@@ -144,7 +144,7 @@ module SportNginAwsAuditor
|
|
144
144
|
|
145
145
|
def self.print_tagged(tagged_array, audit_results, class_type, environment)
|
146
146
|
title = "There are currently some tagged #{class_type}s in #{environment}:\n"
|
147
|
-
slack_instances = NotifySlack.new(title)
|
147
|
+
slack_instances = NotifySlack.new(title, options[:config_json])
|
148
148
|
|
149
149
|
tagged_array.each do |tagged|
|
150
150
|
type = tagged.type
|
@@ -173,7 +173,7 @@ module SportNginAwsAuditor
|
|
173
173
|
message << "*#{name}* (#{count}) on *#{expiration_date}*\n"
|
174
174
|
end
|
175
175
|
|
176
|
-
slack_retired_ris = NotifySlack.new(message)
|
176
|
+
slack_retired_ris = NotifySlack.new(message, options[:config_json])
|
177
177
|
slack_retired_ris.perform
|
178
178
|
end
|
179
179
|
|
@@ -188,7 +188,7 @@ module SportNginAwsAuditor
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
slack_retired_tags = NotifySlack.new(message)
|
191
|
+
slack_retired_tags = NotifySlack.new(message, options[:config_json])
|
192
192
|
slack_retired_tags.perform
|
193
193
|
end
|
194
194
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "sport_ngin_aws_auditor"
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module SportNginAwsAuditor
|
4
5
|
describe NotifySlack do
|
@@ -16,17 +17,29 @@ module SportNginAwsAuditor
|
|
16
17
|
it 'should ping Slack Notifier' do
|
17
18
|
notifier = double('notifier')
|
18
19
|
expect(HTTParty).to receive(:post)
|
19
|
-
message = NotifySlack.new("Test message")
|
20
|
+
message = NotifySlack.new("Test message", nil)
|
20
21
|
message.perform
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'should define certain values' do
|
24
|
-
message = NotifySlack.new("Test message")
|
25
|
+
message = NotifySlack.new("Test message", nil)
|
25
26
|
expect(message.text).to eq("Test message")
|
26
27
|
expect(message.channel).to eq("#random-test-channel")
|
27
28
|
expect(message.username).to eq("Random User")
|
28
29
|
expect(message.webhook).to eq("https://hooks.slack.com/services/totallyrandom/fakewebhookurl")
|
29
30
|
expect(message.icon_url).to eq("http://random-picture.jpg")
|
30
31
|
end
|
32
|
+
|
33
|
+
it 'should ping Slack Notifier even when passing in config as a hash' do
|
34
|
+
notifier = double('notifier')
|
35
|
+
config_hash = {:username=>"AWS Auditor",
|
36
|
+
:icon_url=>"http://i.imgur.com/86x8PSg.jpg",
|
37
|
+
:channel=>"#test-webhook-channel",
|
38
|
+
:webhook=>"https://hooks.slack.com/services/thisisafake"
|
39
|
+
}.to_json
|
40
|
+
expect(HTTParty).to receive(:post)
|
41
|
+
message = NotifySlack.new("Test message", config_hash)
|
42
|
+
message.perform
|
43
|
+
end
|
31
44
|
end
|
32
45
|
end
|
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'highline', '~> 1.6'
|
25
25
|
spec.add_dependency 'google_drive', '~> 1.0.0.pre2'
|
26
26
|
spec.add_dependency 'google-api-client', '~> 0.8.6'
|
27
|
-
spec.add_dependency 'rack', '
|
28
|
-
spec.add_dependency 'activesupport', '
|
27
|
+
spec.add_dependency 'rack', '>= 1.3.0'
|
28
|
+
spec.add_dependency 'activesupport', '>= 3.2'
|
29
29
|
spec.add_dependency 'httparty'
|
30
30
|
spec.add_dependency 'colorize'
|
31
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sport_ngin_aws_auditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Hursh
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-11-
|
13
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
name: rack
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: 1.3.0
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - "
|
110
|
+
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 1.3.0
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: activesupport
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - "
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '3.2'
|
120
120
|
type: :runtime
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - "
|
124
|
+
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '3.2'
|
127
127
|
- !ruby/object:Gem::Dependency
|