outliers 0.2.0 → 0.3.0
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/CHANGELOG.md +8 -0
- data/README.md +6 -66
- data/lib/outliers/cli/process.rb +12 -3
- data/lib/outliers/cli.rb +0 -24
- data/lib/outliers/collection.rb +15 -15
- data/lib/outliers/filters/aws/ec2/tags.rb +1 -1
- data/lib/outliers/info.rb +12 -0
- data/lib/outliers/provider.rb +0 -4
- data/lib/outliers/providers/aws/cloud_formation.rb +1 -5
- data/lib/outliers/providers/aws/ec2.rb +1 -5
- data/lib/outliers/providers/aws/elb.rb +1 -5
- data/lib/outliers/providers/aws/iam.rb +1 -5
- data/lib/outliers/providers/aws/rds.rb +1 -5
- data/lib/outliers/providers/aws/s3.rb +1 -5
- data/lib/outliers/providers/aws/{base.rb → shared.rb} +0 -10
- data/lib/outliers/providers/aws/sqs.rb +1 -5
- data/lib/outliers/providers/aws.rb +1 -1
- data/lib/outliers/resources/aws/ec2/instance.rb +0 -16
- data/lib/outliers/resources/aws/ec2/security_group.rb +0 -7
- data/lib/outliers/resources/aws/elb/load_balancer.rb +0 -7
- data/lib/outliers/resources/aws/iam/user.rb +0 -10
- data/lib/outliers/resources/aws/rds/db_instance.rb +0 -10
- data/lib/outliers/resources/aws/s3/bucket.rb +0 -13
- data/lib/outliers/resources.rb +4 -0
- data/lib/outliers/run.rb +24 -8
- data/lib/outliers/verifications/shared.rb +4 -16
- data/lib/outliers/version.rb +1 -1
- data/lib/outliers.rb +1 -0
- data/reference.yaml +128 -0
- data/spec/collection_spec.rb +3 -3
- data/spec/filters/aws/ec2/tags_spec.rb +1 -1
- data/spec/info_spec.rb +41 -0
- data/spec/run_spec.rb +57 -10
- data/spec/verifications/shared_spec.rb +6 -6
- metadata +7 -6
- data/lib/outliers/cli/evaluate.rb +0 -136
- data/lib/outliers/cli/providers.rb +0 -29
- data/lib/outliers/cli/resources.rb +0 -60
@@ -3,25 +3,13 @@ module Outliers
|
|
3
3
|
module Shared
|
4
4
|
|
5
5
|
def none_exist?
|
6
|
-
|
6
|
+
list
|
7
7
|
end
|
8
8
|
|
9
9
|
def equals?(args)
|
10
|
-
|
11
|
-
logger.debug "Verifying '#{list.join(',')}' equals '#{
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
module_function
|
16
|
-
|
17
|
-
def verifications
|
18
|
-
[
|
19
|
-
{ name: 'none_exist',
|
20
|
-
description: 'Verify no resources exist.' },
|
21
|
-
{ name: 'equals',
|
22
|
-
description: 'Verify resources match the given list of keys.',
|
23
|
-
args: 'keys: [KEY1,KEY2]' }
|
24
|
-
]
|
10
|
+
keys = Array(args[:keys])
|
11
|
+
logger.debug "Verifying '#{list.join(',')}' equals '#{list.empty? ? 'no resources' : list_by_key.join(',')}'."
|
12
|
+
list.reject {|r| keys.include? r.id}
|
25
13
|
end
|
26
14
|
|
27
15
|
end
|
data/lib/outliers/version.rb
CHANGED
data/lib/outliers.rb
CHANGED
data/reference.yaml
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
all:
|
2
|
+
credentials:
|
3
|
+
access_key_id: AWS Account Access Key
|
4
|
+
secret_access_key: AWS Account Secret Key
|
5
|
+
region: AWS Region (Default us-east-1)
|
6
|
+
resources:
|
7
|
+
shared:
|
8
|
+
description: Verifications which are available to all resources.
|
9
|
+
verifications:
|
10
|
+
none_exist:
|
11
|
+
description: Verify no resources exist in list.
|
12
|
+
equals:
|
13
|
+
description: Verify no resources match the given list of keys.
|
14
|
+
args: 'keys: [KEY1,KEY2]'
|
15
|
+
|
16
|
+
aws_cloud_formation:
|
17
|
+
credentials:
|
18
|
+
access_key_id: AWS Account Access Key
|
19
|
+
secret_access_key: AWS Account Secret Key
|
20
|
+
region: AWS Region (Default us-east-1)
|
21
|
+
resources:
|
22
|
+
stack:
|
23
|
+
description: AWS Cloud Formation Stack
|
24
|
+
verifications: {}
|
25
|
+
|
26
|
+
aws_ec2:
|
27
|
+
credentials:
|
28
|
+
access_key_id: AWS Account Access Key
|
29
|
+
secret_access_key: AWS Account Secret Key
|
30
|
+
region: AWS Region (Default us-east-1)
|
31
|
+
resources:
|
32
|
+
instance:
|
33
|
+
description: AWS EC2 Instance
|
34
|
+
verifications:
|
35
|
+
classic:
|
36
|
+
description: Instance is in AWS Classic (No VPC).
|
37
|
+
source_dest_check:
|
38
|
+
description: Instance source dest check set to true.
|
39
|
+
running:
|
40
|
+
description: Instance status is running.
|
41
|
+
valid_image_id:
|
42
|
+
description: ami_ids=ami_id1,ami_id2 - Instances Image ID (AMI) is in given list.
|
43
|
+
args: 'image_ids: [IMAGE_ID1, IMAGEID2]'
|
44
|
+
vpc:
|
45
|
+
description: Instance is in a VPC.
|
46
|
+
security_group:
|
47
|
+
description: AWS EC2 Security Group
|
48
|
+
verifications:
|
49
|
+
no_public_internet_ingress:
|
50
|
+
description: Security Group has no rules open to 0.0.0.0/0.
|
51
|
+
image:
|
52
|
+
description: AWS EC2 AMI
|
53
|
+
verifications: {}
|
54
|
+
|
55
|
+
aws_elb:
|
56
|
+
credentials:
|
57
|
+
access_key_id: AWS Account Access Key
|
58
|
+
secret_access_key: AWS Account Secret Key
|
59
|
+
region: AWS Region (Default us-east-1)
|
60
|
+
resources:
|
61
|
+
load_balancer:
|
62
|
+
description: AWS ELB (Elastic Load Balancer)
|
63
|
+
verifications:
|
64
|
+
ssl_certificates_valid:
|
65
|
+
description: Validates all SSL certificates associated with an ELB are valid for given number of days.
|
66
|
+
args: 'days: DAYS'
|
67
|
+
|
68
|
+
aws_iam:
|
69
|
+
credentials:
|
70
|
+
access_key_id: AWS Account Access Key
|
71
|
+
secret_access_key: AWS Account Secret Key
|
72
|
+
region: AWS Region (Default us-east-1)
|
73
|
+
resources:
|
74
|
+
user:
|
75
|
+
description: AWS IAM User
|
76
|
+
verifications:
|
77
|
+
mfa_enabled:
|
78
|
+
description: Verify MFA enabled for user.
|
79
|
+
no_access_keys:
|
80
|
+
description: Verify user has no access keys.
|
81
|
+
no_password_set:
|
82
|
+
description: Verify password not set for user.
|
83
|
+
|
84
|
+
aws_rds:
|
85
|
+
credentials:
|
86
|
+
access_key_id: AWS Account Access Key
|
87
|
+
secret_access_key: AWS Account Secret Key
|
88
|
+
region: AWS Region (Default us-east-1)
|
89
|
+
resources:
|
90
|
+
db_instance:
|
91
|
+
description: AWS RDS Database Instance
|
92
|
+
verifications:
|
93
|
+
backup_retention_period:
|
94
|
+
description: Validate the backup retention period equals given days for the db_instance.
|
95
|
+
args: 'days: DAYS'
|
96
|
+
multi_az:
|
97
|
+
description: RDS Multi AZ set to yes.
|
98
|
+
db_snapshot:
|
99
|
+
description: AWS RDS Database Snapshot
|
100
|
+
verifications: {}
|
101
|
+
|
102
|
+
aws_s3:
|
103
|
+
credentials:
|
104
|
+
access_key_id: AWS Account Access Key
|
105
|
+
secret_access_key: AWS Account Secret Key
|
106
|
+
region: AWS Region (Default us-east-1)
|
107
|
+
resources:
|
108
|
+
bucket:
|
109
|
+
description: AWS S3 Bucket
|
110
|
+
verifications:
|
111
|
+
empty:
|
112
|
+
description: Bucket has no objects.
|
113
|
+
no_public_objects:
|
114
|
+
description: Bucket has no public accessible objects.
|
115
|
+
configured_as_website:
|
116
|
+
description: Bucket is configured as a website.
|
117
|
+
not_configured_as_website:
|
118
|
+
description: Bucket is not configured as a website.
|
119
|
+
|
120
|
+
aws_sqs:
|
121
|
+
credentials:
|
122
|
+
access_key_id: AWS Account Access Key
|
123
|
+
secret_access_key: AWS Account Secret Key
|
124
|
+
region: AWS Region (Default us-east-1)
|
125
|
+
resources:
|
126
|
+
queue:
|
127
|
+
description: AWS SQS Queue
|
128
|
+
verifications: {}
|
data/spec/collection_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe Outliers::Collection do
|
|
31
31
|
context "#exclude" do
|
32
32
|
it "should exclude the given array of resources" do
|
33
33
|
subject.exclude_by_key ['resource1']
|
34
|
-
expect(subject.
|
34
|
+
expect(subject.list).to eq([resource2])
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,7 +39,7 @@ describe Outliers::Collection do
|
|
39
39
|
it "should apply the given filter to resources" do
|
40
40
|
subject.should_receive('filter_tag').with('Name:test123').and_return [resource1]
|
41
41
|
subject.filter 'tag' => 'Name:test123'
|
42
|
-
expect(subject.
|
42
|
+
expect(subject.list).to eq([resource1])
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should raise an exception if the filter does not exist" do
|
@@ -120,7 +120,7 @@ describe Outliers::Collection do
|
|
120
120
|
to raise_error(Outliers::Exceptions::NoArgumentRequired)
|
121
121
|
end
|
122
122
|
|
123
|
-
it "should return empty passing and failing arrays if no resources exist in
|
123
|
+
it "should return empty passing and failing arrays if no resources exist in list" do
|
124
124
|
subject.stub :load_all => []
|
125
125
|
expect(subject.verify 'valid_resource?', {}).to eq( { failing_resources: [], passing_resources: [] } )
|
126
126
|
end
|
@@ -15,7 +15,7 @@ describe Outliers::Filters::Aws::Ec2::Tags do
|
|
15
15
|
|
16
16
|
before do
|
17
17
|
subject.stub :logger => logger
|
18
|
-
subject.stub :
|
18
|
+
subject.stub :list => [resource1, resource2]
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return the list of instances filtered by the given tag name and value" do
|
data/spec/info_spec.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Outliers::Info do
|
4
|
+
context "#reference" do
|
5
|
+
before do
|
6
|
+
@resources = []
|
7
|
+
subject.reference.each_pair do |name,data|
|
8
|
+
data['resources'].keys.each do |key|
|
9
|
+
@resources << "#{name}_#{key}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to load reference.yaml" do
|
15
|
+
expect(subject.reference.keys.include?('all')).to be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should verify each provider class has a entry in reference.yaml" do
|
19
|
+
expect(subject.reference.keys - ['all']).to eq(Outliers::Providers.name_map.keys)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should verify each resource method has a entry in reference.yaml" do
|
23
|
+
expect((@resources - ['all_shared']).sort).to eq(Outliers::Resources.list.map {|r| r.to_human}.sort)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should validate each resource has a verification list and description" do
|
27
|
+
subject.reference.each_value do |provider_data|
|
28
|
+
provider_data['resources'].each_value do |resource_data|
|
29
|
+
expect(resource_data['verifications'].class).to eq(Hash)
|
30
|
+
expect(resource_data['description'].class).to eq(String)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should validate each resource has a list of credentials" do
|
36
|
+
subject.reference.each_value do |provider_data|
|
37
|
+
expect(provider_data['credentials'].class).to eq(Hash)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/run_spec.rb
CHANGED
@@ -9,8 +9,8 @@ describe Outliers::Run do
|
|
9
9
|
Outliers.config_path '/test'
|
10
10
|
end
|
11
11
|
|
12
|
-
describe "#
|
13
|
-
|
12
|
+
describe "#process_evaluations_in_dir" do
|
13
|
+
before do
|
14
14
|
files = ['/test/test1.rb', '/test/dir', '/test/dir/test2.rb', '/test/dir/test_other_file']
|
15
15
|
Dir.should_receive(:glob).with('/test/**/*').and_return files
|
16
16
|
|
@@ -21,24 +21,71 @@ describe Outliers::Run do
|
|
21
21
|
|
22
22
|
File.should_receive(:read).with('/test/test1.rb').and_return evaluation1
|
23
23
|
File.should_receive(:read).with('/test/dir/test2.rb').and_return evaluation2
|
24
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should process all .rb files in config folder and sub folders" do
|
27
|
+
subject.should_receive(:instance_eval).with(evaluation1)
|
28
|
+
subject.should_receive(:instance_eval).with(evaluation2)
|
29
|
+
subject.process_evaluations_in_dir
|
30
|
+
end
|
31
|
+
|
32
|
+
it "each thread created for an evaluation should be re-joined" do
|
33
|
+
thread_mock = mock 'thread'
|
34
|
+
subject.threaded = true
|
35
|
+
subject.threads = [thread_mock]
|
25
36
|
subject.should_receive(:instance_eval).with(evaluation1)
|
26
37
|
subject.should_receive(:instance_eval).with(evaluation2)
|
27
|
-
|
38
|
+
thread_mock.should_receive(:join)
|
39
|
+
subject.process_evaluations_in_dir
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
31
43
|
describe "#evaluate" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
connect
|
44
|
+
context "with name" do
|
45
|
+
before do
|
46
|
+
Outliers::Evaluation.should_receive(:new).with(:name => 'my evaluation', :run => subject).
|
47
|
+
and_return evaluation1
|
48
|
+
evaluation1.should_receive(:connect).with('test')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should kick off a new evaluation and pass the block for execuation" do
|
52
|
+
subject.evaluate 'my evaluation' do
|
53
|
+
connect 'test'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should sleep if more than thread_count threads running" do
|
58
|
+
list_stub = stub "list"
|
59
|
+
list_stub.stub(:count).and_return(6,1)
|
60
|
+
Thread.stub :list => list_stub
|
61
|
+
subject.should_receive(:sleep).with(2)
|
62
|
+
subject.evaluate 'my evaluation' do
|
63
|
+
connect 'test'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "testing threads" do
|
68
|
+
it "should kick off a new thread if threaded is set to true" do
|
69
|
+
subject.threaded = true
|
70
|
+
Thread.should_receive(:new).and_yield { 'a thread' }
|
71
|
+
subject.evaluate 'my evaluation' do
|
72
|
+
connect 'test'
|
73
|
+
end
|
74
|
+
subject.threads.count == 1
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should not kick off a new thread if threaded is set to false" do
|
78
|
+
subject.evaluate 'my evaluation' do
|
79
|
+
connect 'test'
|
80
|
+
end
|
81
|
+
subject.threads.count == 0
|
82
|
+
end
|
37
83
|
end
|
38
84
|
end
|
39
85
|
|
40
86
|
it "should kick off a new evaluation with unspecified name" do
|
41
|
-
Outliers::Evaluation.should_receive(:new).with(:name => 'unspecified', :run => subject).
|
87
|
+
Outliers::Evaluation.should_receive(:new).with(:name => 'unspecified', :run => subject).
|
88
|
+
and_return evaluation1
|
42
89
|
evaluation1.should_receive(:connect).with('test')
|
43
90
|
subject.evaluate do
|
44
91
|
connect 'test'
|
@@ -12,30 +12,30 @@ describe Outliers::Verifications::Shared do
|
|
12
12
|
|
13
13
|
context "#none_exist?" do
|
14
14
|
it "should be true if no resources returned" do
|
15
|
-
subject.stub :
|
15
|
+
subject.stub :list => []
|
16
16
|
expect(subject.none_exist?).to eq([])
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should be false if resources returned" do
|
20
|
-
subject.stub :
|
21
|
-
subject.stub :
|
20
|
+
subject.stub :list_by_key => ['resource1']
|
21
|
+
subject.stub :list => ['resource1']
|
22
22
|
expect(subject.none_exist?).to eq(['resource1'])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
context "#equals?" do
|
27
27
|
it "should verify the list of resources equals the list of keys and return no failing reosurces" do
|
28
|
-
subject.stub :
|
28
|
+
subject.stub :list_by_key => ['resource1'], :list => [resource1]
|
29
29
|
expect(subject.equals?(:keys => ['resource1'])).to eq([])
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should verify the list of resources equals the single key and return no failing resources" do
|
33
|
-
subject.stub :
|
33
|
+
subject.stub :list_by_key => ['resource1'], :list => [resource1]
|
34
34
|
expect(subject.equals?(:keys => 'resource1')).to eq([])
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should return resources which do not match the given list" do
|
38
|
-
subject.stub :
|
38
|
+
subject.stub :list_by_key => ['resource1', 'resource2'], :list => [resource1, resource2]
|
39
39
|
expect(subject.equals?(:keys => 'resource1')).to eq([resource2])
|
40
40
|
end
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outliers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Weaver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,10 +86,7 @@ files:
|
|
86
86
|
- bin/outliers
|
87
87
|
- lib/outliers.rb
|
88
88
|
- lib/outliers/cli.rb
|
89
|
-
- lib/outliers/cli/evaluate.rb
|
90
89
|
- lib/outliers/cli/process.rb
|
91
|
-
- lib/outliers/cli/providers.rb
|
92
|
-
- lib/outliers/cli/resources.rb
|
93
90
|
- lib/outliers/collection.rb
|
94
91
|
- lib/outliers/credentials.rb
|
95
92
|
- lib/outliers/evaluation.rb
|
@@ -98,17 +95,18 @@ files:
|
|
98
95
|
- lib/outliers/filters/aws.rb
|
99
96
|
- lib/outliers/filters/aws/ec2.rb
|
100
97
|
- lib/outliers/filters/aws/ec2/tags.rb
|
98
|
+
- lib/outliers/info.rb
|
101
99
|
- lib/outliers/mixins.rb
|
102
100
|
- lib/outliers/provider.rb
|
103
101
|
- lib/outliers/providers.rb
|
104
102
|
- lib/outliers/providers/aws.rb
|
105
|
-
- lib/outliers/providers/aws/base.rb
|
106
103
|
- lib/outliers/providers/aws/cloud_formation.rb
|
107
104
|
- lib/outliers/providers/aws/ec2.rb
|
108
105
|
- lib/outliers/providers/aws/elb.rb
|
109
106
|
- lib/outliers/providers/aws/iam.rb
|
110
107
|
- lib/outliers/providers/aws/rds.rb
|
111
108
|
- lib/outliers/providers/aws/s3.rb
|
109
|
+
- lib/outliers/providers/aws/shared.rb
|
112
110
|
- lib/outliers/providers/aws/sqs.rb
|
113
111
|
- lib/outliers/resource.rb
|
114
112
|
- lib/outliers/resources.rb
|
@@ -139,6 +137,7 @@ files:
|
|
139
137
|
- lib/outliers/verifications/shared.rb
|
140
138
|
- lib/outliers/version.rb
|
141
139
|
- outliers.gemspec
|
140
|
+
- reference.yaml
|
142
141
|
- spec/collection_spec.rb
|
143
142
|
- spec/credentials_spec.rb
|
144
143
|
- spec/evaluation_spec.rb
|
@@ -146,6 +145,7 @@ files:
|
|
146
145
|
- spec/fixtures/credentials1.yml
|
147
146
|
- spec/fixtures/credentials2.yml
|
148
147
|
- spec/helpers/fixtures.rb
|
148
|
+
- spec/info_spec.rb
|
149
149
|
- spec/mixins_spec.rb
|
150
150
|
- spec/provider_spec.rb
|
151
151
|
- spec/providers_spec.rb
|
@@ -187,6 +187,7 @@ test_files:
|
|
187
187
|
- spec/fixtures/credentials1.yml
|
188
188
|
- spec/fixtures/credentials2.yml
|
189
189
|
- spec/helpers/fixtures.rb
|
190
|
+
- spec/info_spec.rb
|
190
191
|
- spec/mixins_spec.rb
|
191
192
|
- spec/provider_spec.rb
|
192
193
|
- spec/providers_spec.rb
|
@@ -1,136 +0,0 @@
|
|
1
|
-
module Outliers
|
2
|
-
module CLI
|
3
|
-
class Evaluate
|
4
|
-
def evaluate
|
5
|
-
@options = { arguments: [], exclude: [], filter: [], credentials: [], target_resources: [] }
|
6
|
-
@credentials = {}
|
7
|
-
|
8
|
-
option_parser.parse!
|
9
|
-
|
10
|
-
Outliers.config_path @options[:config]
|
11
|
-
|
12
|
-
@logger = Outliers.logger
|
13
|
-
@run = Run.new
|
14
|
-
|
15
|
-
load_credentials
|
16
|
-
|
17
|
-
@options[:parsed_arguments] = parse_arguments
|
18
|
-
@options[:parsed_filters] = parse_filters
|
19
|
-
|
20
|
-
# Make options available global
|
21
|
-
# Required to read by instance_eval in @run.evaluate
|
22
|
-
@@options = @options
|
23
|
-
|
24
|
-
begin
|
25
|
-
@run.evaluate "Running verification provided via CLI." do
|
26
|
-
connect 'cli'
|
27
|
-
resources @@options[:resource], @@options[:target_resources]
|
28
|
-
exclude @@options[:exclude] if @@options[:exclude].any?
|
29
|
-
filter @@options[:parsed_filters] if @@options[:filter].any?
|
30
|
-
verify @@options[:verification], @@options[:parsed_arguments]
|
31
|
-
end
|
32
|
-
rescue Outliers::Exceptions::Base => e
|
33
|
-
@logger.error e.message
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
|
37
|
-
exit 1 if @run.results.first.failed?
|
38
|
-
end
|
39
|
-
|
40
|
-
def command_name
|
41
|
-
'evaluate'
|
42
|
-
end
|
43
|
-
|
44
|
-
def command_summary
|
45
|
-
'Evaluate the given verification.'
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def load_credentials
|
51
|
-
credentials_name = @options[:credential_name]
|
52
|
-
credentials = Credentials.load_from_file("#{ENV['HOME']}/.outliers.yml").fetch credentials_name
|
53
|
-
credentials.merge! 'provider' => @options[:provider]
|
54
|
-
|
55
|
-
if @options[:credentials].any?
|
56
|
-
@options[:credentials].each do |c|
|
57
|
-
key = c.split('=').first
|
58
|
-
value = c.split('=').last
|
59
|
-
credentials.merge! key => value
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
@run.credentials = { 'cli' => credentials }
|
64
|
-
end
|
65
|
-
|
66
|
-
def parse_filters
|
67
|
-
filters = {}
|
68
|
-
|
69
|
-
@options[:filter].each do |a|
|
70
|
-
key = a.split('=').first
|
71
|
-
value = a.split('=').last
|
72
|
-
filters.merge! key => value
|
73
|
-
end
|
74
|
-
|
75
|
-
filters
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
def parse_arguments
|
80
|
-
arguments = {}
|
81
|
-
|
82
|
-
@options[:arguments].each do |a|
|
83
|
-
key = a.split('=').first
|
84
|
-
value = a.split('=').last
|
85
|
-
value = value.split(',') if value.include?(',')
|
86
|
-
arguments.merge! key => value
|
87
|
-
end
|
88
|
-
|
89
|
-
arguments
|
90
|
-
end
|
91
|
-
|
92
|
-
def option_parser
|
93
|
-
OptionParser.new do |opts|
|
94
|
-
opts.banner = "Usage: outliers evaluate [options]"
|
95
|
-
|
96
|
-
opts.on("-a", "--argument [NAME]", "Equals seperated key and value to pass as argument to verification (can be specified multiple times).") do |o|
|
97
|
-
@options[:arguments] << o
|
98
|
-
end
|
99
|
-
|
100
|
-
opts.on("-c", "--credential_name [CREDENTIAL_NAME]", "Name to load from credentials file.") do |o|
|
101
|
-
@options[:credential_name] = o
|
102
|
-
end
|
103
|
-
|
104
|
-
opts.on("-e", "--exclude [EXCLUDE]", "Exclude resources in collection with the given key (can be specified multiple times).") do |o|
|
105
|
-
@options[:exclude] << o
|
106
|
-
end
|
107
|
-
|
108
|
-
opts.on("-f", "--fitler [FILTER]", "Equals seperated filter name and value (can be specified multiple times).") do |o|
|
109
|
-
@options[:filter] << o
|
110
|
-
end
|
111
|
-
|
112
|
-
opts.on("-p", "--provider [PROVIDER]", "Provider of target resources.") do |o|
|
113
|
-
@options[:provider] = o
|
114
|
-
end
|
115
|
-
|
116
|
-
opts.on("-r", "--resources [RESOURCES]", "Name of resource collection to evaluate.") do |o|
|
117
|
-
@options[:resource] = o
|
118
|
-
end
|
119
|
-
|
120
|
-
opts.on("-t", "--target_resources [TARGET_RESOURCES]", "Target resources with key name (can be specified more than once).") do |o|
|
121
|
-
@options[:target_resources] << o
|
122
|
-
end
|
123
|
-
|
124
|
-
opts.on("-v", "--verification [VERIFICATION]", "Verification to perform against collection of resources.") do |o|
|
125
|
-
@options[:verification] = o
|
126
|
-
end
|
127
|
-
|
128
|
-
opts.on("--credentials [CREDENTIALS]", "Equals seperated key and value to include as credentials (can be specified multiple times).") do |o|
|
129
|
-
@options[:credentials] << o
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Outliers
|
2
|
-
module CLI
|
3
|
-
class Providers
|
4
|
-
def providers
|
5
|
-
option_parser.parse!
|
6
|
-
list = Outliers::Providers.name_map
|
7
|
-
list.each_pair do |k,v|
|
8
|
-
puts k
|
9
|
-
v.credential_arguments.each_pair { |k,v| puts " #{k}: #{v}" }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def command_name
|
14
|
-
'providers'
|
15
|
-
end
|
16
|
-
|
17
|
-
def command_summary
|
18
|
-
'List available providers.'
|
19
|
-
end
|
20
|
-
|
21
|
-
def option_parser
|
22
|
-
OptionParser.new do |opts|
|
23
|
-
opts.banner = "Usage: outliers providers"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Outliers
|
2
|
-
module CLI
|
3
|
-
class Resources
|
4
|
-
def resources
|
5
|
-
@options = {}
|
6
|
-
|
7
|
-
option_parser.parse!
|
8
|
-
|
9
|
-
provider = @options[:provider]
|
10
|
-
|
11
|
-
@logger = Outliers.logger
|
12
|
-
|
13
|
-
unless provider
|
14
|
-
@logger.error "Required parameter 'provider' not specified."
|
15
|
-
exit 1
|
16
|
-
end
|
17
|
-
|
18
|
-
all = Outliers::Resources.collections
|
19
|
-
|
20
|
-
list = all.select { |r| r.to_human =~ /^#{provider}_.*$/ }
|
21
|
-
|
22
|
-
if list.any?
|
23
|
-
list.each do |r|
|
24
|
-
name = r.to_human
|
25
|
-
name.slice! provider
|
26
|
-
name[0] = ''
|
27
|
-
puts name
|
28
|
-
puts " Verifications:"
|
29
|
-
r.verifications.each { |v| puts " #{v[:name]}(#{v[:args]}) #{v[:description]}" }
|
30
|
-
puts " Filters:"
|
31
|
-
r.filters.each { |v| puts " #{v[:name]}(#{v[:args]}) #{v[:description]}" }
|
32
|
-
end
|
33
|
-
else
|
34
|
-
puts "No resources found for '#{provider}'."
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def command_name
|
39
|
-
'resources'
|
40
|
-
end
|
41
|
-
|
42
|
-
def command_summary
|
43
|
-
'List available resources for a provider.'
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def option_parser
|
49
|
-
OptionParser.new do |opts|
|
50
|
-
opts.banner = "Usage: outliers resources [options]"
|
51
|
-
|
52
|
-
opts.on("-p", "--provider [PROVIDER]", "Provider to list resources.") do |o|
|
53
|
-
@options[:provider] = o
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|