jets 2.1.5 → 2.1.6
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/.codebuild/docs/bin/git_setup.sh +3 -1
- data/.codebuild/docs/buildspec.yml +4 -2
- data/.codebuild/docs/project.rb +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/jets/application/defaults.rb +5 -0
- data/lib/jets/aws_info.rb +1 -1
- data/lib/jets/cfn/builders/base_child_builder.rb +0 -1
- data/lib/jets/cfn/builders/parent_builder.rb +2 -0
- data/lib/jets/cfn/builders/parent_builder/stagger.rb +34 -0
- data/lib/jets/lambda/functions.rb +5 -0
- data/lib/jets/resource/child_stack/app_class.rb +25 -13
- data/lib/jets/stack/depends.rb +10 -10
- data/lib/jets/stack/depends/item.rb +18 -1
- data/lib/jets/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b18d400a2d0e0f2133d5c6989b979bde0b1ad9e62f3d58256153d0f303b248a8
|
4
|
+
data.tar.gz: 24bb4977a7a3ae19a0c10db1e47597d8d5718fb613cb9e9b417ddf15a5aeafea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6adb65c04917a41ddfbb39d37baac2e5aa49052858a69b45abc6a751d516b7304dd42d5159c7108a0d168fe8776f859182d82070a869ad3100ff9d343fccc96
|
7
|
+
data.tar.gz: 370233f6def4284f6d0c26f6e4c48bbe217c40316733628ee71fedcf80b3b1e3e8a33291ad993450cf340244a246796d2bd9e7c69e4b79314c54d76f25aa6072
|
@@ -7,6 +7,9 @@
|
|
7
7
|
# cb start:
|
8
8
|
# CODEBUILD_SOURCE_VERSION=codebuild
|
9
9
|
|
10
|
+
git config --global user.email "tongueroo@gmail.com"
|
11
|
+
git config --global user.name "Tung Nguyen"
|
12
|
+
|
10
13
|
set +u # cb start will not have CODEBUILD_WEBHOOK_TRIGGER set
|
11
14
|
if [ -n "$CODEBUILD_WEBHOOK_TRIGGER" ]; then # git push
|
12
15
|
BRANCH=$(echo $CODEBUILD_WEBHOOK_TRIGGER | sed "s/.*\///")
|
@@ -16,4 +19,3 @@ else
|
|
16
19
|
BRANCH=UNKNOWN-BRANCH
|
17
20
|
fi
|
18
21
|
git checkout $BRANCH
|
19
|
-
set -u
|
data/.codebuild/docs/project.rb
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
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
|
+
## [2.1.6]
|
7
|
+
- #364 Add stagger deploy option: https://rubyonjets.com/docs/extras/deploy-stagger/
|
8
|
+
- codebuild: add caching to speed up build
|
9
|
+
|
6
10
|
## [2.1.5]
|
7
11
|
- perform_later calls perform_now in local mode when not on lambda
|
8
12
|
- fix: clear view cache in development mode
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Ruby and Lambda splat out a baby and that child's name is [Jets](http://rubyonjets.com/).
|
6
6
|
|
7
|
-

