Sha256: bb36fc82d112ca1eaea23135d5806dff25200c4fd9486b38ea935a713aa0ce92

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require 'mikoshi/plan'

module Mikoshi
  class Plan
    class TaskDefinition < Base
      def initialize(yaml_path: nil, client: nil)
        super
      end

      def register_task_definition
        invoke_before_register_hooks

        resp = @client.register_task_definition(@data[:task_definition])
        ENV['TASK_DEF_REVISION'] = resp.task_definition.revision.to_s

        invoke_after_register_hooks

        resp
      rescue => e
        invoke_failed_hooks
        raise e
      end

      private

      %w[before after].each do |step|
        define_method "invoke_#{step}_register_hooks" do
          invoke_hooks @data[:hooks]["#{step}_register".to_sym] unless @data.dig(:hooks, "#{step}_register".to_sym).nil?
        end
      end
      def invoke_failed_hooks
        invoke_hooks(@data[:hooks][:failed]) unless @data.dig(:hooks, :failed).nil?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mikoshi-0.5.1 lib/mikoshi/plan/task_definition.rb
mikoshi-0.5.0 lib/mikoshi/plan/task_definition.rb
mikoshi-0.4.0 lib/mikoshi/plan/task_definition.rb
mikoshi-0.3.0 lib/mikoshi/plan/task_definition.rb