Sha256: 65ee17d55cd2f84b9b1cb2d2af52ad79a402395c187c046ef66c1ee35c774008

Contents?: true

Size: 781 Bytes

Versions: 6

Compression:

Stored size: 781 Bytes

Contents

module OpsPreflight
  module OpsWorks
    require 'ops_preflight/ops_works/base'

    class FetchEnvironment < Base
      attr_accessor :app_name
      attr_accessor :environment

      def initialize(environment, stack_name, app_name)
        super stack_name

        @environment = environment
        @app_name = app_name
      end

      def call
        resp = opsworks.client.describe_stacks(:stack_ids => [stack_id])

        require 'multi_json'

        json = MultiJson.load(resp[:stacks].first[:custom_json])

        str = ''
        json['env_vars'][app_name][environment].each do |var, value|
          str << "#{var.upcase}=#{value}\n"
        end

        File.open(".env.#{environment}", 'wb') do |f|
          f.write str
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ops_preflight-1.0.0.pre2 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-1.0.0.pre1 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-0.9.0 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-0.9.0.pre2 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-0.9.0.pre1 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-0.0.1.pre lib/ops_preflight/ops_works/fetch_environment.rb