firespring_dev_commands 2.1.32.pre.alpha.1 → 2.1.32.pre.alpha.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69a50b275c7679e4e84cb4a89fc37b1ab5c99c33ba7c53bef46fa507804e9389
4
- data.tar.gz: be434b186af195f448e2f4e4d6506151c489d223aaac71dead335a96f8debfe0
3
+ metadata.gz: 41b024ecb06f97d872f8a5b83ca9afb7af3fc92cae13e91674ff72812d920c68
4
+ data.tar.gz: fbbc7b27d086c5734a3041c6a43033e7b654e9486aac0280655fd70da25e75c8
5
5
  SHA512:
6
- metadata.gz: ec623e8b07e6f6266c8c5d163d0a95070ad8acf1f3239d7f14ded6c4dba38d205aaf1266e1d3959fa8eb5dae054e904abfae3365a4aeda3d17ee6389d48da3c2
7
- data.tar.gz: e8572a4144e5fdd0be44fbd01b914c6e78e1b9bd9b8d708dca73fd5bb479d8d068f785c2d6be6526181bd0635d608adf8217378e978854181b09b497081bb277
6
+ metadata.gz: 80e32906a5e5e5aa84fd2c985636327a7068fe7b75c8e94fbbe5a85bb78d0c0d239acef5f0dfa2b95299e201940898e2517b3337f966d059db15949eecaf61bc
7
+ data.tar.gz: 5284e5c970113eff3d78d8c86e3ae8adb6f0d54c5fe0d82a1fff6225f9cdd0a50093af41af315a1b4234d950f0ec47c1d1910562afbca7e5d790246c4e12105d
@@ -8,20 +8,23 @@ module Dev
8
8
 
9
9
  def initialize
10
10
  @client = ::Aws::Route53::Client.new
11
- @zones = []
12
11
  end
13
12
 
14
- def get_hosted_zones(domains)
13
+ def hosted_zones(domains)
14
+ @zones = []
15
15
  if domains.empty?
16
- response = client.list_hosted_zones
17
- response.hosted_zones.each do |hosted_zone|
18
- @zones << hosted_zone.id
16
+ @zones = [].tap do |ary|
17
+ Dev::Aws.each_page(client, :list_hosted_zones, {max_items: 2}) do |response|
18
+ response.hosted_zones.each do |hosted_zone|
19
+ ary << hosted_zone.id unless hosted_zone.config.private_zone
20
+ end
21
+ end
19
22
  end
20
23
  else
21
24
  domains.each do |domain_name|
22
25
  zone = client.list_hosted_zones_by_name({dns_name: domain_name, max_items: 1})
23
- target_name = zone.hosted_zones[0].name.chomp!('.') if zone.hosted_zones[0].name.end_with?('.')
24
- @zones << zone.hosted_zones[0].id unless target_name != domain_name
26
+ target_name = zone.hosted_zones.first.name.chomp!('.')
27
+ @zones << zone.hosted_zones.first.id unless target_name != domain_name
25
28
  end
26
29
  end
27
30
  raise 'Hosted zone(s) not found.' if @zones.empty?
@@ -32,7 +35,7 @@ module Dev
32
35
  hosted_zone_id: zone_id,
33
36
  max_results: '1'
34
37
  )
35
- config.query_logging_configs[0].id unless config.query_logging_configs.empty? || config.query_logging_configs[0].hosted_zone_id == zone_id
38
+ config.query_logging_configs.first.id unless config.query_logging_configs.empty? || config.query_logging_configs.first.hosted_zone_id == zone_id
36
39
  end
37
40
 
38
41
  def activate_query_logging(log_group)
@@ -121,56 +121,60 @@ module Dev
121
121
  end
122
122
  end
123
123
 
124
- # rubocop:disable Metrics/MethodLength
125
124
  # Create the rake task for the hosted zone method
126
- def create_hosted_zone_task!
125
+ def create_dns_logging_activate_task!
127
126
  # Have to set a local variable to be accessible inside of the instance_eval block
128
127
  exclude = @exclude
129
128
 
130
129
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
131
130
  namespace :aws do
132
- return if exclude.include?(:hosted_zone)
131
+ return if exclude.include?(:dns_logging)
133
132
 
134
133
  namespace :hosted_zone do
135
134
  namespace :dns_logging do
136
- task :init do
137
- @route53 = Dev::Aws::Route53.new
138
-
139
- domains = ENV['DOMAINS'].to_s.strip.split(',')
140
- domain = ENV['DOMAIN'].to_s.strip
141
- domains << domain unless domain.empty?
142
-
143
- # Set global zone id array
144
- @route53.get_hosted_zones(domains)
145
- end
146
-
147
135
  desc 'Activates query logging for all hosted zones by default.' \
148
136
  'This command should be run from the account the hosted zone(s) reside.' \
149
137
  "\n\toptionally specify HOSTED_ZONE_GROUP='arn:aws:logs:REGION:ACCOUNT_ID:' to specify the ARN of the target log group." \
150
- "\n\toptionally specify DOMAIN='foo.com' to specify the hosted zone to activate." \
151
138
  "\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
152
139
  "\n\t\tComma delimited list."
153
- task activate: %w(init) do
140
+ task :activate do
141
+ route53 = Dev::Aws::Route53.new
142
+ route53.hosted_zones(ENV['DOMAINS'].to_s.strip.split(','))
154
143
  # Use user defined log group. Otherwise, go get the default.
155
144
  log_group = (ENV['HOSTED_ZONE_GROUP'] || Dev::Aws::Parameter.new.get_value('/Firespring/Internal/Route53/hosted-zone/log-group-arn'))
156
-
157
- @route53.activate_query_logging(log_group)
145
+ route53.activate_query_logging(log_group)
158
146
  end
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
159
152
 
153
+ # Create the rake task for the hosted zone method
154
+ def create_dns_logging_deactivate_task!
155
+ # Have to set a local variable to be accessible inside of the instance_eval block
156
+ exclude = @exclude
157
+
158
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
159
+ namespace :aws do
160
+ return if exclude.include?(:dns_logging_de)
161
+
162
+ namespace :hosted_zone do
163
+ namespace :dns_logging do
160
164
  desc 'Deactivates query logging for all hosted zones by default. ' \
161
165
  'This command should be run from the account the hosted zone(s) reside.' \
162
- "\n\toptionally specify DOMAIN='foo.com' to specify the hosted zone to activate." \
163
166
  "\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
164
167
  "\n\t\tComma delimited list."
165
- task deactivate: %w(init) do
166
- @route53.deactivate_query_logging
168
+ task :deactivate do
169
+ route53 = Dev::Aws::Route53.new
170
+ route53.hosted_zones(ENV['DOMAINS'].to_s.strip.split(','))
171
+ route53.deactivate_query_logging
167
172
  end
168
173
  end
169
174
  end
170
175
  end
171
176
  end
172
177
  end
173
- # rubocop:enable Metrics/MethodLength
174
178
  end
175
179
  end
176
180
  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.32.pre.alpha.1'.freeze
9
+ VERSION = '2.1.32.pre.alpha.2'.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.32.pre.alpha.1
4
+ version: 2.1.32.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport