firespring_dev_commands 2.1.12.pre.alpha.1 → 2.1.12.pre.alpha.3

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: 7d45e522585dc1fc678c904d007d74a62e7dcf144ce7740a16d65d74f733f9b3
4
- data.tar.gz: 921bf69588ec64e831c6ddff866185cb639d0567dbd046cbd3109c451475d349
3
+ metadata.gz: 9f601fd4e17457b7e9191634735b25adc99e798d57fba379b389cd996c35af66
4
+ data.tar.gz: d003e9fb9b514e06c77f2b2a0f16b004dee4aa3748642c7d5bfdd0b1a97bfbe3
5
5
  SHA512:
6
- metadata.gz: d3b1641933384538aba3ad31a5b7e06bea40a28b1388567ea5d8818488860097b2d465d84fb2259d1c5f1214fece78f3ceb4cb21dba1c5e8c46e266661bd7cbe
7
- data.tar.gz: c4e70e99aaf81fbb35c60b07178fcf1fbbfa9a2fe1e7636c6b53541c9920122f382f43787c13fc9a6272784ccb0a3aa4772ac4529c2dbe2437406f90dc4fb167
6
+ metadata.gz: a27f199d0741ef7d391207bfda5841923ab4d03d6b6a77b5c49f9279ade5e3aefb009ee99d851c69486c1aed28a14de6873357c99969de24988daf4b09f572a2
7
+ data.tar.gz: a06f8a3bbc6efc62eeba0b3cdb70d361d4b034c1a9456fba12311dcaafea448408b71d3d7ce8df30a42260e092548c3431b55a68e9f273b77553835020bb0f9e
@@ -21,16 +21,10 @@ module Dev
21
21
  def pipelines(regex_match = nil)
22
22
  raise 'regex_match must be a regexp' if regex_match && !regex_match.is_a?(Regexp)
23
23
 
24
- params = {}
25
- response = client.list_pipelines(params)
26
- pipelines = response.pipelines
27
-
28
- next_token = response.next_token
29
- while next_token
30
- params[:next_token] = next_token
31
- response = client.list_pipelines(params)
32
- pipelines += response.pipelines
33
- next_token = response.next_token
24
+ pipelines = [].tap do |ary|
25
+ Dev::Aws.each_page(client, :list_pipelines) do |response|
26
+ ary.concat(response.pipelines)
27
+ end
34
28
  end
35
29
 
36
30
  pipelines.select! { |it| it.name.match(regex_match) } if regex_match
@@ -24,20 +24,12 @@ module Dev
24
24
 
25
25
  # Retrieve all parameters which start with the given path
26
26
  def list(path, recursive: true, with_decryption: true)
27
- next_token = nil
28
-
29
- parameters = []
30
- loop do
31
- response = client.get_parameters_by_path(
32
- path:,
33
- recursive:,
34
- with_decryption:,
35
- next_token:
36
- )
37
- parameters += response.parameters
38
- break unless (next_token = response.next_token)
27
+ [].tap do |ary|
28
+ params = {path:, recursive:, with_decryption:}
29
+ Dev::Aws.each_page(client, :get_parameters_by_path, params) do |response|
30
+ ary.concat(response.parameters)
31
+ end
39
32
  end
40
- parameters
41
33
  end
42
34
 
43
35
  # Sets the given parameter name's value to the given value
@@ -9,5 +9,17 @@ module Dev
9
9
 
10
10
  # The default role name used if none has been configured when logging in
11
11
  DEFAULT_LOGIN_ROLE_NAME = 'ReadonlyAccessRole'.freeze
12
+
13
+ # Runs the query on the client with the parameters
14
+ # Yields each response page
15
+ def self.each_page(client, query, params = {})
16
+ response = client.send(query, params)
17
+ yield response
18
+
19
+ while response.next_page?
20
+ response = response.next_page
21
+ yield response
22
+ end
23
+ end
12
24
  end
13
25
  end
@@ -5,60 +5,112 @@ require 'aws-sdk-opensearchservice'
5
5
 
6
6
  module Dev
7
7
  class EndOfLife
8
+ # Class which queries several different AWS product types and
9
+ # returns ProductVersion entities which can be checked for EOL
8
10
  class Aws
11
+ # Queries and returns product versions for the default product types
12
+ def default_products
13
+ (elasticache_products + lambda_products + opensearch_products + rds_products).flatten.compact
14
+ end
15
+
16
+ # Queries and returns product versions for elasticache products
9
17
  def elasticache_products
10
18
  client = ::Aws::ElastiCache::Client.new
11
- client.describe_cache_clusters.cache_clusters.filter_map do |cluster|
12
- name = cluster.cache_cluster_id
13
- product = cluster.engine
14
- version = cluster.engine_version.reverse.split('.')[-2..].join('.').reverse
15
- Dev::EndOfLife::ProductVersion.new(product, version, name)
19
+
20
+ [].tap do |ary|
21
+ Dev::Aws.each_page(client, :describe_cache_clusters) do |response|
22
+ response.cache_clusters.each do |cluster|
23
+ name = cluster.cache_cluster_id
24
+ product = cluster.engine
25
+ version = cluster.engine_version.reverse.split('.')[-2..].join('.').reverse
26
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
27
+ end
28
+ end
16
29
  end
17
30
  end
18
31
 
32
+ # Queries and returns product versions for lambda products
19
33
  def lambda_products
20
34
  client = ::Aws::Lambda::Client.new
21
- client.list_functions.functions.filter_map do |function|
22
- # Runtime is empty if using a docker image
23
- next unless function.runtime
24
35
 
