aerosol 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9494ad62c369aa73f67af3dca0dcc28d8dd29ef820e5bd75c05e30b4203bd950
4
- data.tar.gz: a7be58f47b1d874751346371cc3e448bcea64f5fce4846fc2b2c4875788db5ee
3
+ metadata.gz: 6d4984e8f3a4ad49c8fcf43ee3f8a46afc0a8ff5a03bc17e0e2a7c5ae51d5ff9
4
+ data.tar.gz: 6a02a6faf80b6a0bc3ccb317df748dac95d994f4a0fb146724ed844240727451
5
5
  SHA512:
6
- metadata.gz: 805b520c8b7e883e58113b864732bbd841f01d56d3d1703da8e79982d940d590a47d0f2ed5458efa523bbb03c95d81a82eee5b031d81f946f92d7ff58b1f6024
7
- data.tar.gz: 8b0390907ccbefef4e58d333f2e92da0a5489304380776fa00836fa9d578200c1623a489985aa1bff66e48e22cea84cdbcec2915ad984b1d364e0fcf31955b9d
6
+ metadata.gz: ddb94dbd6f44e8cb419d6051fc0e5855a8bc5bb9ce45de11e35da6600831d0a8f8928990d0429aa6f415b80a91381c4c198a5c1d8a2a341f7ea47992b2417178
7
+ data.tar.gz: 5f2488d1ec6336cb2a4a3aea9dadd7ab030b788bfb72fffb8723369857e875ccba832d88ecba070098c750d208de76c74ac5ee9c80cb4879f497e9f829435e0a
data/.travis.yml CHANGED
@@ -2,9 +2,9 @@ sudo: false
2
2
  dist: trusty
3
3
  language: ruby
4
4
  rvm:
5
- - 2.0
6
5
  - 2.1
7
6
  - 2.2
7
+ - 2.7
8
8
  cache: bundler
9
9
  before_install: gem install bundler -v 1.17.3
10
10
  script: CI=true bundle exec rake
@@ -7,7 +7,12 @@ class Aerosol::AutoScaling
7
7
  :desired_capacity, :health_check_grace_period, :health_check_type, :load_balancer_names,
8
8
  :placement_group, :tags, :created_time, :vpc_zone_identifier, :target_group_arns
9
9
  aws_class_attribute :launch_configuration, Aerosol::LaunchConfiguration
10
- aws_class_attribute :launch_template, Aerosol::LaunchTemplate
10
+ aws_class_attribute(
11
+ :launch_template,
12
+ Aerosol::LaunchTemplate,
13
+ proc { |argument| argument.fetch(:launch_template, {})[:launch_template_name] }
14
+ )
15
+
11
16
  primary_key :auto_scaling_group_name
12
17
 
13
18
  def initialize(options={}, &block)
@@ -88,7 +93,7 @@ class Aerosol::AutoScaling
88
93
  def all_instances
89
94
  conn.describe_auto_scaling_groups(auto_scaling_group_names: [*auto_scaling_group_name])
90
95
  .auto_scaling_groups.first
91
- .instances.map { |instance| Aerosol::Instance.from_hash(instance) }
96
+ .instances.map { |instance| Aerosol::Instance.from_hash(instance.to_hash) }
92
97
  end
93
98
 
94
99
  def launch_details
@@ -156,12 +161,6 @@ class Aerosol::AutoScaling
156
161
  }}
157
162
  end
158
163
 
159
- def self.from_hash(hash)
160
- instance = super(hash)
161
- instance['launch_template'] = (hash[:launch_template][:launch_template_name]) if hash[:launch_template]
162
- instance
163
- end
164
-
165
164
  private
166
165
  def conn
167
166
  Aerosol::AWS.auto_scaling
@@ -47,13 +47,15 @@ module Aerosol::AWSModel
47
47
  aws_attributes.merge(attrs)
48
48
  end
49
49
 
50
- def aws_class_attribute(name, klass)
50
+ def aws_class_attribute(name, klass, primary_key_proc = nil)
51
51
  unless klass.ancestors.include?(Aerosol::AWSModel) || (klass == self)
52
52
  raise '.aws_class_attribute requires a Aerosol::AWSModel that is not the current class.'
53
53
  end
54
54
 
55
+ primary_key_proc ||= proc { |hash| hash[klass.primary_key] }
56
+
55
57
  dsl_class_attribute(name, klass)
56
- aws_class_attributes.merge!({ name => klass })
58
+ aws_class_attributes.merge!({ name => [klass, primary_key_proc] })
57
59
  end
58
60
 
59
61
  def exists?(key)
@@ -67,9 +69,9 @@ module Aerosol::AWSModel
67
69
 
