Class: Bookbinder::Config::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/config/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration_validator, loader, credentials_provider) ⇒ Fetcher

Returns a new instance of Fetcher.



9
10
11
12
13
# File 'lib/bookbinder/config/fetcher.rb', line 9

def initialize(configuration_validator, loader, credentials_provider)
  @loader = loader
  @configuration_validator = configuration_validator
  @credentials_provider = credentials_provider
end

Instance Method Details

#fetch_configObject



15
16
17
# File 'lib/bookbinder/config/fetcher.rb', line 15

def fetch_config
  @config ||= validate(read_config_file)
end

#fetch_credentials(environment = 'null-environment') ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bookbinder/config/fetcher.rb', line 19

def fetch_credentials(environment = 'null-environment')
  @credentials ||= credentials_provider.credentials(fetch_config.cred_repo_url)
  {
    aws: Config::AwsCredentials.new(
      @credentials.fetch('aws', {})
    ),
    cloud_foundry: Config::CfCredentials.new(
      @credentials.fetch('cloud_foundry', {}),
      environment
    )
  }
end

#set_config_file_path(config_file_path) ⇒ Object



32
33
34
# File 'lib/bookbinder/config/fetcher.rb', line 32

def set_config_file_path config_file_path
  @config_file_path = File.expand_path config_file_path
end