jets 3.0.13 → 3.0.17
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/CHANGELOG.md +17 -0
- data/lib/jets/aws_services.rb +38 -10
- data/lib/jets/commands/clean/log.rb +0 -13
- data/lib/jets/commands/delete.rb +1 -21
- data/lib/jets/commands/deploy.rb +0 -37
- data/lib/jets/commands/new.rb +8 -1
- data/lib/jets/controller/middleware/local/route_matcher.rb +3 -3
- data/lib/jets/controller/middleware/local.rb +1 -0
- data/lib/jets/controller/redirection.rb +1 -10
- data/lib/jets/controller/rendering.rb +17 -4
- data/lib/jets/generator/templates/rails/scaffold_controller/controller.rb +1 -1
- data/lib/jets/internal/app/functions/jets/base_path_mapping.rb +19 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/base.rb +5 -20
- data/lib/jets/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a03ac914d64e082dd8973795f04e9e4ebd3878b0eb04663e97ef368eecc19eb3
|
4
|
+
data.tar.gz: 56fe08319ec68002c7990d140dd26e90cdd7ff13b503702bf94dcddb60e12e4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bdcb8d9549179d4adf082abaa0b7353b758b4168019dc43a5208e427186462875bc2e843378461747b756f976d2b62ee175714a7081455ddacb532b4f1b6e2f
|
7
|
+
data.tar.gz: 5d79ca553952a1413abf1ac4a143f6b905bf1067662c4642e598932ff5ee15b135334d57fbb3530171e63f8322c9e46dc60e6349c1d2e3c06b1416ce386a2821
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,23 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [3.0.17] - 2021-09-15
|
7
|
+
- [#593](https://github.com/boltops-tools/jets/pull/593) Fix deploy for new projects. Added rescue block back into lib/jets/commands/deploy.rb
|
8
|
+
|
9
|
+
## [3.0.16] - 2021-09-10
|
10
|
+
- [#590](https://github.com/boltops-tools/jets/pull/590) Improve Rate Limit Handling
|
11
|
+
|
12
|
+
## [3.0.15] - 2021-09-05
|
13
|
+
- [#587](https://github.com/boltops-tools/jets/pull/587) Fix private method names
|
14
|
+
- [#588](https://github.com/boltops-tools/jets/pull/588) custom domain: adjust rate limit for base mapping
|
15
|
+
- [#589](https://github.com/boltops-tools/jets/pull/589) Ujs
|
16
|
+
|
17
|
+
## [3.0.14] - 2021-09-01
|
18
|
+
- [#583](https://github.com/boltops-tools/jets/pull/583) Don't overwrite content_type when rendering json or xml with content_type specified
|
19
|
+
- [#584](https://github.com/boltops-tools/jets/pull/584) Adds an override flag to change behaviour when Jets is behind an ELB running Jets Server
|
20
|
+
- [#585](https://github.com/boltops-tools/jets/pull/585) add_stage controller method
|
21
|
+
- [#586](https://github.com/boltops-tools/jets/pull/586) JETS_ELB env var flag
|
22
|
+
|
6
23
|
## [3.0.13] - 2021-08-17
|
7
24
|
- [#582](https://github.com/boltops-tools/jets/pull/582) use Shotgun::Static middleware always
|
8
25
|
|
data/lib/jets/aws_services.rb
CHANGED
@@ -16,52 +16,80 @@ module Jets::AwsServices
|
|
16
16
|
include StackStatus
|
17
17
|
|
18
18
|
def apigateway
|
19
|
-
Aws::APIGateway::Client.new
|
19
|
+
Aws::APIGateway::Client.new(aws_options)
|
20
20
|
end
|
21
21
|
global_memoize :apigateway
|
22
22
|
|
23
23
|
def cfn
|
24
|
-
Aws::CloudFormation::Client.new
|
24
|
+
Aws::CloudFormation::Client.new(aws_options)
|
25
25
|
end
|
26
26
|
global_memoize :cfn
|
27
27
|
|
28
28
|
def dynamodb
|
29
|
-
Aws::DynamoDB::Client.new
|
29
|
+
Aws::DynamoDB::Client.new(aws_options)
|
30
30
|
end
|
31
31
|
global_memoize :dynamodb
|
32
32
|
|
33
33
|
def aws_lambda
|
34
|
-
Aws::Lambda::Client.new
|
34
|
+
Aws::Lambda::Client.new(aws_options)
|
35
35
|
end
|
36
36
|
global_memoize :aws_lambda
|
37
37
|
|
38
38
|
def logs
|
39
|
-
Aws::CloudWatchLogs::Client.new
|
39
|
+
Aws::CloudWatchLogs::Client.new(aws_options)
|
40
40
|
end
|
41
41
|
global_memoize :logs
|
42
42
|
|
43
43
|
def s3
|
44
|
-
Aws::S3::Client.new
|
44
|
+
Aws::S3::Client.new(aws_options)
|
45
45
|
end
|
46
46
|
global_memoize :s3
|
47
47
|
|
48
48
|
def s3_resource
|
49
|
-
Aws::S3::Resource.new
|
49
|
+
Aws::S3::Resource.new(aws_options)
|
50
50
|
end
|
51
51
|
global_memoize :s3_resource
|
52
52
|
|
53
53
|
def sns
|
54
|
-
Aws::SNS::Client.new
|
54
|
+
Aws::SNS::Client.new(aws_options)
|
55
55
|
end
|
56
56
|
global_memoize :sns
|
57
57
|
|
58
58
|
def sqs
|
59
|
-
Aws::SQS::Client.new
|
59
|
+
Aws::SQS::Client.new(aws_options)
|
60
60
|
end
|
61
61
|
global_memoize :sqs
|
62
62
|
|
63
63
|
def sts
|
64
|
-
Aws::STS::Client.new
|
64
|
+
Aws::STS::Client.new(aws_options)
|
65
65
|
end
|
66
66
|
global_memoize :sts
|
67
|
+
|
68
|
+
# Override the AWS retry settings with Jets AWS clients.
|
69
|
+
#
|
70
|
+
# The aws-sdk-core has exponential backup with this formula:
|
71
|
+
#
|
72
|
+
# 2 ** c.retries * c.config.retry_base_delay
|
73
|
+
#
|
74
|
+
# So the max delay will be 2 ** 7 * 0.6 = 76.8s
|
75
|
+
#
|
76
|
+
# Only scoping this to deploy because dont want to affect people's application that use the aws sdk.
|
77
|
+
#
|
78
|
+
# There is also additional rate backoff logic elsewhere, since this is only scoped to deploys.
|
79
|
+
#
|
80
|
+
# Useful links:
|
81
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
|
82
|
+
# https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
|
83
|
+
#
|
84
|
+
def aws_options
|
85
|
+
options = {
|
86
|
+
retry_limit: 7, # default: 3
|
87
|
+
retry_base_delay: 0.6, # default: 0.3
|
88
|
+
}
|
89
|
+
options.merge!(
|
90
|
+
log_level: :debug,
|
91
|
+
logger: Logger.new($stdout),
|
92
|
+
) if ENV['JETS_DEBUG_AWS_SDK']
|
93
|
+
options
|
94
|
+
end
|
67
95
|
end
|
@@ -26,20 +26,7 @@ class Jets::Commands::Clean
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def delete_log_group(log_group_name)
|
29
|
-
retries = 0
|
30
29
|
logs.delete_log_group(log_group_name: log_group_name)
|
31
|
-
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
|
32
|
-
retries += 1
|
33
|
-
seconds = 2 ** retries
|
34
|
-
|
35
|
-
puts "WARN: delete_log_group #{e.class} #{e.message}".color(:yellow)
|
36
|
-
puts "Backing off and will retry in #{seconds} seconds."
|
37
|
-
sleep(seconds)
|
38
|
-
if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
|
39
|
-
puts "Giving up after #{retries} retries"
|
40
|
-
else
|
41
|
-
retry
|
42
|
-
end
|
43
30
|
end
|
44
31
|
|
45
32
|
def clean_deploys
|
data/lib/jets/commands/delete.rb
CHANGED
@@ -44,27 +44,7 @@ class Jets::Commands::Delete
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def confirm_project_exists
|
47
|
-
|
48
|
-
begin
|
49
|
-
cfn.describe_stacks(stack_name: parent_stack_name)
|
50
|
-
rescue Aws::CloudFormation::Errors::ValidationError
|
51
|
-
# Aws::CloudFormation::Errors::ValidationError is thrown when the stack
|
52
|
-
# does not exist
|
53
|
-
puts "The parent stack #{Jets.config.project_namespace.color(:green)} for the project #{Jets.config.project_name.color(:green)} does not exist. So it cannot be deleted."
|
54
|
-
exit 0
|
55
|
-
rescue Aws::CloudFormation::Errors::Throttling => e
|
56
|
-
retries += 1
|
57
|
-
seconds = 2 ** retries
|
58
|
-
|
59
|
-
puts "WARN: confirm_project_exists #{e.class} #{e.message}".color(:yellow)
|
60
|
-
puts "Backing off and will retry in #{seconds} seconds."
|
61
|
-
sleep(seconds)
|
62
|
-
if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
|
63
|
-
puts "Giving up after #{retries} retries"
|
64
|
-
else
|
65
|
-
retry
|
66
|
-
end
|
67
|
-
end
|
47
|
+
cfn.describe_stacks(stack_name: parent_stack_name)
|
68
48
|
end
|
69
49
|
|
70
50
|
def empty_s3_bucket
|
data/lib/jets/commands/deploy.rb
CHANGED
@@ -9,7 +9,6 @@ module Jets::Commands
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
aws_config_update!
|
13
12
|
deployment_env = Jets.config.project_namespace.color(:green)
|
14
13
|
puts "Deploying to Lambda #{deployment_env} environment..."
|
15
14
|
return if @options[:noop]
|
@@ -37,29 +36,6 @@ module Jets::Commands
|
|
37
36
|
ship(stack_type: :full, s3_bucket: s3_bucket)
|
38
37
|
end
|
39
38
|
|
40
|
-
# Override the AWS retry settings during a deploy.
|
41
|
-
#
|
42
|
-
# The aws-sdk-core has expondential backup with this formula:
|
43
|
-
#
|
44
|
-
# 2 ** c.retries * c.config.retry_base_delay
|
45
|
-
#
|
46
|
-
# So the max delay will be 2 ** 7 * 0.6 = 76.8s
|
47
|
-
#
|
48
|
-
# Only scoping this to deploy because dont want to affect people's application that use the aws sdk.
|
49
|
-
#
|
50
|
-
# There is also additional rate backoff logic elsewhere, since this is only scoped to deploys.
|
51
|
-
#
|
52
|
-
# Useful links:
|
53
|
-
# https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
|
54
|
-
# https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
|
55
|
-
#
|
56
|
-
def aws_config_update!
|
57
|
-
Aws.config.update(
|
58
|
-
retry_limit: 7, # default: 3
|
59
|
-
retry_base_delay: 0.6, # default: 0.3
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
39
|
def create_s3_event_buckets
|
64
40
|
buckets = Jets::Job::Base.s3_events.keys
|
65
41
|
buckets.each do |bucket|
|
@@ -126,7 +102,6 @@ module Jets::Commands
|
|
126
102
|
end
|
127
103
|
|
128
104
|
def find_stack(stack_name)
|
129
|
-
retries = 0
|
130
105
|
resp = cfn.describe_stacks(stack_name: stack_name)
|
131
106
|
resp.stacks.first
|
132
107
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
@@ -136,18 +111,6 @@ module Jets::Commands
|
|
136
111
|
else
|
137
112
|
raise
|
138
113
|
end
|
139
|
-
rescue Aws::CloudFormation::Errors::Throttling => e
|
140
|
-
retries += 1
|
141
|
-
seconds = 2 ** retries
|
142
|
-
|
143
|
-
puts "WARN: find_stack #{e.class} #{e.message}".color(:yellow)
|
144
|
-
puts "Backing off and will retry in #{seconds} seconds."
|
145
|
-
sleep(seconds)
|
146
|
-
if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
|
147
|
-
puts "Giving up after #{retries} retries"
|
148
|
-
else
|
149
|
-
retry
|
150
|
-
end
|
151
114
|
end
|
152
115
|
|
153
116
|
# All CloudFormation states listed here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
|
data/lib/jets/commands/new.rb
CHANGED
@@ -114,7 +114,14 @@ JS
|
|
114
114
|
after = "const { environment } = require('@rails/webpacker')\n"
|
115
115
|
insert_into_file("config/webpack/environment.js", jquery, after: after)
|
116
116
|
|
117
|
-
|
117
|
+
jets_ujs =<<-JS
|
118
|
+
import Jets from "@rubyonjets/ujs-compat"
|
119
|
+
Jets.start()
|
120
|
+
JS
|
121
|
+
after = "Rails.start()\n"
|
122
|
+
insert_into_file("app/javascript/packs/application.js", jets_ujs, after: after)
|
123
|
+
|
124
|
+
run("yarn add bootstrap jquery popper.js postcss-cssnext @rails/ujs @rubyonjets/ujs-compat")
|
118
125
|
end
|
119
126
|
|
120
127
|
def git_init
|
@@ -5,17 +5,17 @@ class Jets::Controller::Middleware::Local
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def find_route
|
8
|
-
Jets::Router::Finder.new(
|
8
|
+
Jets::Router::Finder.new(path, method).run
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
attr_reader :env
|
13
13
|
|
14
|
-
def
|
14
|
+
def method
|
15
15
|
env["REQUEST_METHOD"] || "GET"
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def path
|
19
19
|
env["PATH_INFO"].sub(/^\//,'')
|
20
20
|
end
|
21
21
|
end
|
@@ -70,6 +70,7 @@ module Jets::Controller::Middleware
|
|
70
70
|
|
71
71
|
def on_aws?(env)
|
72
72
|
return false if Jets.env.test? # usually with test we're passing in full API Gateway fixtures with the HTTP_X_AMZN_TRACE_ID
|
73
|
+
return false if ENV['JETS_ELB'] # If we're using an ELB and Jets is inside a container running jets server, we don't want to pretend we're on AWS.
|
73
74
|
on_cloud9 = !!(env['HTTP_HOST'] =~ /cloud9\..*\.amazonaws\.com/)
|
74
75
|
!!env['HTTP_X_AMZN_TRACE_ID'] && !on_cloud9
|
75
76
|
end
|
@@ -7,16 +7,7 @@ class Jets::Controller
|
|
7
7
|
raise "redirect_to url parameter must be a String. Please pass in a string"
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
# if no location.host, we been provided a relative host
|
12
|
-
if !uri.host && actual_host
|
13
|
-
url = "/#{url}" unless url.starts_with?('/')
|
14
|
-
url = add_stage_name(url)
|
15
|
-
redirect_url = actual_host + url
|
16
|
-
else
|
17
|
-
redirect_url = url
|
18
|
-
end
|
19
|
-
|
10
|
+
redirect_url = add_stage(url)
|
20
11
|
redirect_url = ensure_protocol(redirect_url)
|
21
12
|
|
22
13
|
aws_proxy = Rendering::RackRenderer.new(self,
|
@@ -33,6 +33,8 @@ class Jets::Controller
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def adjust_content_type!(options)
|
36
|
+
return if options.key?(:content_type)
|
37
|
+
|
36
38
|
if options.key?(:json)
|
37
39
|
options[:content_type] = "application/json"
|
38
40
|
elsif options.key?(:xml)
|
@@ -60,15 +62,26 @@ class Jets::Controller
|
|
60
62
|
rest.merge(template: template)
|
61
63
|
end
|
62
64
|
|
63
|
-
#
|
64
|
-
|
65
|
+
# Example usage:
|
66
|
+
#
|
67
|
+
# render json: {success: true, location: add_stage(posts_path)}
|
68
|
+
#
|
69
|
+
def add_stage(url)
|
65
70
|
return url unless actual_host
|
66
71
|
|
67
|
-
|
72
|
+
uri = URI.parse(url)
|
73
|
+
# if no location.host, we been provided a relative host
|
74
|
+
if !uri.host && actual_host
|
75
|
+
url = "/#{url}" unless url.starts_with?('/')
|
76
|
+
url = Jets::Controller::Stage.add(actual_host, url)
|
77
|
+
actual_host + url
|
78
|
+
else
|
79
|
+
url
|
80
|
+
end
|
68
81
|
end
|
69
82
|
|
70
83
|
def url_for(url)
|
71
|
-
|
84
|
+
add_stage(url)
|
72
85
|
end
|
73
86
|
|
74
87
|
# Actual host can be headers["origin"] when cloudfront is in front.
|
@@ -56,7 +56,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
56
56
|
def delete
|
57
57
|
@<%= orm_instance.destroy %>
|
58
58
|
if request.xhr?
|
59
|
-
render json: {success: true}
|
59
|
+
render json: {success: true, location: <%= table_name %>_path}
|
60
60
|
else
|
61
61
|
redirect_to <%= table_name %>_path
|
62
62
|
end
|
@@ -4,6 +4,25 @@ require 'aws-sdk-cloudformation'
|
|
4
4
|
class BasePathMapping
|
5
5
|
def initialize(event, stage_name)
|
6
6
|
@event, @stage_name = event, stage_name
|
7
|
+
aws_config_update!
|
8
|
+
end
|
9
|
+
|
10
|
+
# Override the AWS retry settings. The aws-sdk-core has expondential backup with this formula:
|
11
|
+
#
|
12
|
+
# 2 ** c.retries * c.config.retry_base_delay
|
13
|
+
#
|
14
|
+
# So the max delay will be 2 ** 7 * 0.6 = 76.8s
|
15
|
+
#
|
16
|
+
# Useful links:
|
17
|
+
#
|
18
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
|
19
|
+
# https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
|
20
|
+
#
|
21
|
+
def aws_config_update!
|
22
|
+
Aws.config.update(
|
23
|
+
retry_limit: 7, # default: 3
|
24
|
+
retry_base_delay: 0.6, # default: 0.3
|
25
|
+
)
|
7
26
|
end
|
8
27
|
|
9
28
|
# Cannot use update_base_path_mapping to update the base_mapping because it doesnt
|
@@ -59,26 +59,11 @@ class Jets::Resource::ApiGateway::RestApi::Routes::Change
|
|
59
59
|
|
60
60
|
def method_uri(resource_id, http_method)
|
61
61
|
# https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
http_method: http_method
|
68
|
-
)
|
69
|
-
rescue Aws::APIGateway::Errors::TooManyRequestsException => e
|
70
|
-
retries += 1
|
71
|
-
seconds = 2 ** retries
|
72
|
-
|
73
|
-
puts "WARN: method_uri #{e.class} #{e.message}".color(:yellow)
|
74
|
-
puts "Backing off and will retry in #{seconds} seconds."
|
75
|
-
sleep(seconds)
|
76
|
-
if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
|
77
|
-
puts "Giving up after #{retries} retries"
|
78
|
-
else
|
79
|
-
retry
|
80
|
-
end
|
81
|
-
end
|
62
|
+
resp = apigateway.get_method(
|
63
|
+
rest_api_id: rest_api_id,
|
64
|
+
resource_id: resource_id,
|
65
|
+
http_method: http_method
|
66
|
+
)
|
82
67
|
resp.method_integration.uri
|
83
68
|
end
|
84
69
|
|
data/lib/jets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -1095,7 +1095,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1095
1095
|
- !ruby/object:Gem::Version
|
1096
1096
|
version: '0'
|
1097
1097
|
requirements: []
|
1098
|
-
rubygems_version: 3.
|
1098
|
+
rubygems_version: 3.1.6
|
1099
1099
|
signing_key:
|
1100
1100
|
specification_version: 4
|
1101
1101
|
summary: Ruby Serverless Framework
|