|
8
8
|
[](https://circleci.com/gh/tongueroo/jets)
|
9
9
|
[](https://badge.fury.io/rb/jets)
|
10
10
|
[](http://rubyonjets.com/support/)
|
@@ -147,6 +147,11 @@ class Jets::Application
|
|
147
147
|
config.controllers = ActiveSupport::OrderedOptions.new
|
148
148
|
config.controllers.default_protect_from_forgery = nil
|
149
149
|
|
150
|
+
config.deploy = ActiveSupport::OrderedOptions.new
|
151
|
+
config.deploy.stagger = ActiveSupport::OrderedOptions.new
|
152
|
+
config.deploy.stagger.enabled = false
|
153
|
+
config.deploy.stagger.batch_size = 10
|
154
|
+
|
150
155
|
config
|
151
156
|
end
|
152
157
|
|
data/lib/jets/aws_info.rb
CHANGED
@@ -55,7 +55,7 @@ module Jets
|
|
55
55
|
ENV['AWS_REGION'] ||= region
|
56
56
|
begin
|
57
57
|
sts.get_caller_identity.account
|
58
|
-
rescue Aws::Errors::MissingCredentialsError
|
58
|
+
rescue Aws::Errors::MissingCredentialsError, Aws::Errors::NoSuchEndpointError
|
59
59
|
puts "INFO: You're missing AWS credentials. Only local services are currently available"
|
60
60
|
end
|
61
61
|
end
|
@@ -4,6 +4,7 @@ module Jets::Cfn::Builders
|
|
4
4
|
class ParentBuilder
|
5
5
|
include Interface
|
6
6
|
include Jets::AwsServices
|
7
|
+
include Stagger
|
7
8
|
|
8
9
|
def initialize(options={})
|
9
10
|
@options = options
|
@@ -68,6 +69,7 @@ module Jets::Cfn::Builders
|
|
68
69
|
|
69
70
|
def add_app_class_stack(path)
|
70
71
|
resource = Jets::Resource::ChildStack::AppClass.new(@options[:s3_bucket], path: path)
|
72
|
+
add_stagger(resource)
|
71
73
|
add_child_resources(resource)
|
72
74
|
end
|
73
75
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Jets::Cfn::Builders::ParentBuilder
|
2
|
+
module Stagger
|
3
|
+
def add_stagger(resource)
|
4
|
+
batch_size = stagger_batch_size # shorter convenience variable
|
5
|
+
return if !stagger_enabled || batch_size.nil? || batch_size == 0
|
6
|
+
|
7
|
+
# initialize all here to keep logic together
|
8
|
+
@previous_stacks ||= []
|
9
|
+
@added_count ||= 0
|
10
|
+
|
11
|
+
if @previous_stacks.size >= batch_size
|
12
|
+
at_boundary = @added_count % batch_size == 0
|
13
|
+
if at_boundary
|
14
|
+
@left = @added_count - batch_size
|
15
|
+
@right = @left + batch_size - 1
|
16
|
+
end
|
17
|
+
previous_stack_batch = @previous_stacks[@left..@right]
|
18
|
+
resource.add_stagger_depends_on(previous_stack_batch)
|
19
|
+
end
|
20
|
+
|
21
|
+
@added_count += 1
|
22
|
+
@previous_stacks << resource
|
23
|
+
end
|
24
|
+
|
25
|
+
def stagger_batch_size
|
26
|
+
Jets.config.deploy.stagger.batch_size
|
27
|
+
end
|
28
|
+
|
29
|
+
# for spec-ing
|
30
|
+
def stagger_enabled
|
31
|
+
Jets.config.deploy.stagger.enabled
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -21,29 +21,40 @@ module Jets::Resource::ChildStack
|
|
21
21
|
}
|
22
22
|
}
|
23
23
|
}
|
24
|
-
defintion[logical_id][:depends_on] =
|
24
|
+
defintion[logical_id][:depends_on] = depends.stack_list if depends
|
25
25
|
defintion
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
28
|
+
def depends
|
29
|
+
return if all_depends_on.empty?
|
30
|
+
Jets::Stack::Depends.new(all_depends_on)
|
31
|
+
end
|
32
|
+
memoize :depends
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
# Always returns an Array, could be empty
|
35
|
+
def all_depends_on
|
36
|
+
depends_on = current_app_class.depends_on || [] # contains Depends::Items
|
37
|
+
stagger_depends_on = @stagger_depends_on || [] # contains Depends::Items
|
38
|
+
depends_on + stagger_depends_on
|
34
39
|
end
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
# For staggering. We're abusing depends_on to slow down the update rate.
|
42
|
+
#
|
43
|
+
# For this type of depends_on, there are no template parameters or outputs. To use the normal depends at we would
|
44
|
+
# have to make app classes adhere to what Jets::Stack::Depends requires. This is mainly dependency_outputs and
|
45
|
+
# output_keys for each class right now. It would not be that difficult but is not needed. So we create the
|
46
|
+
# Jets::Stack::Depends::Item objects directly.
|
47
|
+
def add_stagger_depends_on(stacks)
|
48
|
+
stack_names = stacks.map { |s| s.current_app_class.to_s.underscore }
|
49
|
+
items = stack_names.map { |name| Jets::Stack::Depends::Item.new(name) }
|
50
|
+
@stagger_depends_on ||= []
|
51
|
+
@stagger_depends_on += items.flatten
|
41
52
|
end
|
42
53
|
|
43
54
|
def parameters
|
44
55
|
common = self.class.common_parameters
|
45
56
|
common.merge!(controller_params) if controller?
|
46
|
-
common.merge!(
|
57
|
+
common.merge!(depends.params) if depends
|
47
58
|
common
|
48
59
|
end
|
49
60
|
|
@@ -86,7 +97,7 @@ module Jets::Resource::ChildStack
|
|
86
97
|
|
87
98
|
def scoped_routes
|
88
99
|
@routes ||= Jets::Router.routes.select do |route|
|
89
|
-
route.controller_name == current_app_class
|
100
|
+
route.controller_name == current_app_class.to_s
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
@@ -96,6 +107,7 @@ module Jets::Resource::ChildStack
|
|
96
107
|
.sub(/\.yml$/,'')
|
97
108
|
.gsub('-','/')
|
98
109
|
.camelize
|
110
|
+
.constantize
|
99
111
|
end
|
100
112
|
|
101
113
|
# map the path to a camelized logical_id. Example:
|
data/lib/jets/stack/depends.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
class Jets::Stack
|
2
2
|
class Depends
|
3
3
|
def initialize(items)
|
4
|
-
@items = items
|
4
|
+
@items = items # Jets::Stack::Depends::Item - has stack and options properties
|
5
5
|
end
|
6
6
|
|
7
7
|
def params
|
8
8
|
result = {}
|
9
9
|
@items.each do |item|
|
10
|
-
|
11
|
-
dependency_outputs(
|
12
|
-
dependency_class =
|
10
|
+
class_name = item.class_name
|
11
|
+
dependency_outputs(class_name).each do |output|
|
12
|
+
dependency_class = class_name.to_s.camelize
|
13
13
|
output_key = item.options[:class_prefix] ?
|
14
14
|
"#{dependency_class}#{output}" : # already camelized
|
15
15
|
output
|
@@ -21,14 +21,14 @@ class Jets::Stack
|
|
21
21
|
result
|
22
22
|
end
|
23
23
|
|
24
|
+
# Returns CloudFormation template logical ids
|
24
25
|
def stack_list
|
25
|
-
@items.map
|
26
|
-
item.stack.to_s.camelize # logical_id # logical_id
|
27
|
-
end
|
26
|
+
@items.map(&:logical_id)
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
private
|
30
|
+
def dependency_outputs(class_name)
|
31
|
+
class_name.to_s.camelize.constantize.output_keys
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
@@ -1,9 +1,26 @@
|
|
1
|
+
# Usage examples:
|
2
|
+
#
|
3
|
+
# Jets::Stack::Depends::Item.new(:custom)
|
4
|
+
# Jets::Stack::Depends::Item.new(:custom, :alert)
|
5
|
+
# Jets::Stack::Depends::Item.new(:custom, class_prefix: true)
|
6
|
+
# Jets::Stack::Depends::Item.new(:custom, :alert, class_prefix: true)
|
7
|
+
#
|
8
|
+
# The Jets::Stack::Depends#params uses the options to determine if the class prefix should be added.
|
9
|
+
#
|
1
10
|
class Jets::Stack::Depends
|
2
11
|
class Item
|
3
12
|
attr_reader :stack, :options
|
4
13
|
def initialize(stack, options={})
|
5
|
-
@stack = stack
|
14
|
+
@stack = stack # should be underscore format. IE: admin/posts_controller
|
6
15
|
@options = options
|
7
16
|
end
|
17
|
+
|
18
|
+
def logical_id
|
19
|
+
@stack.to_s.gsub('::','').gsub('/','_').camelize
|
20
|
+
end
|
21
|
+
|
22
|
+
def class_name
|
23
|
+
@stack.to_s.camelize
|
24
|
+
end
|
8
25
|
end
|
9
26
|
end
|
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: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -614,6 +614,7 @@ files:
|
|
614
614
|
- lib/jets/cfn/builders/interface.rb
|
615
615
|
- lib/jets/cfn/builders/job_builder.rb
|
616
616
|
- lib/jets/cfn/builders/parent_builder.rb
|
617
|
+
- lib/jets/cfn/builders/parent_builder/stagger.rb
|
617
618
|
- lib/jets/cfn/builders/rule_builder.rb
|
618
619
|
- lib/jets/cfn/builders/shared_builder.rb
|
619
620
|
- lib/jets/cfn/built_template.rb
|