Sha256: 18a6728f73e48875bd736e5d42802642e1ae6dafcd401b737d64ea489163a238

Contents?: true

Size: 992 Bytes

Versions: 7

Compression:

Stored size: 992 Bytes

Contents

require 'shipitron'

module Shipitron
  module Client
    class LoadTemplates
      include Metaractor

      required :ecs_task_def_dir
      optional :ecs_service_dir

      def call
        context.ecs_task_def_templates = load_templates(ecs_task_def_dir)
        context.ecs_service_templates = load_templates(ecs_service_dir)
      end

      private
      def ecs_task_def_dir
        context.ecs_task_def_dir
      end

      def ecs_service_dir
        context.ecs_service_dir
      end

      def load_templates(dir)
        return [] if dir.nil?

        search_path = Pathname.new(dir)
        unless search_path.directory?
          fail_with_error!(
            message: "directory '#{dir}' does not exist"
          )
        end

        templates = []
        search_path.find do |path|
          next if path.directory?

          templates << path.read
        end

        Logger.debug "Templates loaded: #{templates.inspect}"
        templates
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shipitron-0.3.5 lib/shipitron/client/load_templates.rb
shipitron-0.3.4 lib/shipitron/client/load_templates.rb
shipitron-0.3.3 lib/shipitron/client/load_templates.rb
shipitron-0.3.1 lib/shipitron/client/load_templates.rb
shipitron-0.3.0 lib/shipitron/client/load_templates.rb
shipitron-0.2.2 lib/shipitron/client/load_templates.rb
shipitron-0.2.1 lib/shipitron/client/load_templates.rb