firespring_dev_commands 3.1.4.pre.alpha.2 → 3.1.4
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/route53.rb +77 -45
- data/lib/firespring_dev_commands/dns/resource.rb +83 -0
- data/lib/firespring_dev_commands/docker/desktop.rb +7 -5
- data/lib/firespring_dev_commands/git.rb +18 -1
- data/lib/firespring_dev_commands/templates/aws/services/route53.rb +16 -11
- data/lib/firespring_dev_commands/templates/git.rb +148 -0
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 179df75f7b62c175947f2cf19da1d3cd99711dc1e5e430567810e57afdc41c61
|
4
|
+
data.tar.gz: f1d69c062cdc5df63aa9b4786ffc2f706ed9acb0450adf9fc1221a9f4426d0f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6defd1186a7d99b941b8cdb89d9fce77d828694c66aaee7eb24df27aabed58aded31a2bf0b72b0e95057c5e0053a0a6d7e93e279ba5509f03a8f9598c7f1a354
|
7
|
+
data.tar.gz: '09268007596b27dbda45ee0afe4eb8d93330078d1d03f39bfa38856ef0f9175a59f025c4b6f1dc420e3d0838abaf5d2727d9b7511e1bac88cc9b8cdf4c2ebd42'
|
@@ -1,44 +1,59 @@
|
|
1
|
+
require 'aws-sdk-route53'
|
2
|
+
|
1
3
|
module Dev
|
2
4
|
class Aws
|
3
5
|
# Class for performing Route53 functions
|
4
6
|
class Route53
|
5
7
|
attr_reader :client
|
6
8
|
|
7
|
-
def initialize(domains)
|
9
|
+
def initialize(domains = nil)
|
8
10
|
@client = ::Aws::Route53::Client.new
|
9
|
-
@domains = domains
|
11
|
+
@domains = Array(domains || [])
|
10
12
|
end
|
11
13
|
|
12
|
-
|
14
|
+
def zones(&)
|
13
15
|
if @domains.empty?
|
14
|
-
|
16
|
+
each_zone(&)
|
15
17
|
else
|
16
|
-
|
18
|
+
each_zone_by_domains(&)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
private def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
private def each_zone
|
23
|
+
Dev::Aws.each_page(client, :list_hosted_zones) do |response|
|
24
|
+
response.hosted_zones&.each do |hosted_zone|
|
25
|
+
next if hosted_zone.config.private_zone
|
26
|
+
|
27
|
+
yield hosted_zone
|
26
28
|
end
|
29
|
+
rescue ::Aws::Route53::Errors::Throttling
|
30
|
+
sleep(1)
|
31
|
+
retry
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
|
-
private def
|
31
|
-
|
32
|
-
|
33
|
-
response = client.list_hosted_zones_by_name({dns_name: domain_name})
|
34
|
-
target = response.hosted_zones.find { |it| it.name.chomp('.') == domain_name }
|
35
|
-
raise "The #{domain_name} hosted zone not found." unless target
|
35
|
+
private def each_zone_by_domains(&)
|
36
|
+
@domains.each do |domain|
|
37
|
+
response = client.list_hosted_zones_by_name({dns_name: domain})
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
# The 'list_hosted_zones_by_name' returns fuzzy matches (so "foo.com" would return both "bar.foo.com" and "foo.com"
|
40
|
+
# So we are only selecting domains that match exactly since that's what we really want here
|
41
|
+
targets = response.hosted_zones.select { |it| it.name.chomp('.') == domain }
|
42
|
+
raise "The #{domain} hosted zone not found." if targets.empty?
|
43
|
+
|
44
|
+
targets.each(&)
|
45
|
+
rescue ::Aws::Route53::Errors::Throttling
|
46
|
+
sleep(1)
|
47
|
+
retry
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
51
|
+
private def ip_address(domain)
|
52
|
+
Addrinfo.ip(domain.to_s.strip)&.ip_address
|
53
|
+
rescue SocketError
|
54
|
+
"Unable to resolve domain: #{domain}"
|
55
|
+
end
|
56
|
+
|
42
57
|
private def target_config_id(zone_id)
|
43
58
|
client.list_query_logging_configs(
|
44
59
|
hosted_zone_id: zone_id,
|
@@ -46,61 +61,78 @@ module Dev
|
|
46
61
|
).query_logging_configs&.first&.id
|
47
62
|
end
|
48
63
|
|
49
|
-
|
50
|
-
|
51
|
-
|
64
|
+
# Get the hosted zone details for the zone id
|
65
|
+
private def details(zone_id)
|
66
|
+
response = client.get_hosted_zone(id: zone_id)
|
67
|
+
[response.hosted_zone, response.delegation_set]
|
68
|
+
end
|
69
|
+
|
70
|
+
def list_zone_details
|
71
|
+
zones do |zone|
|
72
|
+
puts
|
73
|
+
zone_details, delegation_set = details(zone.id)
|
74
|
+
dns_resource = Dev::Dns::Resource.new(zone_details.name)
|
52
75
|
|
53
|
-
|
54
|
-
puts
|
76
|
+
puts "#{zone_details.name.chomp('.').light_white} (#{zone_details.id}):"
|
77
|
+
puts format(' %-50s %s', 'Delegation Set:', delegation_set.id)
|
78
|
+
puts format(' %-50s %s', 'Delegation Defined Nameservers:', delegation_set.name_servers.sort.join(', '))
|
79
|
+
puts format(' %-50s %s', 'DNS Reported Nameservers:', dns_resource.recursive_nameserver_lookup.sort.join(', '))
|
80
|
+
puts format(' %-50s %s', 'DNS Reported Nameserver IPs:', dns_resource.recursive_nameserver_lookup.sort.map { |it| dns_resource.recursive_a_lookup(it) }.join(', '))
|
81
|
+
puts format(' %-50s %s', 'Domain Apex IP Resolution:', dns_resource.recursive_a_lookup.sort.join(', '))
|
82
|
+
rescue ::Aws::Route53::Errors::Throttling
|
83
|
+
sleep(1)
|
84
|
+
retry
|
55
85
|
end
|
86
|
+
puts
|
56
87
|
end
|
57
88
|
|
58
89
|
def list_query_configs
|
59
|
-
|
60
|
-
zones.each do |zone|
|
90
|
+
zones do |zone|
|
61
91
|
target_config_id = target_config_id(zone.id)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
92
|
+
message = if target_config_id
|
93
|
+
"Config\t=>\t#{target_config_id}".colorize(:green)
|
94
|
+
else
|
95
|
+
'No query logging config assigned.'.colorize(:red)
|
96
|
+
end
|
97
|
+
puts format('%-50s => %s', zone.name, message)
|
98
|
+
rescue ::Aws::Route53::Errors::Throttling
|
99
|
+
sleep(1)
|
100
|
+
retry
|
68
101
|
end
|
69
|
-
|
70
|
-
pretty_puts(output)
|
71
102
|
end
|
72
103
|
|
73
104
|
def activate_query_logging(log_group)
|
74
|
-
|
75
|
-
|
76
|
-
zones.each do |zone|
|
105
|
+
zones do |zone|
|
77
106
|
response = client.create_query_logging_config(
|
78
107
|
hosted_zone_id: zone.id,
|
79
108
|
cloud_watch_logs_log_group_arn: log_group
|
80
109
|
)
|
81
|
-
|
110
|
+
puts format('%-50s => %s', zone.id, response.location)
|
111
|
+
rescue ::Aws::Route53::Errors::Throttling
|
112
|
+
sleep(1)
|
113
|
+
retry
|
82
114
|
rescue ::Aws::Route53::Errors::ServiceError => e
|
83
115
|
raise "Error: #{e.message}" unless e.instance_of?(::Aws::Route53::Errors::QueryLoggingConfigAlreadyExists)
|
84
116
|
|
85
|
-
|
117
|
+
puts format('%-50s => %s', zone.id, e.message)
|
86
118
|
end
|
87
|
-
pretty_puts(output)
|
88
119
|
end
|
89
120
|
|
90
121
|
def deactivate_query_logging
|
91
|
-
|
92
|
-
zones.each do |zone|
|
122
|
+
zones do |zone|
|
93
123
|
target_config_id = target_config_id(zone.id)
|
94
124
|
if target_config_id
|
95
125
|
client.delete_query_logging_config(
|
96
126
|
id: target_config_id
|
97
127
|
)
|
98
|
-
|
128
|
+
puts format('%-50s => %s', zone.id, 'Query logging config removed.'.colorize(:green))
|
99
129
|
else
|
100
|
-
|
130
|
+
puts format('%-50s => %s', zone.id, 'No query logging config assigned.'.colorize(:red))
|
101
131
|
end
|
132
|
+
rescue ::Aws::Route53::Errors::Throttling
|
133
|
+
sleep(1)
|
134
|
+
retry
|
102
135
|
end
|
103
|
-
pretty_puts(output)
|
104
136
|
end
|
105
137
|
end
|
106
138
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Dev
|
2
|
+
class Dns
|
3
|
+
class Resource
|
4
|
+
attr_reader :domain
|
5
|
+
|
6
|
+
def initialize(domain)
|
7
|
+
@domain = domain
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns whether or not the given value is a valid IPv4 or IPv6 address
|
11
|
+
def self.ip?(value)
|
12
|
+
ipv4?(value) || ipv6?(value)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns whether or not the given value is a valid IPv4 address
|
16
|
+
def self.ipv4?(value)
|
17
|
+
value.match?(Resolv::IPv4::Regex)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns whether or not the given value is a valid IPv6 address
|
21
|
+
def self.ipv6?(value)
|
22
|
+
value.match?(Resolv::IPv6::Regex)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Recursively determine the correct nameservers for the given domain.
|
26
|
+
# If nameservers are not found, strip subdomains off until we've reached the TLD
|
27
|
+
def recursive_nameserver_lookup(name = domain)
|
28
|
+
records = lookup(name, type: Resolv::DNS::Resource::IN::NS)
|
29
|
+
|
30
|
+
# Strip the subdomain and try again if we didn't find any nameservers (this can happen with wildcards)
|
31
|
+
return recursive_nameserver_lookup(name.split('.', 2).last) if records.empty?
|
32
|
+
|
33
|
+
# Look up the IPs for the nameservers
|
34
|
+
records
|
35
|
+
end
|
36
|
+
|
37
|
+
# Recursively attempt to find an A record for the given domain.
|
38
|
+
# If one isn't found, also check for CNAMEs continually until we have either found an IP or run out of things to check
|
39
|
+
def recursive_a_lookup(name = domain)
|
40
|
+
# Try looking up an A record first. If we find one, we are done.
|
41
|
+
records = lookup(name, type: Resolv::DNS::Resource::IN::A)
|
42
|
+
return records unless records.empty?
|
43
|
+
|
44
|
+
# Try looking up a CNAME record
|
45
|
+
records = lookup(name, type: Resolv::DNS::Resource::IN::CNAME)
|
46
|
+
|
47
|
+
# If we didn't find an A record _or_ a CNAME, just return empty
|
48
|
+
return records if records.empty?
|
49
|
+
|
50
|
+
# If we found more than one CNAME that is a DNS error
|
51
|
+
raise "Found more than one CNAME entry for #{name}. This is not allowed by DNS" if records.length > 1
|
52
|
+
|
53
|
+
recursive_a_lookup(records.first)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Lookup the given name using the record type provided.
|
57
|
+
def lookup(name = domain, type: Resolv::DNS::Resource::IN::A)
|
58
|
+
# Validate the type
|
59
|
+
raise 'lookup type must be a Resolv::DNS::Resource' unless type.ancestors.include?(Resolv::DNS::Resource)
|
60
|
+
|
61
|
+
# If we were given a tld, return empty
|
62
|
+
return [] unless name.include?('.')
|
63
|
+
|
64
|
+
# Look up NS records for the given host
|
65
|
+
records = Resolv::DNS.new.getresources(name, type)
|
66
|
+
|
67
|
+
# Return the record names
|
68
|
+
records.map do |record|
|
69
|
+
if record.respond_to?(:address)
|
70
|
+
record.address.to_s
|
71
|
+
elsif record.respond_to?(:name)
|
72
|
+
record.name.to_s
|
73
|
+
else
|
74
|
+
''
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue
|
78
|
+
sleep(1)
|
79
|
+
retry
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -46,12 +46,14 @@ services:
|
|
46
46
|
::Docker.url = 'tcp://127.0.0.1:23750'
|
47
47
|
|
48
48
|
else
|
49
|
+
context = Dev::Common.new.run_command(
|
50
|
+
"docker context inspect --format '{{.Endpoints.docker.Host}}'",
|
51
|
+
capture: true
|
52
|
+
).to_s.strip
|
53
|
+
raise 'context is empty' unless context
|
54
|
+
|
49
55
|
# If a user based socket has been defined, default to that
|
50
|
-
::Docker.url =
|
51
|
-
"unix://#{Dir.home}/.docker/run/docker.sock"
|
52
|
-
elsif File.exist?("/#{Dir.home}/.docker/desktop/docker.sock")
|
53
|
-
"unix://#{Dir.home}/.docker/desktop/docker.sock"
|
54
|
-
end
|
56
|
+
::Docker.url = context
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'git'
|
3
|
+
require 'octokit'
|
3
4
|
|
4
5
|
module Dev
|
5
6
|
# Class for performing git functions
|
@@ -408,7 +409,10 @@ module Dev
|
|
408
409
|
# Clones the repo_name into the dir
|
409
410
|
# Optionally specify a repo_org
|
410
411
|
# Optionally specify a branch to check out (defaults to the repository default branch)
|
411
|
-
def clone_repo(dir:, repo_name:, repo_org:
|
412
|
+
def clone_repo(dir:, repo_name:, repo_org: nil, branch: nil, depth: nil)
|
413
|
+
# TODO: Split out the default of 'firespring' into a configuration variable
|
414
|
+
repo_org = 'firespring' if repo_org.to_s.strip.empty?
|
415
|
+
|
412
416
|
if Dir.exist?("#{dir}/.git")
|
413
417
|
puts "#{dir} already cloned".light_green
|
414
418
|
return
|
@@ -425,6 +429,19 @@ module Dev
|
|
425
429
|
g.fetch('origin', prune: true)
|
426
430
|
end
|
427
431
|
|
432
|
+
def commit_status(token:, repo_name:, commit_id:, status:, repo_org: nil, options: {})
|
433
|
+
# TODO: Split out the default of 'firespring' into a configuration variable
|
434
|
+
repo_org = 'firespring' if repo_org.to_s.strip.empty?
|
435
|
+
repo = "#{repo_org}/#{repo_name}"
|
436
|
+
|
437
|
+
# Set up the GitHub client
|
438
|
+
client = Octokit::Client.new(access_token: token)
|
439
|
+
|
440
|
+
# Create the commit status
|
441
|
+
puts "Tagging commit #{commit_id} in #{repo} as #{status} for #{options[:context]}"
|
442
|
+
client.create_status(repo, commit_id, status, options)
|
443
|
+
end
|
444
|
+
|
428
445
|
# Builds an ssh repo URL using the org and repo name given
|
429
446
|
def ssh_repo_url(name, org)
|
430
447
|
"git@github.com:#{org}/#{name}.git"
|
@@ -6,16 +6,21 @@ module Dev
|
|
6
6
|
module Services
|
7
7
|
# Class contains rake templates for managing your AWS settings and logging in
|
8
8
|
class Route53 < Dev::Template::BaseInterface
|
9
|
-
|
10
|
-
def create_ensure_credentials_task!
|
9
|
+
def create_list_zone_details_task!
|
11
10
|
# Have to set a local variable to be accessible inside of the instance_eval block
|
12
11
|
exclude = @exclude
|
13
12
|
|
14
13
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
15
|
-
return if exclude.include?(:
|
14
|
+
return if exclude.include?(:list_details)
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
namespace :aws do
|
17
|
+
namespace :hosted_zone do
|
18
|
+
desc 'print details for all hosted zones'
|
19
|
+
task list_details: %w(ensure_aws_credentials) do
|
20
|
+
route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
|
21
|
+
route53.list_zone_details
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -26,9 +31,9 @@ module Dev
|
|
26
31
|
exclude = @exclude
|
27
32
|
|
28
33
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
29
|
-
|
30
|
-
return if exclude.include?(:dns_logging)
|
34
|
+
return if exclude.include?(:dns_logging_activate)
|
31
35
|
|
36
|
+
namespace :aws do
|
32
37
|
namespace :hosted_zone do
|
33
38
|
namespace :dns_logging do
|
34
39
|
desc 'Activates query logging for all hosted zones by default.' \
|
@@ -56,9 +61,9 @@ module Dev
|
|
56
61
|
exclude = @exclude
|
57
62
|
|
58
63
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
59
|
-
|
60
|
-
return if exclude.include?(:dns_logging)
|
64
|
+
return if exclude.include?(:dns_logging_deactivate)
|
61
65
|
|
66
|
+
namespace :aws do
|
62
67
|
namespace :hosted_zone do
|
63
68
|
namespace :dns_logging do
|
64
69
|
desc 'Deactivates query logging for all hosted zones by default. ' \
|
@@ -81,9 +86,9 @@ module Dev
|
|
81
86
|
exclude = @exclude
|
82
87
|
|
83
88
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
84
|
-
|
85
|
-
return if exclude.include?(:dns_logging)
|
89
|
+
return if exclude.include?(:dns_logging_config)
|
86
90
|
|
91
|
+
namespace :aws do
|
87
92
|
namespace :hosted_zone do
|
88
93
|
namespace :dns_logging do
|
89
94
|
desc 'Lists the current config for domain(s). ' \
|
@@ -159,6 +159,154 @@ module Dev
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
# Create the rake task for the git commit status pending task.
|
164
|
+
def create_commit_status_pending_task!
|
165
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
166
|
+
exclude = @exclude
|
167
|
+
|
168
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
169
|
+
namespace :git do
|
170
|
+
return if exclude.include?(:commit_status)
|
171
|
+
|
172
|
+
namespace :commit_status do
|
173
|
+
desc 'Add pending status to commit' \
|
174
|
+
"\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
|
175
|
+
"\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
|
176
|
+
"\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
|
177
|
+
"\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
|
178
|
+
"\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
|
179
|
+
task :pending do
|
180
|
+
status = 'pending'
|
181
|
+
token = ENV['GITHUB_TOKEN'].to_s.strip
|
182
|
+
repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
|
183
|
+
commit_id = ENV['COMMIT_ID'].to_s.strip
|
184
|
+
|
185
|
+
raise 'GITHUB_TOKEN is required' unless token
|
186
|
+
raise 'REPOSITORY is required' unless repo_name
|
187
|
+
raise 'COMMIT_ID is required' unless commit_id
|
188
|
+
|
189
|
+
options = {}
|
190
|
+
options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
|
191
|
+
options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
|
192
|
+
|
193
|
+
Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Create the rake task for the git commit status success task.
|
201
|
+
def create_commit_status_success_task!
|
202
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
203
|
+
exclude = @exclude
|
204
|
+
|
205
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
206
|
+
namespace :git do
|
207
|
+
return if exclude.include?(:commit_status)
|
208
|
+
|
209
|
+
namespace :commit_status do
|
210
|
+
desc 'Add success status to commit' \
|
211
|
+
"\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
|
212
|
+
"\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
|
213
|
+
"\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
|
214
|
+
"\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
|
215
|
+
"\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
|
216
|
+
task :success do
|
217
|
+
status = 'success'
|
218
|
+
token = ENV['GITHUB_TOKEN'].to_s.strip
|
219
|
+
repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
|
220
|
+
commit_id = ENV['COMMIT_ID'].to_s.strip
|
221
|
+
|
222
|
+
raise 'GITHUB_TOKEN is required' unless token
|
223
|
+
raise 'REPOSITORY is required' unless repo_name
|
224
|
+
raise 'COMMIT_ID is required' unless commit_id
|
225
|
+
|
226
|
+
options = {}
|
227
|
+
options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
|
228
|
+
options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
|
229
|
+
|
230
|
+
Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Create the rake task for the git commit status error task.
|
238
|
+
def create_commit_status_error_task!
|
239
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
240
|
+
exclude = @exclude
|
241
|
+
|
242
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
243
|
+
namespace :git do
|
244
|
+
return if exclude.include?(:commit_status)
|
245
|
+
|
246
|
+
namespace :commit_status do
|
247
|
+
desc 'Add error status to commit' \
|
248
|
+
"\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
|
249
|
+
"\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
|
250
|
+
"\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
|
251
|
+
"\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
|
252
|
+
"\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
|
253
|
+
task :error do
|
254
|
+
status = 'error'
|
255
|
+
token = ENV['GITHUB_TOKEN'].to_s.strip
|
256
|
+
repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
|
257
|
+
commit_id = ENV['COMMIT_ID'].to_s.strip
|
258
|
+
|
259
|
+
raise 'GITHUB_TOKEN is required' unless token
|
260
|
+
raise 'REPOSITORY is required' unless repo_name
|
261
|
+
raise 'COMMIT_ID is required' unless commit_id
|
262
|
+
|
263
|
+
options = {}
|
264
|
+
options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
|
265
|
+
options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
|
266
|
+
|
267
|
+
Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# Create the rake task for the git commit status failure task.
|
275
|
+
def create_commit_status_failure_task!
|
276
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
277
|
+
exclude = @exclude
|
278
|
+
|
279
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
280
|
+
namespace :git do
|
281
|
+
return if exclude.include?(:commit_status)
|
282
|
+
|
283
|
+
namespace :commit_status do
|
284
|
+
desc 'Add failure status to commit' \
|
285
|
+
"\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
|
286
|
+
"\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
|
287
|
+
"\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
|
288
|
+
"\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
|
289
|
+
"\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
|
290
|
+
task :failure do
|
291
|
+
status = 'failure'
|
292
|
+
token = ENV['GITHUB_TOKEN'].to_s.strip
|
293
|
+
repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
|
294
|
+
commit_id = ENV['COMMIT_ID'].to_s.strip
|
295
|
+
|
296
|
+
raise 'GITHUB_TOKEN is required' unless token
|
297
|
+
raise 'REPOSITORY is required' unless repo_name
|
298
|
+
raise 'COMMIT_ID is required' unless commit_id
|
299
|
+
|
300
|
+
options = {}
|
301
|
+
options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
|
302
|
+
options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
|
303
|
+
|
304
|
+
Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
162
310
|
end
|
163
311
|
end
|
164
312
|
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: 3.1.4
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - '='
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: 0.110.0
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: faraday-retry
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '2.0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '2.0'
|
237
251
|
- !ruby/object:Gem::Dependency
|
238
252
|
name: git
|
239
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,6 +290,20 @@ dependencies:
|
|
276
290
|
- - "~>"
|
277
291
|
- !ruby/object:Gem::Version
|
278
292
|
version: 2.3.0
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: octokit
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - "~>"
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: '8.1'
|
300
|
+
type: :runtime
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - "~>"
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '8.1'
|
279
307
|
- !ruby/object:Gem::Dependency
|
280
308
|
name: ox
|
281
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -367,6 +395,7 @@ files:
|
|
367
395
|
- lib/firespring_dev_commands/coverage/cobertura.rb
|
368
396
|
- lib/firespring_dev_commands/coverage/none.rb
|
369
397
|
- lib/firespring_dev_commands/daterange.rb
|
398
|
+
- lib/firespring_dev_commands/dns/resource.rb
|
370
399
|
- lib/firespring_dev_commands/docker.rb
|
371
400
|
- lib/firespring_dev_commands/docker/artifact.rb
|
372
401
|
- lib/firespring_dev_commands/docker/compose.rb
|
@@ -447,9 +476,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
447
476
|
version: '3.1'
|
448
477
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
449
478
|
requirements:
|
450
|
-
- - "
|
479
|
+
- - ">="
|
451
480
|
- !ruby/object:Gem::Version
|
452
|
-
version:
|
481
|
+
version: '0'
|
453
482
|
requirements: []
|
454
483
|
rubygems_version: 3.4.10
|
455
484
|
signing_key:
|