jets 1.9.23 → 1.9.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f412ceff12f17dc7991129a970fb8cadbbd99505df4477ff9d21caa0c5336cd
4
- data.tar.gz: e21ec406d552d30bf5a2f3975d986ebf319737235e78042bb20565b34d91fa6c
3
+ metadata.gz: 2f1be1857a1221db9a29d0106fa74d9f2d773fe5f3c09eb877eb91dabfacf913
4
+ data.tar.gz: 93154ffb64b35f28d6af723d5d6309077480b083ddb67b9e69a5fdafc2e30aec
5
5
  SHA512:
6
- metadata.gz: 0edbc1119cc44b14bd71585f077e8abf6b8e545d83f587e7fe4e7c4059817033d0869539e96e688540bcddd3cbd90c8f905189cb08780a393610535ae5a8b3df
7
- data.tar.gz: e74dd8be455ea2120b3b2fc1fc8e20621488f6fc030cae7a9847a2f84d4dffa9cdf6f70cc8f7e5d17cf5531f927285d127fdda9d52316f135d5f95a3571a278c
6
+ metadata.gz: 4e6a216db6fe880c7474a22a104f5b323fec4fe7b2f784b5a8837608df7a24b6cff5be8e13151e5ee6e2ceb110ccfb9c6a629b40b0762f1128b50cc1c5c17c9a
7
+ data.tar.gz: 0b149b34bf275c7c77d373a43c6f4abe89710d40e2adca924a07a3a9e8d3d2b2add0c384b5e180495903748ab727b97f4c64c2e40aa3fa372c69e105a0b97171
@@ -3,6 +3,9 @@
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
+ ## [1.9.24]
7
+ - #301 Fix jets call for long function names. Lookup actual function names for long functions
8
+
6
9
  ## [1.9.23]
7
10
  - #300 use .jets/project folder for afterburner instead of .jets/app
8
11
 
@@ -16,6 +16,8 @@ Jets::Autoloaders.once.setup
16
16
 
17
17
  module Jets
18
18
  RUBY_VERSION = "2.5.3"
19
+ MAX_FUNCTION_NAME_SIZE = 64
20
+
19
21
  class Error < StandardError; end
20
22
  extend Core # root, logger, etc
21
23
  end
@@ -23,14 +23,12 @@ class Jets::Application
23
23
  }
24
24
  policies = [logs, s3_readonly, s3_bucket]
25
25
 
26
- if Jets::Stack.has_resources?
27
- cloudformation = {
28
- action: ["cloudformation:DescribeStacks"],
29
- effect: "Allow",
30
- resource: "arn:aws:cloudformation:#{Jets.aws.region}:#{Jets.aws.account}:stack/#{project_namespace}*",
31
- }
32
- policies << cloudformation
33
- end
26
+ cloudformation = {
27
+ action: ["cloudformation:DescribeStacks", "cloudformation:DescribeStackResources"],
28
+ effect: "Allow",
29
+ resource: "arn:aws:cloudformation:#{Jets.aws.region}:#{Jets.aws.account}:stack/#{project_namespace}*",
30
+ }
31
+ policies << cloudformation
34
32
 
35
33
  if Jets.config.function.vpc_config
