cwa 0.2.5 → 0.2.6
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 +4 -4
- data/README.md +6 -0
- data/lib/cwa/cli.rb +22 -5
- data/lib/cwa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68fe5fa6a7a7028fe3a8aa3c6781ba92b95c77972bcb9b32f0ef87b7d3ffea5f
|
4
|
+
data.tar.gz: d37958cce67757b099ab293a157060d91053c83f34a563fc9743254cbdbe4fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4380bddd08abd79d38d6a5dde6b99c5af8ad93d4ab0086783c258f50accebb0c4c6abb9f649d468b1e7578ecfd60aa56bdccfc13943ec8e43191a5ef999b525
|
7
|
+
data.tar.gz: 6dc99a2dedb8a4ffabdd1a086cb5204a91c7e56c4afd20f47a5593fa220d742c52dd01b987c4027fdd6d89f4f26df36744d8edf6cd2b5e0b261160723eb21ebf
|
data/README.md
CHANGED
@@ -19,12 +19,18 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
```
|
22
|
+
$ >> cwa help
|
22
23
|
Commands:
|
23
24
|
cwa alarms --name ALARMNAME --regexp ALARMNAME --namespae NAMESPACE --dimensions KEY:VALUE # show cloudwatch alms
|
25
|
+
cwa configure # create config files
|
24
26
|
cwa disable --name ALARMNAME --regexp ALARMNAME --namespae NAMESPACE --dimensions KEY:VALUE # disable cloudwatch alms
|
25
27
|
cwa enable --name ALARMNAME --regexp ALARMNAME --namespae NAMESPACE --dimensions KEY:VALUE # enable cloudwatch alms
|
26
28
|
cwa help [COMMAND] # Describe available commands or one specific command
|
27
29
|
|
28
30
|
Options:
|
29
31
|
[--verbose], [--no-verbose]
|
32
|
+
[--profile=PROFILE]
|
33
|
+
[--region=REGION]
|
34
|
+
[--assume-role=ASSUME_ROLE]
|
35
|
+
[--output=OUTPUT]
|
30
36
|
```
|
data/lib/cwa/cli.rb
CHANGED
@@ -5,6 +5,7 @@ require 'thor'
|
|
5
5
|
require 'terminal-table'
|
6
6
|
require 'colorize'
|
7
7
|
require 'yaml'
|
8
|
+
require 'json'
|
8
9
|
require 'fileutils'
|
9
10
|
|
10
11
|
ASSUME_DIR = File.join(Dir.home, '.config', 'cwa').freeze
|
@@ -14,6 +15,12 @@ OUTPUT_KEYS = %i[
|
|
14
15
|
namespace
|
15
16
|
alarm_name
|
16
17
|
actions_enabled
|
18
|
+
].freeze
|
19
|
+
|
20
|
+
OUTPUT_KEYS_DETAIL = %i[
|
21
|
+
namespace
|
22
|
+
alarm_name
|
23
|
+
actions_enabled
|
17
24
|
dimensions
|
18
25
|
alarm_arn
|
19
26
|
alarm_description
|
@@ -35,6 +42,7 @@ module CWA
|
|
35
42
|
class_option :profile, type: :string
|
36
43
|
class_option :region, type: :string
|
37
44
|
class_option :assume_role, type: :string
|
45
|
+
class_option :output, type: :string
|
38
46
|
|
39
47
|
desc "alarms #{OPTIONS}", 'show cloudwatch alms'
|
40
48
|
option :name, type: :string, aliases: 'n'
|
@@ -47,11 +55,18 @@ module CWA
|
|
47
55
|
alms = output_alms
|
48
56
|
raise 'not alarms' if alms.empty?
|
49
57
|
|
50
|
-
head = alms.first.keys
|
51
|
-
rows = alms.map{|alm| alm.values }
|
52
|
-
table = Terminal::Table.new :headings => head, :rows => rows
|
53
58
|
|
54
|
-
|
59
|
+
case options[:output]
|
60
|
+
when 'json'
|
61
|
+
puts JSON.dump(alms)
|
62
|
+
when 'yaml'
|
63
|
+
puts YAML.dump(alms)
|
64
|
+
else
|
65
|
+
head = alms.first.keys
|
66
|
+
rows = alms.map{|alm| alm.values }
|
67
|
+
table = Terminal::Table.new :headings => head, :rows => rows
|
68
|
+
puts table
|
69
|
+
end
|
55
70
|
end
|
56
71
|
|
57
72
|
desc "enable #{OPTIONS}", 'enable cloudwatch alms'
|
@@ -144,10 +159,12 @@ module CWA
|
|
144
159
|
def output_alms
|
145
160
|
cwa = CWA.get(options)
|
146
161
|
alms = cwa.alarms(options)
|
162
|
+
keys = OUTPUT_KEYS
|
163
|
+
keys = OUTPUT_KEYS_DETAIL if options[:verbose]
|
147
164
|
|
148
165
|
alms.map do |alm|
|
149
166
|
v = Hash.new
|
150
|
-
|
167
|
+
keys.each do |key|
|
151
168
|
v[key] = alm.method(key).call
|
152
169
|
end
|
153
170
|
v
|
data/lib/cwa/version.rb
CHANGED