Sha256: 2550f6c0289b93ab07659127d4e8e33fe8c7e621866a49c711f6ef884929779e

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

require "yaml"

module Jack
  class Create
    include Util

    def initialize(options={})
      @options = options
      @root = options[:root] || '.'
      @env_name = options[:env_name]
      @app_name = options[:app] || app_name_convention(@env_name)
    end

    def run
      prerequisites
      create_app
      create_env
    end

    def create_app
      eb.create_application(
        application_name: @app_name
      ) unless app_exist?
    end

    def app_exist?
      return true if @options[:noop]
      r = eb.describe_applications
      r.applications.collect(&:application_name).include?(@app_name)
    end

    def create_env
      command = build_command
      sh(command, @options)
    end

    def build_command
      @cfg = upload_cfg
      flags = settings.create_flags
      "#{eb_bin} create#{eb_base_flags} --sample --nohang #{flags} #{@cfg}#{cname}#{@env_name}"
    end

    def upload_cfg
      @upload = Config::Apply.new(@options)
      if @upload.local_cfg_exist?
        @upload.upload
        cfg = "--cfg #{@upload.upload_name} "
      end
    end

    def cname
      "--cname #{@env_name} "
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jack-eb-1.4.4 lib/jack/create.rb
jack-eb-1.4.3 lib/jack/create.rb
jack-eb-1.4.2 lib/jack/create.rb
jack-eb-1.4.1 lib/jack/create.rb