Sha256: ab1aec270b2bcf8e2ecca0962eb388343cceb3f25aca6d87549c0d34720714c3

Contents?: true

Size: 1.33 KB

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
phase-1.0.2 lib/phase/configuration.rb
phase-1.0.0.rc1 lib/phase/configuration.rb
phase-0.0.17 lib/phase/configuration.rb
phase-0.0.16.1 lib/phase/configuration.rb
phase-0.0.16 lib/phase/configuration.rb