Module: Jets::Lambda::Dsl::Warnings

Defined in:
lib/jets/lambda/dsl/warnings.rb

Instance Method Summary collapse

Instance Method Details

#app_call_lineObject



53
54
55
# File 'lib/jets/lambda/dsl/warnings.rb', line 53

def app_call_line
  caller.find { |l| l.include?('app/controllers') }
end

#class_iam_policy_unused_warning(managed = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/jets/lambda/dsl/warnings.rb', line 23

def class_iam_policy_unused_warning(managed=false)
  return unless Jets.config.cfn.build.controllers == "one_lambda_for_all_controllers"
  return if self.to_s == "ApplicationController" # ApplicationController not defined in job mode
  return if self.ancestors.include?(Jets::Job::Base)

  managed_prefix = managed ? "managed_" : ""
  puts "    WARNING: class_\#{managed_prefix}iam_policy is not respected when\n    config.cfn.build.controllers is not set to \"one_lambda_per_controller\" or \"one_lambda_per_method\"\n    Current setting: config.cfn.build.controllers = \"\#{Jets.config.cfn.build.controllers}\"\n    Please use class_\#{managed_prefix}iam_policy in the ApplicationController instead.\n    Docs: \#{iam_docs_url(managed)}\n  EOL\n\n  DslEvaluator.print_code(app_call_line) if app_call_line\nend\n".color(:yellow)

#iam_docs_url(managed) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/jets/lambda/dsl/warnings.rb', line 45

def iam_docs_url(managed)
  if managed
    "http://rubyonjets.com/docs/managed-iam-policies/"
  else
    "http://rubyonjets.com/docs/iam-policies/"
  end
end

#iam_policy_unused_warning(managed = false) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jets/lambda/dsl/warnings.rb', line 3

def iam_policy_unused_warning(managed=false)
  return unless show_iam_policy_unused_warning?

  managed_prefix = managed ? "managed_" : ""
  use_instead = case Jets.config.cfn.build.controllers
                when "one_lambda_per_contoller"
                  "class_#{managed_prefix}iam_policy"
                when "one_lambda_for_all_controllers"
                  "class_#{managed_prefix}iam_policy in the ApplicationController"
                end
  puts "    WARNING: \#{managed_prefix}iam_policy is not respected when config.cfn.build.controllers is not set to \"one_lambda_per_controller\"\n    Current setting: config.cfn.build.controllers = \"\#{Jets.config.cfn.build.controllers}\"\n    Please use \#{use_instead} instead.\n    Docs: \#{iam_docs_url(managed)}\n  EOL\n\n  DslEvaluator.print_code(app_call_line) if app_call_line\nend\n".color(:yellow)

#show_iam_policy_unused_warning?Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/jets/lambda/dsl/warnings.rb', line 40

def show_iam_policy_unused_warning?
  Jets.config.cfn.build.controllers != "one_lambda_per_method" &&
  self.name.include?("Controller")
end