25
- name = function.function_name
26
- product = function.runtime.split(/[0-9]/, 2).first
27
- version = function.runtime.split(/#{product}/, 2).last.chomp('.x')
28
- Dev::EndOfLife::ProductVersion.new(product, version, name)
36
+ [].tap do |ary|
37
+ Dev::Aws.each_page(client, :list_functions) do |response|
38
+ response.functions.each do |function|
39
+ # Runtime is empty if using a docker image
40
+ next unless function.runtime
41
+
42
+ name = function.function_name
43
+ product = function&.runtime&.split(/[0-9]/, 2)&.first
44
+ version = function&.runtime&.split(/#{product}/, 2)&.last&.chomp('.x')
45
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
46
+ end
47
+ end
29
48
  end
30
49
  end
31
50
 
51
+ # Queries and returns product versions for opensearch products
32
52
  def opensearch_products
33
53
  client = ::Aws::OpenSearchService::Client.new
34
- client.list_domain_names.domain_names.filter_map do |domain|
35
- name = domain.domain_name
36
- product = domain.engine_type
37
- version = client.describe_domain(domain_name: name).domain_status.engine_version.split('_').last.split('.').first
38
- Dev::EndOfLife::ProductVersion.new(product, version, name)
54
+
55
+ [].tap do |ary|
56
+ Dev::Aws.each_page(client, :list_domain_names) do |response|
57
+ response.domain_names.each do |domain|
58
+ name = domain.domain_name
59
+ product = domain.engine_type
60
+ version = client.describe_domain(domain_name: name).domain_status.engine_version.split('_').last.split('.').first
61
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
62
+ end
63
+ end
39
64
  end
40
65
  end
41
66
 
67
+ # Queries and returns product versions for rds products
42
68
  def rds_products
43
- supported_aws_engines = %w(mysql postgresql)
44
- supported_eol_engines = %w(mssqlserver mysql postgresql sqlite)
69
+ rds_instance_products + rds_cluster_products
70
+ end
45
71
 
72
+ # Queries and returns product versions for rds instance products
73
+ def rds_instance_products
74
+ aws_engines = %w(mysql postgresql)
46
75
  client = ::Aws::RDS::Client.new
47
- client.describe_db_instances.db_instances.filter_map do |instance|
48
- name = instance.db_instance_identifier
49
- product = if supported_aws_engines.include?(instance.engine)
50
- "amazon-rds-#{instance.engine}"
51
- elsif supported_eol_engines.include?(instance.engine)
52
- instance.engine
53
- else
54
- puts "WARNING: unsupported engine #{instance.engine} found".light_yellow
55
- next
56
- end
57
- version = instance.engine_version.reverse.split('.')[-2..].join('.').reverse
58
- Dev::EndOfLife::ProductVersion.new(product, version, name)
76
+
77
+ [].tap do |ary|
78
+ Dev::Aws.each_page(client, :describe_db_instances) do |response|
79
+ response.db_instances.each do |instance|
80
+ name = instance.db_instance_identifier
81
+ engine = instance.engine.tr('aurora-', '')
82
+ product = if aws_engines.include?(engine)
83
+ "amazon-rds-#{engine}"
84
+ else
85
+ engine
86
+ end
87
+ version = instance.engine_version.reverse.split('.')[-2..].join('.').reverse
88
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
89
+ end
90
+ end
59
91
  end
92
+ end
60
93
 
61
- # TODO: Add db cluster info too?
94
+ # Queries and returns product versions for rds cluster products
95
+ def rds_cluster_products
96
+ aws_engines = %w(mysql postgresql)
97
+ client = ::Aws::RDS::Client.new
98
+
99
+ [].tap do |ary|
100
+ Dev::Aws.each_page(client, :describe_db_clusters) do |response|
101
+ response.db_clusters.each do |cluster|
102
+ name = cluster.db_cluster_identifier
103
+ engine = cluster.engine.tr('aurora-', '')
104
+ product = if aws_engines.include?(engine)
105
+ "amazon-rds-#{engine}"
106
+ else
107
+ engine
108
+ end
109
+ version = cluster.engine_version.reverse.split('.')[-2..].join('.').reverse
110
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
111
+ end
112
+ end
113
+ end
62
114
  end
63
115
  end
64
116
  end
@@ -55,9 +55,7 @@ module Dev
55
55
  # If EOL info is a boolean or missing from the current details, overwrite with the manual date (if present)
56
56
  manual_date = Dev::EndOfLife.config.manual_dates["#{product}_#{cycle.tr('.', '_')}".to_sym]
57
57
  detail['eol'] = manual_date if manual_date && (detail['eol'].boolean? || detail['eol'].nil?)
58
-
59
- raise "unable to query eol detail for #{name}, #{cycle}" if detail.empty?
60
-
58
+ detail['eol'] = '1979-01-01' if detail.empty?
61
59
  detail
62
60
  end
63
61
 
@@ -108,12 +108,7 @@ module Dev
108
108
  account_name = Dev::Aws::Account.new.name_by_account(account_id)
109
109
  LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
110
110
 
111
- versions = Dev::EndOfLife::Aws.new.elasticache_products +
112
- Dev::EndOfLife::Aws.new.lambda_products +
113
- Dev::EndOfLife::Aws.new.opensearch_products +
114
- Dev::EndOfLife::Aws.new.rds_products
115
-
116
- Dev::EndOfLife.new(product_versions: versions.compact).check
111
+ Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).check
117
112
  end
118
113
  end
119
114
  end
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.12.pre.alpha.1'.freeze
9
+ VERSION = '2.1.12.pre.alpha.3'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.12.pre.alpha.1
4
+ version: 2.1.12.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2023-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport