firespring_dev_commands 2.1.13.pre.alpha.2 → 2.1.13
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/firespring_dev_commands/aws/codepipeline.rb +4 -10
- data/lib/firespring_dev_commands/aws/parameter.rb +5 -13
- data/lib/firespring_dev_commands/aws.rb +12 -0
- data/lib/firespring_dev_commands/common.rb +82 -7
- data/lib/firespring_dev_commands/eol/aws.rb +117 -0
- data/lib/firespring_dev_commands/eol/product_version.rb +1 -3
- data/lib/firespring_dev_commands/templates/aws.rb +19 -0
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +61 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a84986a2061f8fe6b475bc9fbf6b0593abffa358128f97e9fe5e6de67be450ff
|
|
4
|
+
data.tar.gz: 54b7e228c92940a12695a86f1866f2e2c10e382a785004c6d3ad021f79da0fd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9233d5fe012349dc028739ff650ef4df1ffba9b8692a5c7141a0db600d10aed51191d9c65f92fadc7a6e4f88240226df815cbac993c4965781440aed09ffd0e
|
|
7
|
+
data.tar.gz: 539dd77c64dc43c8711e5fe2b4f0ad7409b55e1ddf6687aa83372526d3648aa7e7eee8bea6ccee62ac9924201773bbc4addf27f0993eb9b609fe74009833c9d4
|
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
@@ -40,7 +40,8 @@ module Dev
|
|
|
40
40
|
# Wraps a block of code in a y/n question.
|
|
41
41
|
# If the user answers 'y' then the block is executed.
|
|
42
42
|
# If the user answers 'n' then the block is skipped.
|
|
43
|
-
|
|
43
|
+
# @deprecated Please use {Common#when_confirmed} instead
|
|
44
|
+
def with_confirmation(message, default = 'y', color_message: true)
|
|
44
45
|
message = "\n #{message}" << '? '.light_green
|
|
45
46
|
message = message.light_green if color_message
|
|
46
47
|
print message
|
|
@@ -49,15 +50,89 @@ module Dev
|
|
|
49
50
|
answer = default
|
|
50
51
|
answer = $stdin.gets unless ENV['NON_INTERACTIVE'] == 'true'
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
puts
|
|
54
|
-
yield
|
|
55
|
-
elsif exit_unconfirmed
|
|
53
|
+
unless answer.strip.casecmp('y').zero?
|
|
56
54
|
puts "\n Cancelled.\n".light_yellow
|
|
57
55
|
exit 1
|
|
58
|
-
else
|
|
59
|
-
puts
|
|
60
56
|
end
|
|
57
|
+
puts
|
|
58
|
+
|
|
59
|
+
yield
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Exits unless the user confirms they want to continue
|
|
63
|
+
# If the user answers 'y' then the code will continue
|
|
64
|
+
# All other inputs cause the code to exit
|
|
65
|
+
def exit_unless_confirmed(message, default: nil, colorize: true)
|
|
66
|
+
# If a default is given, it must be y or n
|
|
67
|
+
raise 'invalid default' if default && !%w(y n).include?(default)
|
|
68
|
+
|
|
69
|
+
# print the colorized message (if requested) with the default (if given)
|
|
70
|
+
print(confirmation_message(message, default:, colorize:))
|
|
71
|
+
|
|
72
|
+
# Default to the default
|
|
73
|
+
# Read from stdin unless non_interactive is set to true
|
|
74
|
+
answer = gather_input(default:)
|
|
75
|
+
|
|
76
|
+
return if answer.casecmp('y').zero?
|
|
77
|
+
|
|
78
|
+
puts "\n Cancelled.\n".light_yellow
|
|
79
|
+
exit 1
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Wraps a block of code in a y/n question
|
|
83
|
+
# If the user answers 'y' then the block is executed
|
|
84
|
+
# All other inputs cause the block to be skipped
|
|
85
|
+
def when_confirmed(message, default: nil, colorize: true)
|
|
86
|
+
# If a default is given, it must be y or n
|
|
87
|
+
raise 'invalid default' if default && !%w(y n).include?(default)
|
|
88
|
+
|
|
89
|
+
# print the colorized message (if requested) with the default (if given)
|
|
90
|
+
print(confirmation_message(message, default:, colorize:))
|
|
91
|
+
|
|
92
|
+
# Default to the default
|
|
93
|
+
# Read from stdin unless non_interactive is set to true
|
|
94
|
+
answer = gather_input(default:)
|
|
95
|
+
|
|
96
|
+
# Yield to the block if confirmed
|
|
97
|
+
yield if answer.casecmp('y').zero?
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Receive a string from the user on stdin unless non_interactive is set to true
|
|
101
|
+
# If a default value was specified and no answer was given, return the default
|
|
102
|
+
def gather_input(default: nil)
|
|
103
|
+
answer = $stdin.gets.to_s.strip unless ENV['NON_INTERACTIVE'] == 'true'
|
|
104
|
+
answer.to_s.strip
|
|
105
|
+
return default if default && answer.empty?
|
|
106
|
+
|
|
107
|
+
answer
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Build a confirmation message, colorizing each individual part appropriately
|
|
111
|
+
# Include the default value in the message if one was specified
|
|
112
|
+
def confirmation_message(question, default:, colorize:)
|
|
113
|
+
message = conditional_colorize(question, colorize:, color: :light_green)
|
|
114
|
+
options = conditional_colorize('(', colorize:, color: :light_green)
|
|
115
|
+
options << conditional_colorize('y', colorize:, color: :light_yellow)
|
|
116
|
+
options << conditional_colorize('/', colorize:, color: :light_green)
|
|
117
|
+
options << conditional_colorize('n', colorize:, color: :light_yellow)
|
|
118
|
+
options << conditional_colorize(')', colorize:, color: :light_green)
|
|
119
|
+
|
|
120
|
+
unless default.to_s.strip.empty?
|
|
121
|
+
options << ' '
|
|
122
|
+
options << conditional_colorize('[', colorize:, color: :light_green)
|
|
123
|
+
options << conditional_colorize(default.to_s.strip, colorize:, color: :light_yellow)
|
|
124
|
+
options << conditional_colorize(']', colorize:, color: :light_green)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
options << conditional_colorize(':', colorize:, color: :light_green)
|
|
128
|
+
"#{message} #{options} "
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Colorize the string if it has been requested
|
|
132
|
+
def conditional_colorize(string, colorize:, color:)
|
|
133
|
+
return string.send(color) if colorize
|
|
134
|
+
|
|
135
|
+
string
|
|
61
136
|
end
|
|
62
137
|
|
|
63
138
|
# Asks for user input using the given message and returns it
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require 'aws-sdk-lambda'
|
|
2
|
+
require 'aws-sdk-elasticache'
|
|
3
|
+
require 'aws-sdk-rds'
|
|
4
|
+
require 'aws-sdk-opensearchservice'
|
|
5
|
+
|
|
6
|
+
module Dev
|
|
7
|
+
class EndOfLife
|
|
8
|
+
# Class which queries several different AWS product types and
|
|
9
|
+
# returns ProductVersion entities which can be checked for EOL
|
|
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
|
|
17
|
+
def elasticache_products
|
|
18
|
+
client = ::Aws::ElastiCache::Client.new
|
|
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
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Queries and returns product versions for lambda products
|
|
33
|
+
def lambda_products
|
|
34
|
+
client = ::Aws::Lambda::Client.new
|
|
35
|
+
|
|
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
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Queries and returns product versions for opensearch products
|
|
52
|
+
def opensearch_products
|
|
53
|
+
client = ::Aws::OpenSearchService::Client.new
|
|
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
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Queries and returns product versions for rds products
|
|
68
|
+
def rds_products
|
|
69
|
+
rds_instance_products + rds_cluster_products
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Queries and returns product versions for rds instance products
|
|
73
|
+
def rds_instance_products
|
|
74
|
+
aws_engines = %w(mysql postgresql)
|
|
75
|
+
client = ::Aws::RDS::Client.new
|
|
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
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
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
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
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
|
|
|
@@ -93,6 +93,25 @@ module Dev
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
# rubocop:enable Metrics/MethodLength
|
|
96
|
+
|
|
97
|
+
# Create the rake task for the eol method
|
|
98
|
+
def create_eol_task!
|
|
99
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
|
100
|
+
exclude = @exclude
|
|
101
|
+
|
|
102
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
|
103
|
+
return if exclude.include?(:eol)
|
|
104
|
+
|
|
105
|
+
desc 'Compares the current date to the EOL date for supported resources'
|
|
106
|
+
task eol: %w(init ensure_aws_credentials) do
|
|
107
|
+
account_id = Dev::Aws::Profile.new.current
|
|
108
|
+
account_name = Dev::Aws::Account.new.name_by_account(account_id)
|
|
109
|
+
LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
|
|
110
|
+
|
|
111
|
+
Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).check
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
96
115
|
end
|
|
97
116
|
end
|
|
98
117
|
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.13
|
|
4
|
+
version: 2.1.13
|
|
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-
|
|
11
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -66,6 +66,62 @@ dependencies:
|
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: 1.61.0
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: aws-sdk-elasticache
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 1.88.0
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 1.88.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: aws-sdk-lambda
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 1.101.0
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 1.101.0
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: aws-sdk-opensearchservice
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 1.24.0
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 1.24.0
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: aws-sdk-rds
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 1.183.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 1.183.0
|
|
69
125
|
- !ruby/object:Gem::Dependency
|
|
70
126
|
name: aws-sdk-s3
|
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -280,6 +336,7 @@ files:
|
|
|
280
336
|
- lib/firespring_dev_commands/dotenv.rb
|
|
281
337
|
- lib/firespring_dev_commands/env.rb
|
|
282
338
|
- lib/firespring_dev_commands/eol.rb
|
|
339
|
+
- lib/firespring_dev_commands/eol/aws.rb
|
|
283
340
|
- lib/firespring_dev_commands/eol/product_version.rb
|
|
284
341
|
- lib/firespring_dev_commands/git.rb
|
|
285
342
|
- lib/firespring_dev_commands/git/info.rb
|
|
@@ -342,9 +399,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
342
399
|
version: '3.1'
|
|
343
400
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
401
|
requirements:
|
|
345
|
-
- - "
|
|
402
|
+
- - ">="
|
|
346
403
|
- !ruby/object:Gem::Version
|
|
347
|
-
version:
|
|
404
|
+
version: '0'
|
|
348
405
|
requirements: []
|
|
349
406
|
rubygems_version: 3.4.10
|
|
350
407
|
signing_key:
|