firespring_dev_commands 2.1.31.pre.alpha.3 → 2.1.32.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/firespring_dev_commands/aws/route53.rb +72 -0
- data/lib/firespring_dev_commands/target_process/release.rb +1 -1
- data/lib/firespring_dev_commands/target_process/team_assignment.rb +1 -1
- data/lib/firespring_dev_commands/target_process/user.rb +1 -12
- data/lib/firespring_dev_commands/target_process/user_story.rb +1 -1
- data/lib/firespring_dev_commands/target_process/user_story_history.rb +1 -1
- data/lib/firespring_dev_commands/target_process.rb +6 -21
- data/lib/firespring_dev_commands/templates/aws.rb +51 -0
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +17 -3
- data/lib/firespring_dev_commands/target_process/time.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a50b275c7679e4e84cb4a89fc37b1ab5c99c33ba7c53bef46fa507804e9389
|
4
|
+
data.tar.gz: be434b186af195f448e2f4e4d6506151c489d223aaac71dead335a96f8debfe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec623e8b07e6f6266c8c5d163d0a95070ad8acf1f3239d7f14ded6c4dba38d205aaf1266e1d3959fa8eb5dae054e904abfae3365a4aeda3d17ee6389d48da3c2
|
7
|
+
data.tar.gz: e8572a4144e5fdd0be44fbd01b914c6e78e1b9bd9b8d708dca73fd5bb479d8d068f785c2d6be6526181bd0635d608adf8217378e978854181b09b497081bb277
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Dev::Template::Docker::Node::Application.new('foo')
|
|
28
28
|
```
|
29
29
|
* If you run `rake -T` now, you should have base rake commands and application rake commands for an app called `foo`
|
30
30
|
|
31
|
-
* (
|
31
|
+
* (optional) Add AWS login template commands
|
32
32
|
```
|
33
33
|
# Configure AWS accounts and create tasks
|
34
34
|
Dev::Aws::Account::configure do |c|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'aws-sdk-route53'
|
2
|
+
|
3
|
+
module Dev
|
4
|
+
class Aws
|
5
|
+
# Class for performing Route53 functions
|
6
|
+
class Route53
|
7
|
+
attr_reader :client, :zones
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@client = ::Aws::Route53::Client.new
|
11
|
+
@zones = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_hosted_zones(domains)
|
15
|
+
if domains.empty?
|
16
|
+
response = client.list_hosted_zones
|
17
|
+
response.hosted_zones.each do |hosted_zone|
|
18
|
+
@zones << hosted_zone.id
|
19
|
+
end
|
20
|
+
else
|
21
|
+
domains.each do |domain_name|
|
22
|
+
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
|
25
|
+
end
|
26
|
+
end
|
27
|
+
raise 'Hosted zone(s) not found.' if @zones.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_target_config_id(zone_id)
|
31
|
+
config = client.list_query_logging_configs(
|
32
|
+
hosted_zone_id: zone_id,
|
33
|
+
max_results: '1'
|
34
|
+
)
|
35
|
+
config.query_logging_configs[0].id unless config.query_logging_configs.empty? || config.query_logging_configs[0].hosted_zone_id == zone_id
|
36
|
+
end
|
37
|
+
|
38
|
+
def activate_query_logging(log_group)
|
39
|
+
output = {}
|
40
|
+
|
41
|
+
@zones.each do |zone|
|
42
|
+
response = client.create_query_logging_config(
|
43
|
+
hosted_zone_id: zone,
|
44
|
+
cloud_watch_logs_log_group_arn: log_group
|
45
|
+
)
|
46
|
+
output[zone] = response.location
|
47
|
+
rescue ::Aws::Route53::Errors::ServiceError => e
|
48
|
+
raise "Error: #{e.message}" unless e.instance_of?(::Aws::Route53::Errors::QueryLoggingConfigAlreadyExists)
|
49
|
+
|
50
|
+
output[zone] = e.message
|
51
|
+
end
|
52
|
+
pp output
|
53
|
+
end
|
54
|
+
|
55
|
+
def deactivate_query_logging
|
56
|
+
output = {}
|
57
|
+
@zones.each do |zone|
|
58
|
+
target_config_id = get_target_config_id(zone)
|
59
|
+
if target_config_id
|
60
|
+
client.delete_query_logging_config(
|
61
|
+
id: target_config_id
|
62
|
+
)
|
63
|
+
output[zone] = 'Query logging config removed.'
|
64
|
+
else
|
65
|
+
output[zone] = 'No query logging config assigned.'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
pp output
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -2,13 +2,7 @@ module Dev
|
|
2
2
|
class TargetProcess
|
3
3
|
# Class containing user information
|
4
4
|
class User
|
5
|
-
|
6
|
-
RESOURCE_TYPE = 'User'.freeze
|
7
|
-
|
8
|
-
# The api path for user requests
|
9
|
-
PATH = '/User'.freeze
|
10
|
-
|
11
|
-
attr_accessor :data, :id, :type, :name, :login, :email
|
5
|
+
attr_accessor :data, :id, :type, :name, :login
|
12
6
|
|
13
7
|
def initialize(data)
|
14
8
|
@data = data
|
@@ -16,11 +10,6 @@ module Dev
|
|
16
10
|
@type = data['ResourceType']
|
17
11
|
@name = data['FullName']
|
18
12
|
@login = data['Login']
|
19
|
-
@email = data['Email']
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.get(id)
|
23
|
-
new(TargetProcess.new.get("#{User::PATH}/#{id}", Query.new))
|
24
13
|
end
|
25
14
|
end
|
26
15
|
end
|
@@ -72,8 +72,8 @@ module Dev
|
|
72
72
|
[].tap do |ary|
|
73
73
|
get(Release::PATH, query) do |result|
|
74
74
|
ary << Release.new(result)
|
75
|
-
yield ary.last if block_given?
|
76
75
|
end
|
76
|
+
ary.each(&)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -84,8 +84,8 @@ module Dev
|
|
84
84
|
[].tap do |ary|
|
85
85
|
get(UserStory::PATH, query) do |result|
|
86
86
|
ary << UserStory.new(result)
|
87
|
-
yield ary.last if block_given?
|
88
87
|
end
|
88
|
+
ary.each(&)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -96,8 +96,8 @@ module Dev
|
|
96
96
|
[].tap do |ary|
|
97
97
|
get(UserStoryHistory::PATH, query) do |result|
|
98
98
|
ary << UserStoryHistory.new(result)
|
99
|
-
yield ary.last if block_given?
|
100
99
|
end
|
100
|
+
ary.each(&)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -108,20 +108,8 @@ module Dev
|
|
108
108
|
[].tap do |ary|
|
109
109
|
get(TeamAssignment::PATH, query) do |result|
|
110
110
|
ary << TeamAssignment.new(result)
|
111
|
-
yield ary.last if block_given?
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Perform a query to the time api path
|
117
|
-
# Call the given block (if present) with each time
|
118
|
-
# Return all times
|
119
|
-
def times(query, &)
|
120
|
-
[].tap do |ary|
|
121
|
-
get(Time::PATH, query) do |result|
|
122
|
-
ary << Time.new(result)
|
123
|
-
yield ary.last if block_given?
|
124
111
|
end
|
112
|
+
ary.each(&)
|
125
113
|
end
|
126
114
|
end
|
127
115
|
|
@@ -144,11 +132,8 @@ module Dev
|
|
144
132
|
parsed_response['Items'].each(&)
|
145
133
|
|
146
134
|
while parsed_response['Next']
|
147
|
-
|
148
|
-
|
149
|
-
next_url << "?#{next_query_string}" unless query_string.empty?
|
150
|
-
response = client.request_get(next_url, headers)
|
151
|
-
raise "Error querying #{next_url} [#{next_query_string}]: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
|
135
|
+
response = client.request_get(parsed_response['Next'], headers)
|
136
|
+
raise "Error querying #{parsed_response['Next']} [#{query_string}]: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
|
152
137
|
|
153
138
|
parsed_response = JSON.parse(response.body)
|
154
139
|
return parsed_response unless parsed_response.key?('Items')
|
@@ -120,6 +120,57 @@ module Dev
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
# rubocop:disable Metrics/MethodLength
|
125
|
+
# Create the rake task for the hosted zone method
|
126
|
+
def create_hosted_zone_task!
|
127
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
128
|
+
exclude = @exclude
|
129
|
+
|
130
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
131
|
+
namespace :aws do
|
132
|
+
return if exclude.include?(:hosted_zone)
|
133
|
+
|
134
|
+
namespace :hosted_zone do
|
135
|
+
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
|
+
desc 'Activates query logging for all hosted zones by default.' \
|
148
|
+
'This command should be run from the account the hosted zone(s) reside.' \
|
149
|
+
"\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
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
152
|
+
"\n\t\tComma delimited list."
|
153
|
+
task activate: %w(init) do
|
154
|
+
# Use user defined log group. Otherwise, go get the default.
|
155
|
+
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)
|
158
|
+
end
|
159
|
+
|
160
|
+
desc 'Deactivates query logging for all hosted zones by default. ' \
|
161
|
+
'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
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
164
|
+
"\n\t\tComma delimited list."
|
165
|
+
task deactivate: %w(init) do
|
166
|
+
@route53.deactivate_query_logging
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
# rubocop:enable Metrics/MethodLength
|
123
174
|
end
|
124
175
|
end
|
125
176
|
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.
|
4
|
+
version: 2.1.32.pre.alpha.1
|
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-
|
11
|
+
date: 2024-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.208.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: aws-sdk-route53
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.87.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.87.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: aws-sdk-s3
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -326,6 +340,7 @@ files:
|
|
326
340
|
- lib/firespring_dev_commands/aws/login.rb
|
327
341
|
- lib/firespring_dev_commands/aws/parameter.rb
|
328
342
|
- lib/firespring_dev_commands/aws/profile.rb
|
343
|
+
- lib/firespring_dev_commands/aws/route53.rb
|
329
344
|
- lib/firespring_dev_commands/aws/s3.rb
|
330
345
|
- lib/firespring_dev_commands/bloom_growth.rb
|
331
346
|
- lib/firespring_dev_commands/bloom_growth/rock.rb
|
@@ -380,7 +395,6 @@ files:
|
|
380
395
|
- lib/firespring_dev_commands/target_process/release.rb
|
381
396
|
- lib/firespring_dev_commands/target_process/team.rb
|
382
397
|
- lib/firespring_dev_commands/target_process/team_assignment.rb
|
383
|
-
- lib/firespring_dev_commands/target_process/time.rb
|
384
398
|
- lib/firespring_dev_commands/target_process/user.rb
|
385
399
|
- lib/firespring_dev_commands/target_process/user_story.rb
|
386
400
|
- lib/firespring_dev_commands/target_process/user_story_history.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
class TargetProcess
|
3
|
-
class Time
|
4
|
-
# The resource type for the api endpoint
|
5
|
-
RESOURCE_TYPE = 'Time'.freeze
|
6
|
-
|
7
|
-
# The api path for team assignment requests
|
8
|
-
PATH = '/Time'.freeze
|
9
|
-
|
10
|
-
attr_accessor :data, :id, :type, :description, :hours, :date, :story, :user
|
11
|
-
|
12
|
-
def initialize(data)
|
13
|
-
@data = data
|
14
|
-
@id = data['Id']
|
15
|
-
@type = data['ResourceType']
|
16
|
-
@description = data['Description']
|
17
|
-
@hours = data['Spent']
|
18
|
-
@date = parse_time(data['Date'])
|
19
|
-
@story = UserStory.new(data['Assignable']) if data['Assignable']
|
20
|
-
@user = User.new(data['User']) if data['User']
|
21
|
-
end
|
22
|
-
|
23
|
-
# Parse the dot net time representation into something that ruby can use
|
24
|
-
def parse_time(string)
|
25
|
-
return nil unless string && !string.empty?
|
26
|
-
|
27
|
-
::Time.at(string.slice(6, 10).to_i)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|