36
34
  vpc = {
@@ -27,6 +27,7 @@ module Jets
27
27
  Zeitwerk::Loader.new.tap do |loader|
28
28
  loader.tag = "jets.main"
29
29
  # loader.inflector = Inflector.new # TODO: allow custom app inflector
30
+ loader.ignore("#{Jets.root}/app/shared/functions")
30
31
  end
31
32
  end
32
33
  memoize :main
@@ -5,6 +5,8 @@
5
5
  #
6
6
  class Jets::Commands::Call
7
7
  class BaseGuesser
8
+ include Jets::AwsServices
9
+
8
10
  # provided_function_name:
9
11
  # admin/related_pages_controller-list_all
10
12
  # admin-related-pages-controller-list-all
@@ -28,6 +30,31 @@ class Jets::Commands::Call
28
30
 
29
31
  code_path = class_name.underscore.gsub('/','-')
30
32
  function_name = [Jets.config.project_namespace, code_path, method_name].join('-')
33
+ generated_function_name(function_name)
34
+ end
35
+
36
+ def generated_function_name(function_name)
37
+ if function_name.size > Jets::MAX_FUNCTION_NAME_SIZE # name generated by CloudFormation
38
+ logical_id = @class_name.gsub('::','')
39
+ app_stack_arn = lookup(parent_stack[:outputs], logical_id)
40
+
41
+ resources = stack_resources(app_stack_arn)
42
+ resource = resources.find { |r| r.logical_resource_id == method_name.camelize + "LambdaFunction" } # method_name only contains the method
43
+ resource.physical_resource_id # actual function name
44
+ else
45
+ function_name
46
+ end
47
+ end
48
+
49
+ # Class variable caches
50
+ @@stack_resources = {}
51
+ def stack_resources(stack_name)
52
+ @@stack_resources[stack_name] ||= cfn.describe_stack_resources(stack_name: stack_name).stack_resources
53
+ end
54
+
55
+ @@parent_stack = nil
56
+ def parent_stack
57
+ @@parent_stack ||= cfn.describe_stacks(stack_name: Jets::Naming.parent_stack_name).stacks.first
31
58
  end
32
59
  end
33
60
  end
@@ -80,7 +80,7 @@ module Jets::Commands
80
80
  option :qualifier, desc: "Lambda function version or alias name"
81
81
  option :show_log, type: :boolean, desc: "Shows last 4KB of log in the x-amz-log-result header"
82
82
  option :lambda_proxy, type: :boolean, default: true, desc: "Enables automatic Lambda proxy transformation of the event payload"
83
- option :guess, type: :boolean, default: true, desc: "Enables guess mode. Uses inference to allows use of all dashes to specify functions. Smart mode verifies that the function exists in the code base."
83
+ option :guess, type: :boolean, default: true, desc: "Enables guess mode. Uses inference to allows use of all dashes to specify functions. Guess mode verifies that the function exists in the code base."
84
84
  option :local, type: :boolean, desc: "Enables local mode. Instead of invoke the AWS Lambda function, the method gets called locally with current app code. With local mode guess mode is always used."
85
85
  def call(function_name, payload='')
86
86
  # Printing to stdout can mangle up the response when piping
@@ -23,6 +23,7 @@ group :development, :test do
23
23
  <% unless options[:mode] == 'job' -%>
24
24
  gem 'shotgun'
25
25
  gem 'rack'
26
+ gem 'puma'
26
27
  <% end -%>
27
28
  end
28
29
 
@@ -184,7 +184,6 @@ module Jets::Resource::Lambda
184
184
  "jets/code/code-#{checksum}.zip" # s3_key
185
185
  end
186
186
 
187
- MAX_FUNCTION_NAME_SIZE = 64
188
187
  # Examples:
189
188
  # "#{Jets.config.project_namespace}-sleep_job-perform"
190
189
  # "demo-dev-sleep_job-perform"
@@ -200,7 +199,7 @@ module Jets::Resource::Lambda
200
199
  # Returns nil if function name is too long.
201
200
  # CloudFormation will managed the the function name in this case.
202
201
  # A pretty function name won't be generated but the deploy will be successful.
203
- function_name.size > MAX_FUNCTION_NAME_SIZE ? nil : function_name
202
+ function_name.size > Jets::MAX_FUNCTION_NAME_SIZE ? nil : function_name
204
203
  end
205
204
 
206
205
  def description
@@ -61,20 +61,11 @@ module Jets
61
61
  end
62
62
  memoize :template
63
63
 
64
- # Usage:
65
- #
66
- # Jets::Stack.has_resources?
67
- #
68
- def has_resources?
69
- # need to eager load the app/shared resources in order to check if shared resources have been registered
70
- eager_load_shared_resources!
71
- !!subclasses.detect do |subclass|
72
- subclass.build?
73
- end
74
- end
75
-
64
+ # Eager loading the app/shared resources to ensure shared resources have been registered.
65
+ # Not being used anymore but keeping around just in case for now.
76
66
  def eager_load_shared_resources!
77
67
  Dir.glob("#{Jets.root}/app/shared/**").each do |path|
68
+ next if path.include?("app/shared/functions")
78
69
  Jets::Autoloaders.main.preload(path)
79
70
  end
80
71
  end
@@ -1,6 +1,5 @@
1
1
  module Jets::Stack::Main::Dsl
2
2
  module Lambda
3
- MAX_FUNCTION_NAME_SIZE = 64
4
3
  # Example:
5
4
  #
6
5
  # function(:hello,
@@ -38,7 +37,7 @@ module Jets::Stack::Main::Dsl
38
37
  }
39
38
 
40
39
  function_name = "#{Jets.config.project_namespace}-#{class_namespace}-#{meth}"
41
- function_name = function_name.size > MAX_FUNCTION_NAME_SIZE ? nil : function_name
40
+ function_name = function_name.size > Jets::MAX_FUNCTION_NAME_SIZE ? nil : function_name
42
41
  defaults[:function_name] = function_name if function_name
43
42
 
44
43
  props = defaults.merge(props)
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.9.23"
2
+ VERSION = "1.9.24"
3
3
  end
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: 1.9.23
4
+ version: 1.9.24
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-06-27 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer