elbas 3.0.3 → 3.0.4
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/lib/elbas.rb +0 -2
- data/lib/elbas/aws/autoscale_group.rb +14 -5
- data/lib/elbas/logger.rb +21 -3
- data/lib/elbas/version.rb +1 -1
- data/spec/aws/autoscale_group_spec.rb +15 -1
- data/spec/capistrano_spec.rb +12 -1
- data/spec/support/stubs/DescribeInstances_Empty.200.xml +17 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a9767c651ec0c1760448416fd452ca1fffb11f8506d0dae40cd736484df7caa
|
4
|
+
data.tar.gz: 5b70894f9efe95dfe0bb4744551b4830573f0eb77a33e0fef8d859153d9495c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86b52dc84b95896c1f6d9bea51d6dffa7c77042314544ca340c8e96c636116fc5a5623d4d9e88fa1f759a0fe8b7a040ded8887015e8f140c4aab3ba0c19b441
|
7
|
+
data.tar.gz: 83f24b0f72ecabcea6ddfadd01a6be41d4d4cfbc02ac55349ddaa3e9f665b145df6fabc0a9be9c6c39fcad70b9ed9d302bbc57a49255d8e538ebb049acd586a9
|
data/lib/elbas.rb
CHANGED
@@ -17,12 +17,13 @@ module Elbas
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def launch_template
|
20
|
-
|
20
|
+
lts = aws_launch_template || aws_launch_template_specification
|
21
|
+
raise Elbas::Errors::NoLaunchTemplate unless lts
|
21
22
|
|
22
23
|
LaunchTemplate.new(
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
lts.launch_template_id,
|
25
|
+
lts.launch_template_name,
|
26
|
+
lts.version
|
26
27
|
)
|
27
28
|
end
|
28
29
|
|
@@ -38,6 +39,14 @@ module Elbas
|
|
38
39
|
.first
|
39
40
|
end
|
40
41
|
|
42
|
+
def aws_launch_template
|
43
|
+
aws_counterpart.launch_template
|
44
|
+
end
|
45
|
+
|
46
|
+
def aws_launch_template_specification
|
47
|
+
aws_counterpart.mixed_instances_policy&.launch_template
|
48
|
+
&.launch_template_specification
|
49
|
+
end
|
41
50
|
end
|
42
51
|
end
|
43
|
-
end
|
52
|
+
end
|
data/lib/elbas/logger.rb
CHANGED
@@ -4,17 +4,35 @@ module Elbas
|
|
4
4
|
module Logger
|
5
5
|
include Capistrano::Doctor::OutputHelpers
|
6
6
|
|
7
|
+
PREFIX_TEXT = '[ELBAS] '.freeze
|
8
|
+
|
7
9
|
def info(message)
|
8
10
|
$stdout.puts [prefix, message, "\n"].join
|
9
11
|
end
|
10
12
|
|
11
|
-
def
|
12
|
-
|
13
|
+
def error(message)
|
14
|
+
$stderr.puts [error_prefix, message, "\n"].join
|
13
15
|
end
|
14
16
|
|
15
17
|
private
|
16
18
|
def prefix
|
17
|
-
@prefix ||= cyan(
|
19
|
+
@prefix ||= cyan(PREFIX_TEXT)
|
20
|
+
end
|
21
|
+
|
22
|
+
def error_prefix
|
23
|
+
@error_prefix ||= red(PREFIX_TEXT)
|
24
|
+
end
|
25
|
+
|
26
|
+
def cyan(text)
|
27
|
+
color_text text, :cyan
|
28
|
+
end
|
29
|
+
|
30
|
+
def red(text)
|
31
|
+
color_text text, :red
|
32
|
+
end
|
33
|
+
|
34
|
+
def color_text(text, coloring)
|
35
|
+
color.colorize text, coloring
|
18
36
|
end
|
19
37
|
end
|
20
38
|
end
|
data/lib/elbas/version.rb
CHANGED
@@ -48,6 +48,20 @@ describe Elbas::AWS::AutoscaleGroup do
|
|
48
48
|
expect(subject.launch_template.version).to eq '$Latest'
|
49
49
|
end
|
50
50
|
|
51
|
+
it 'returns a LauchTemplate object for fleet composition' do
|
52
|
+
allow(subject.aws_counterpart).to receive(:launch_template) { nil }
|
53
|
+
allow(subject.aws_counterpart).to receive_message_chain(
|
54
|
+
:mixed_instances_policy, :launch_template,
|
55
|
+
:launch_template_specification) do
|
56
|
+
double(launch_template_id: 'test-2',
|
57
|
+
launch_template_name: 'mixed_instance',
|
58
|
+
version: '$Latest')
|
59
|
+
end
|
60
|
+
|
61
|
+
expect(subject.launch_template.id).to eq 'test-2'
|
62
|
+
expect(subject.launch_template.name).to eq 'mixed_instance'
|
63
|
+
expect(subject.launch_template.version).to eq '$Latest'
|
64
|
+
end
|
51
65
|
|
52
66
|
end
|
53
|
-
end
|
67
|
+
end
|
data/spec/capistrano_spec.rb
CHANGED
@@ -63,4 +63,15 @@ describe '#autoscale' do
|
|
63
63
|
expect(env.servers.to_a[1].properties.keys).to_not include :primary
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
|
+
context 'no servers' do
|
68
|
+
before do
|
69
|
+
webmock :post, %r{ec2.(.*).amazonaws.com\/\z} => 'DescribeInstances_Empty.200.xml',
|
70
|
+
with: Hash[body: /Action=DescribeInstances/]
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'logs as an error' do
|
74
|
+
expect { autoscale 'test-asg' }.to output.to_stderr
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
|
2
|
+
<requestId>fdcdcab1-ae5c-489e-9c33-4637c5dda355</requestId>
|
3
|
+
<reservationSet>
|
4
|
+
<item>
|
5
|
+
<reservationId>r-1a2b3c4d</reservationId>
|
6
|
+
<ownerId>123456789012</ownerId>
|
7
|
+
<groupSet>
|
8
|
+
<item>
|
9
|
+
<groupId>sg-1a2b3c4d</groupId>
|
10
|
+
<groupName>my-security-group</groupName>
|
11
|
+
</item>
|
12
|
+
</groupSet>
|
13
|
+
<instancesSet>
|
14
|
+
</instancesSet>
|
15
|
+
</item>
|
16
|
+
</reservationSet>
|
17
|
+
</DescribeInstancesResponse>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elbas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Serman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- spec/support/stubs/DescribeAutoScalingGroups.200.xml
|
185
185
|
- spec/support/stubs/DescribeImages.200.xml
|
186
186
|
- spec/support/stubs/DescribeInstances.200.xml
|
187
|
+
- spec/support/stubs/DescribeInstances_Empty.200.xml
|
187
188
|
- spec/support/stubs/DescribeInstances_MultipleReservations.200.xml
|
188
189
|
- spec/support/stubs/DescribeInstances_MultipleRunning.200.xml
|
189
190
|
- spec/support/stubs/DescribeLaunchConfigurations.200.xml
|
@@ -233,6 +234,7 @@ test_files:
|
|
233
234
|
- spec/support/stubs/DescribeAutoScalingGroups.200.xml
|
234
235
|
- spec/support/stubs/DescribeImages.200.xml
|
235
236
|
- spec/support/stubs/DescribeInstances.200.xml
|
237
|
+
- spec/support/stubs/DescribeInstances_Empty.200.xml
|
236
238
|
- spec/support/stubs/DescribeInstances_MultipleReservations.200.xml
|
237
239
|
- spec/support/stubs/DescribeInstances_MultipleRunning.200.xml
|
238
240
|
- spec/support/stubs/DescribeLaunchConfigurations.200.xml
|