Sha256: 3da16869304e0079b32cccc5bbad7aeff6ee6f986251272e350b798d8d2e8754

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

module Phase
  class Configuration

    attr_accessor :bastions_enabled, :bastion_role, :bastion_user, :public_subnet_name,
                  :private_subnet_name, :aws_region, :adapter, :backend

    def initialize
      @bastions_enabled     = false
      @bastion_role         = nil
      @bastion_user         = nil
      @public_subnet_name   = "public"
      @private_subnet_name  = "private"
      @aws_region           = "us-east-1"
      @adapter              = ::Phase::Adapters::AWS

      # self.backend = ::Phase::SSH::Backend
      set_aws_credentials!
    end

    def backend=(backend)
      @backend = backend
      ::SSHKit.config.backend = @backend
    end

    # @see Phase::Config::Deploy
    def deploy
      @deploy ||= Config::Deploy.new
    end

    # @see Phase::Config::IPA
    def ipa
      @ipa ||= Config::IPA.new
    end

    def load_phasefile!
      if ::File.exist?(phasefile_path)
        load phasefile_path
      end
    end

    def set_aws_credentials!(access_key_id = nil, secret_access_key = nil)
      Fog.credentials = {
        aws_access_key_id:     ENV.fetch('AWS_ACCESS_KEY_ID', access_key_id),
        aws_secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', secret_access_key)
      }
    end

    private

      def phasefile_path
        @phasefile_path ||= ::File.join(::Dir.pwd, 'Phasefile')
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phase-1.0.1 lib/phase/configuration.rb
phase-1.0.0 lib/phase/configuration.rb
phase-1.0.0.rc2 lib/phase/configuration.rb