68
70
  def from_hash(hash)
69
71
  raise 'To use .from_hash, you must specify a primary_key' if primary_key.nil?
70
- refs = Hash[aws_class_attributes.map do |name, klass|
72
+ refs = Hash[aws_class_attributes.map do |name, (klass, primary_key_proc)|
71
73
  value = klass.instances.values.find do |inst|
72
- inst.send(klass.primary_key).to_s == hash[klass.primary_key].to_s unless inst.send(klass.primary_key).nil?
74
+ inst.send(klass.primary_key).to_s == primary_key_proc.call(hash).to_s unless inst.send(klass.primary_key).nil?
73
75
  end
74
76
  [name, value]
75
77
  end].reject { |k, v| v.nil? }
@@ -5,7 +5,11 @@ class Aerosol::Instance
5
5
 
6
6
  aws_attribute :availability_zone, :health_status, :instance_id, :lifecycle_state
7
7
  aws_class_attribute :launch_configuration, Aerosol::LaunchConfiguration
8
- aws_class_attribute :launch_template, Aerosol::LaunchTemplate
8
+ aws_class_attribute(
9
+ :launch_template,
10
+ Aerosol::LaunchTemplate,
11
+ proc { |argument| argument.fetch(:launch_template, {})[:launch_template_name] }
12
+ )
9
13
  primary_key :instance_id
10
14
 
11
15
  def live?
@@ -59,12 +63,6 @@ class Aerosol::Instance
59
63
  instances
60
64
  end
61
65
 
62
- def self.from_hash(hash)
63
- instance = super(hash)
64
- instance['launch_template'] = (hash[:launch_template][:launch_template_name]) if hash[:launch_template]
65
- instance
66
- end
67
-
68
66
  private
69
67
  def describe!
70
68
  ensure_present! :instance_id
@@ -3,7 +3,8 @@ class Aerosol::LaunchTemplate
3
3
  include Dockly::Util::Logger::Mixin
4
4
 
5
5
  logger_prefix '[aerosol launch_template]'
6
- aws_attribute :launch_template_name, :image_id, :instance_type, :security_groups, :user_data,
6
+ aws_attribute :launch_template_name, :launch_template_id, :latest_version_number,
7
+ :image_id, :instance_type, :security_groups, :user_data,
7
8
  :iam_instance_profile, :kernel_id, :key_name, :spot_price, :created_time,
8
9
  :network_interfaces, :block_device_mappings, :ebs_optimized
9
10
  dsl_attribute :meta_data
@@ -21,15 +22,6 @@ class Aerosol::LaunchTemplate
21
22
  end
22
23
  end
23
24
 
24
- def exists?
25
- info "launch_template: needed?: #{launch_template_name}: " +
26
- "checking for launch template: #{launch_template_name}"
27
- exists = super
28
- info "launch template: needed?: #{launch_template_name}: " +
29
- "#{exists ? 'found' : 'did not find'} launch template: #{launch_template_name}"
30
- exists
31
- end
32
-
33
25
  def security_group(group)
34
26
  security_groups << group
35
27
  end
@@ -48,6 +40,7 @@ class Aerosol::LaunchTemplate
48
40
  },
49
41
  }.merge(create_options)
50
42
  )
43
+
51
44
  info self.inspect
52
45
  end
53
46
 
@@ -60,7 +53,7 @@ class Aerosol::LaunchTemplate
60
53
  def all_instances
61
54
  Aerosol::Instance.all.select { |instance|
62
55
  !instance.launch_template.nil? &&
63
- (instance.launch_template == launch_template_name)
56
+ (instance.launch_template.launch_template_name == launch_template_name)
64
57
  }.each(&:description)
65
58
  end
66
59
 
@@ -78,13 +71,14 @@ class Aerosol::LaunchTemplate
78
71
  lts.concat(new_lts.launch_templates)
79
72
  next_token = new_lts.next_token
80
73
  end until next_token.nil?
81
-
82
74
  lts
83
75
  end
84
76
 
85
77
  def to_s
86
78
  %{Aerosol::LaunchTemplate { \
87
79
  "launch_template_name" => "#{launch_template_name}", \
80
+ "launch_template_id" => "#{launch_template_id}", \
81
+ "latest_version_number" => "#{latest_version_number}", \
88
82
  "image_id" => "#{image_id}", \
89
83
  "instance_type" => "#{instance_type}", \
90
84
  "security_group_ids" => #{security_groups.to_s}, \
@@ -1,5 +1,5 @@
1
1
  # Copyright Swipely, Inc. All rights reserved.
2
2
 
3
3
  module Aerosol
4
- VERSION = '1.9.1'
4
+ VERSION = '1.9.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aerosol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord