lib/phase/configuration.rb in phase-0.0.5 vs lib/phase/configuration.rb in phase-0.0.6

- old
+ new

@@ -1,45 +1,49 @@ module Phase class Configuration - attr_accessor :use_bastions, - :bastion_role, - :bastion_user, + attr_accessor :bastions_enabled, :bastion_role, :bastion_user, :public_subnet_name, + :private_subnet_name, :aws_region, :adapter, :backend, + :bundle_id_prefix, :ipa_directory_prefix, :ipa_bucket_name - :aws_region, - - :adapter - def initialize - @use_bastions = false - @bastion_role = "ssh" - @bastion_user = "orca" + @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 - @aws_region = "us-east-1" + @bundle_id_prefix = "" + @ipa_directory_prefix = "" + @ipa_bucket_name = "" - @adapter = ::Phase::Adapters::AWS - - ::SSHKit.config.backend = SSH::Backend - - configure_from_yml if defined?(::Rails) && yml_present? + self.backend = ::Phase::SSH::Backend + set_aws_credentials! end - def configure_from_yml - yml_config = ::YAML.load_file(yml_path) || {} - - @use_bastions = yml_config[:use_bastions] if yml_config.has_key(:use_bastions) - @bastion_role = yml_config[:bastion_role] if yml_config.has_key(:bastion_role) - @bastion_user = yml_config[:bastion_user] if yml_config.has_key(:bastion_user) - - @aws_region = yml_config[:aws_region] if yml_config.has_key(:aws_region) + def backend=(backend) + @backend = backend + ::SSHKit.config.backend = @backend end - def yml_present? - File.exists?(yml_path) + def load_phasefile! + if ::File.exist?(phasefile_path) + load phasefile_path + end end - def yml_path - # ::Rails.root.join("config", "phase.yml") - "" + def set_aws_credentials! + Fog.credentials = { + aws_access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), + aws_secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY') + } end + + private + + def phasefile_path + @phasefile_path ||= ::File.join(::Dir.pwd, 'Phasefile') + end end end