cloud_powers 0.2.7.5 → 0.2.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cloud_powers/context.rb +1 -1
- data/lib/cloud_powers/version.rb +1 -1
- data/lib/stubs/aws_stubs.rb +62 -79
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1538ba3fa5987dc1fec3bf6980eaecb2a2f72f85
|
4
|
+
data.tar.gz: d227eb099350cce6f37bf1a6bd670671ce5bb26d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df43a33011900b9097712283c2afb19f9abcbe40f04ea7f74a5e9892b69e2aa18b5b413dd99571dfc064325add2f24735af3a72c197d523bf72685fcd8ce13ab
|
7
|
+
data.tar.gz: 28c44b1cff2482c324a2e067edf70d6f9f2c71d81040d2db7beebf30e496dce8b45ce9af7dd6803612bb66d620b8d47543a463e1dc908cab16855adf8e959384
|
data/Gemfile.lock
CHANGED
data/lib/cloud_powers/context.rb
CHANGED
@@ -19,7 +19,7 @@ module Smash
|
|
19
19
|
# passed.
|
20
20
|
#
|
21
21
|
# Parameters
|
22
|
-
# * args +Hash+|+JSON+|+Array+|+
|
22
|
+
# * args +Hash+|+JSON+|+Array+|+Enumerable+
|
23
23
|
# * * expample +Hash+:
|
24
24
|
# * * * each key is a module or class that is in CloudPowers and each value
|
25
25
|
# is either an array of configurations information or a single configuration.
|
data/lib/cloud_powers/version.rb
CHANGED
data/lib/stubs/aws_stubs.rb
CHANGED
@@ -4,28 +4,30 @@ module Smash
|
|
4
4
|
module AwsStubs
|
5
5
|
|
6
6
|
# Stub metadata for EC2 instance
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
7
|
+
def instance_metadata_stub(opts = {})
|
8
|
+
{
|
9
|
+
'ami-id' => 'ami-1234',
|
10
|
+
'ami-launch-index' => '1',
|
11
|
+
'ami-manifest-path' => '',
|
12
|
+
'block-device-mapping/' => '',
|
13
|
+
'hostname' => '',
|
14
|
+
'instance-action' => '',
|
15
|
+
'instance-id' => 'asd-1234',
|
16
|
+
'instance-type' => 't2.nano',
|
17
|
+
'kernel-id' => '',
|
18
|
+
'local-hostname' => 'ip-10-251-50-12.ec2.internal',
|
19
|
+
'local-ipv4' => '',
|
20
|
+
'mac network/' => '',
|
21
|
+
'placement/' => 'boogers',
|
22
|
+
'public-hostname' => 'ec2-203-0-113-25.compute-1.amazonaws.com',
|
23
|
+
'public-ipv4' => 'adsfasdfasfd',
|
24
|
+
'public-keys/' => 'jfakdsjfkdlsajfkldsajflkasjdfklajsdflkajsldkfjalsdfjaklsdjflasjfklasjdfkals',
|
25
|
+
'public-keys/0' => 'asdjfkasdjfkasdjflasjdfklsajdlkfjaldkgfjalkdfgjklsdfjgklsdjfklsjlkdfjakdlfjalskdfjlas',
|
26
|
+
'reservation-id' => 'r-fea54097',
|
27
|
+
'security-groups' => 'groupidygroupgroupgroup',
|
28
|
+
'services/' => ''
|
29
|
+
}
|
30
|
+
end
|
29
31
|
|
30
32
|
# Get or create an EC2 client and cache that client so that a Context is more well tied together
|
31
33
|
#
|
@@ -39,24 +41,16 @@ module Smash
|
|
39
41
|
# <tt>AWS::EC2::Client</tt>
|
40
42
|
#
|
41
43
|
# Example
|
42
|
-
#
|
43
|
-
# run_instances: {
|
44
|
-
# instances: [{ instance_id: 'asd-1234', launch_time: Time.now, state: { name: 'running' }]
|
45
|
-
# },
|
46
|
-
# describe_instances: {
|
47
|
-
# reservations: [
|
48
|
-
# { instances: [{ instance_id: 'asd-1234', state: { code: 200, name: 'running' } }] }
|
49
|
-
# ] },
|
50
|
-
# describe_images: {
|
51
|
-
# images: [{ image_id: 'asdf', state: 'available' }]
|
52
|
-
# }
|
53
|
-
# }
|
54
|
-
#
|
55
|
-
# ec2(config) # sets and gets an <tt>EC2::Client</tt> that is stubbed with the return data in the config <tt>Hash</tt>
|
44
|
+
# ec2(Smash::CloudPowers::AwsStubs.node_stub) # sets and gets an <tt>EC2::Client</tt> that is stubbed with the return data in the config <tt>Hash</tt>
|
56
45
|
#
|
57
46
|
# images = ec2.describe_images
|
58
47
|
# images.first[:image_id]
|
59
48
|
# # => 'asdf'
|
49
|
+
#
|
50
|
+
# Notes
|
51
|
+
# * defaults can't be overriden or don't have good support for
|
52
|
+
# for it yet but you can use this hash as a guide
|
53
|
+
# for your own custom configuration
|
60
54
|
def self.node_stub(opts = {})
|
61
55
|
{
|
62
56
|
stub_responses: {
|
@@ -103,20 +97,15 @@ module Smash
|
|
103
97
|
# AWS::SNS client
|
104
98
|
#
|
105
99
|
# Example
|
106
|
-
#
|
107
|
-
# stub_responses: {
|
108
|
-
# create_topic: {},
|
109
|
-
# delete_topic: {},
|
110
|
-
# list_topics: [],
|
111
|
-
# publish: {},
|
112
|
-
# subscribe: {}
|
113
|
-
# }
|
114
|
-
# }
|
115
|
-
#
|
116
|
-
# sns(config) # sets and gets an Kinesis client
|
100
|
+
# sns(Smash::CloudPowers::AwsStubs.broadcast_stub) # sets and gets an Kinesis client
|
117
101
|
#
|
118
102
|
# create_channel!('testBroadcast')
|
119
103
|
# # => true
|
104
|
+
#
|
105
|
+
# Notes
|
106
|
+
# * defaults can't be overriden or don't have good support for
|
107
|
+
# for it yet but you can use this hash as a guide
|
108
|
+
# for your own custom configuration
|
120
109
|
def self.broadcast_stub(opts = {})
|
121
110
|
arn = "arn:aws:sns:us-west-2:8123456789:#{opts[:name] || 'testChannel'}"
|
122
111
|
stub = {
|
@@ -142,35 +131,24 @@ module Smash
|
|
142
131
|
# AWS::Kinesis client
|
143
132
|
#
|
144
133
|
# Example
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
# put_record: {
|
149
|
-
# shard_id: opts[:shard_id] || 'idididididididid',
|
150
|
-
# sequence_number: opts[:sequence_number] || Time.now.to_i.to_s
|
151
|
-
# },
|
152
|
-
# describe_stream: {
|
153
|
-
# stream_description: {
|
154
|
-
# stream_name: opts[:name] || 'somePipe',
|
155
|
-
# stream_arn: 'arnarnarnarnar',
|
156
|
-
# stream_status: 'ACTIVE',
|
157
|
-
# }
|
158
|
-
# }
|
159
|
-
# }
|
160
|
-
# }
|
161
|
-
# }
|
162
|
-
#
|
163
|
-
# kinesis(config) # sets and gets an Kinesis client
|
134
|
+
# # sets and gets an Kinesis client. No need to set a variable because one was
|
135
|
+
# # just created as +@kinesis+ and is set to the client
|
136
|
+
# kinesis(Smash::CloudPowers::AwsStubs.pipe_stub)
|
164
137
|
#
|
165
138
|
# pipe_to('somePipe') { update_body(status: 'waHoo') }
|
166
139
|
# # => sequence_number: '1676151970'
|
140
|
+
#
|
141
|
+
# Notes
|
142
|
+
# * defaults can't be overriden or don't have good support for
|
143
|
+
# for it yet but you can use this hash as a guide
|
144
|
+
# for your own custom configuration
|
167
145
|
def self.pipe_stub(opts = {})
|
168
146
|
stub = {
|
169
147
|
stub_responses: {
|
170
148
|
create_stream: {},
|
171
149
|
put_record: {
|
172
150
|
shard_id: opts[:shard_id] || 'idididididididid',
|
173
|
-
sequence_number: opts[:sequence_number] || '
|
151
|
+
sequence_number: opts[:sequence_number] || '1676151970'
|
174
152
|
},
|
175
153
|
describe_stream: {
|
176
154
|
stream_description: {
|
@@ -211,15 +189,14 @@ module Smash
|
|
211
189
|
# AWS::S3 client
|
212
190
|
#
|
213
191
|
# Example
|
214
|
-
#
|
215
|
-
# stub_responses: {
|
216
|
-
# head_bucket: {}
|
217
|
-
# }
|
218
|
-
# }
|
219
|
-
#
|
220
|
-
# s3(config)
|
192
|
+
# s3(Smash::CloudPowers::AwsStubs.storage_stub)
|
221
193
|
# expect(s3.head_bucket).to be_empty
|
222
194
|
# # passing expectation
|
195
|
+
#
|
196
|
+
# Notes
|
197
|
+
# * defaults can't be overriden or don't have good support for
|
198
|
+
# for it yet but you can use this hash as a guide
|
199
|
+
# for your own custom configuration
|
223
200
|
def self.storage_stub(opts = {})
|
224
201
|
{
|
225
202
|
stub_responses: {
|
@@ -231,17 +208,23 @@ module Smash
|
|
231
208
|
# Stub data for an SQS client
|
232
209
|
#
|
233
210
|
# Parameters
|
234
|
-
# * opts
|
235
|
-
# * * stub_responses
|
236
|
-
# * * region
|
237
|
-
# * * AWS::Credentials object, which will also scour the context and environment for your keys
|
211
|
+
# * opts +Hash+ (optional)
|
212
|
+
# * * +:stub_responses+ - defaulted to false but it can be overriden with the desired responses for local testing
|
213
|
+
# * * +:region+ - defaulted to use the +#region()+ method
|
214
|
+
# * * +AWS::Credentials+ object, which will also scour the context and environment for your keys
|
238
215
|
#
|
239
216
|
# Returns
|
240
217
|
# AWS::SQS client
|
241
218
|
#
|
242
219
|
# Example
|
220
|
+
# sqs(Smash::CloudPowers::AwsStubs.queue_stub(name: 'someQueue'))
|
243
221
|
# create_queue('someQueue') # uses AWS::SQS
|
244
|
-
#
|
222
|
+
# # => 'https://sqs.us-west-2.amazonaws.com/12345678/someQueue'
|
223
|
+
#
|
224
|
+
# Notes
|
225
|
+
# * defaults can't be overriden or don't have good support for
|
226
|
+
# for it yet but you can use this hash as a guide
|
227
|
+
# for your own custom configuration
|
245
228
|
def self.queue_stub(opts = {})
|
246
229
|
{
|
247
230
|
stub_responses: {
|