Sha256: 8808a8e0366b1f50c28b800e27de65198891874d6eac5f4f11fbdf356297b67d

Contents?: true

Size: 1.78 KB

Versions: 23

Compression:

Stored size: 1.78 KB

Contents

# Implements:
#
#   * template_path
#
# FYI
#
#   * compose implemented by the classes that include this
class Jets::Cfn::Builders
  class BaseChildBuilder
    include Interface

    # The app_class is can be a controller, job or anonymous function class.
    # IE: PostsController, HardJob
    def initialize(app_class)
      @app_class = app_class
      @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
    end

    # template_path is an interface method for Interface module
    def template_path
      Jets::Naming.app_template_path(@app_class)
    end

    def add_common_parameters
      common_parameters = Jets::Resource::ChildStack::AppClass.common_parameters
      common_parameters.each do |k,_|
        add_parameter(k, Description: k)
      end

      depends_on_params.each do |output_key, output_value|
        desc = output_value.gsub("!GetAtt ", "") # desc doesnt allow !GetAtt
        add_parameter(output_key, Description: desc)
      end
    end

    def depends_on_params
      return {} unless @app_class.depends_on

      depends = Jets::Stack::Depends.new(@app_class.depends_on)
      depends.params
    end

    def add_functions
      add_class_iam_policy
      @app_class.tasks.each do |task|
        add_function(task)
        add_function_iam_policy(task)
      end
    end

    def add_function(task)
      resource = Jets::Resource::Lambda::Function.new(task)
      add_resource(resource)
    end

    def add_class_iam_policy
      return unless @app_class.build_class_iam?

      resource = Jets::Resource::Iam::ClassRole.new(@app_class)
      add_resource(resource)
    end

    def add_function_iam_policy(task)
      return unless task.build_function_iam?

      resource = Jets::Resource::Iam::FunctionRole.new(task)
      add_resource(resource)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
jets-1.9.7 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.6 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.5 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.4 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.3 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.2 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.1 lib/jets/cfn/builders/base_child_builder.rb
jets-1.9.0 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.14 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.13 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.12 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.11 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.10 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.9 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.8 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.7 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.6 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.5 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.4 lib/jets/cfn/builders/base_child_builder.rb
jets-1.8.3 lib/jets/cfn/builders/base_child_builder.rb