infopark-aws_utils 0.8.1 → 1.0.1

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
- SHA1:
3
- metadata.gz: 006b2100b6b073324eaca1778953e0145be0fd50
4
- data.tar.gz: 81aef7b6cb4db98985357c06a27ac58309541b3a
2
+ SHA256:
3
+ metadata.gz: e8d3e58deae1c3f55e18b551ebbfb40572e1e4ff815b53d82f88e3c864289efa
4
+ data.tar.gz: 353a64a595b54c01154ea956a68734de2bf3224dca43d7a4b6bf502e5031040e
5
5
  SHA512:
6
- metadata.gz: 32e2faf37d95a697c58fa97cbe3460cf2024e42ab098c34127ad31703cc64ef4ce63176d038946d29972d6fdf2d6e69142abaefc97ccf7328c8972fc8cef0b3c
7
- data.tar.gz: a185ecc2feabf5fb080c00f2b754720e857c10ef7dc2a9f071ddb26ce06d20c5d085bfeb24a66cb9bfae49c5ee2baa21cfc2667c8dd34f7dc5d4d8d8732ff87f
6
+ metadata.gz: 3e9fa7c93e45577e8773dba59565033f7c7612740adfbd2db6fecfc9de08f9ef87523891f7406ae847a78ded73d852db7484e47fa853e9afb3731e852f275cb0
7
+ data.tar.gz: 6a1fe70450d9c804a831add17ac1b8fb08b37f1af99186f6c13f758aa84bfdbcc6a7f9f823457f36001ccaeed2e5df3a0be8dc4eb87ad876e7d2e157dc6368a5
@@ -110,18 +110,22 @@ class Env
110
110
  else
111
111
  raise "invalid root_device_type: #{root_device_type}"
112
112
  end
113
- available_images = AwsUtils.gather_all(ec2, :describe_images,
114
- owners: [AWS_AMI_OWNER],
115
- filters: [
116
- {name: "root-device-type", values: root_device_filter_value},
117
- {name: "ena-support", values: ["true"]},
118
- {name: "image-type", values: ["machine"]},
119
- {name: "virtualization-type", values: ["hvm"]},
120
- ])
121
- .reject {|image| image.name.include?(".rc-") }
122
- .reject {|image| image.name.include?("-minimal-") }
123
- .reject {|image| image.name.include?("-test") }
124
- .reject {|image| image.name.include?("amzn-ami-vpc-nat-") }
113
+ available_images = AwsUtils.gather_all(
114
+ client: ec2,
115
+ method: :describe_images,
116
+ response_key: :image_details,
117
+ owners: [AWS_AMI_OWNER],
118
+ filters: [
119
+ {name: "root-device-type", values: root_device_filter_value},
120
+ {name: "ena-support", values: ["true"]},
121
+ {name: "image-type", values: ["machine"]},
122
+ {name: "virtualization-type", values: ["hvm"]},
123
+ ],
124
+ )
125
+ .reject {|image| image.name.include?(".rc-") }
126
+ .reject {|image| image.name.include?("-minimal-") }
127
+ .reject {|image| image.name.include?("-test") }
128
+ .reject {|image| image.name.include?("amzn-ami-vpc-nat-") }
125
129
  (reject_image_name_patterns || []).each do |pattern|
126
130
  available_images.reject! {|image| image.name =~ pattern }
127
131
  end
@@ -129,12 +133,22 @@ class Env
129
133
  end
130
134
 
131
135
  def find_image_by_id(id)
132
- AwsUtils.gather_all(ec2, :describe_images, image_ids: [id]).first
136
+ AwsUtils.gather_all(
137
+ client: ec2,
138
+ method: :describe_images,
139
+ response_key: :image_details,
140
+ image_ids: [id],
141
+ ).first
133
142
  end
134
143
 
135
144
  def find_image_by_name(name)
136
- AwsUtils.gather_all(ec2, :describe_images, owners: [DEV_ACCOUNT_ID],
137
- filters: [{name: "name", values: [name]}]).first
145
+ AwsUtils.gather_all(
146
+ client: ec2,
147
+ method: :describe_images,
148
+ response_key: :image_details,
149
+ owners: [DEV_ACCOUNT_ID],
150
+ filters: [{name: "name", values: [name]}],
151
+ ).first
138
152
  end
139
153
 
140
154
  private
@@ -1,5 +1,5 @@
1
1
  module Infopark
2
2
  module AwsUtils
3
- VERSION = "0.8.1"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ module Infopark
6
6
  AWS_AMI_OWNER = "137112412989"
7
7
 
8
8
  class << self
9
- def gather_all(client, method, **options)
9
+ def gather_all(client:, method:, response_key:, **options)
10
10
  unless block_given?
11
11
  @gather_cache ||= {}
12
12
  cache_key = [client, method, options]
@@ -16,14 +16,13 @@ module Infopark
16
16
  result = []
17
17
  loop do
18
18
  response = retry_on_throttle { client.send(method, **options) }
19
- key = (response.members - [:next_token, :failures]).first
20
19
  if response.members.include?(:failures) && !response.failures.empty?
21
20
  raise "Failed gathering all #{method}: #{response.failures}"
22
21
  end
23
22
  if block_given?
24
- response[key].each {|entity| retry_on_throttle { yield entity } }
23
+ response[response_key].each {|entity| retry_on_throttle { yield entity } }
25
24
  else
26
- result += response[key]
25
+ result += response[response_key]
27
26
  end
28
27
  unless options[:next_token] = response.members.include?(:next_token) && response.next_token
29
28
  break
@@ -45,7 +44,7 @@ module Infopark
45
44
  def local_config
46
45
  @local_config ||= (
47
46
  path = "#{Dir.home}/.config/infopark/aws_utils.json"
48
- if File.exists?(path)
47
+ if File.exist?(path)
49
48
  JSON.parse(File.read(path))
50
49
  else
51
50
  {}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark-aws_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilo Prütz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-applicationautoscaling
@@ -181,11 +181,11 @@ files:
181
181
  - lib/infopark/aws_utils/version.rb
182
182
  - spec/env_spec.rb
183
183
  - spec/spec_helper.rb
184
- homepage:
184
+ homepage:
185
185
  licenses:
186
186
  - UNLICENSED
187
187
  metadata: {}
188
- post_install_message:
188
+ post_install_message:
189
189
  rdoc_options: []
190
190
  require_paths:
191
191
  - lib
@@ -200,9 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.6.13
205
- signing_key:
203
+ rubygems_version: 3.4.10
204
+ signing_key:
206
205
  specification_version: 4
207
206
  summary: A utility lib to ease the use of the AWS SDK
208
207
  test_files: []