Class: OpzWorks::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/opzworks/config.rb', line 12

def initialize
  file = ENV['AWS_CONFIG_FILE'] || "#{ENV['HOME']}/.aws/config"

  fail 'AWS config file not found' unless File.exist? file
  ini = IniFile.load(file)

  # set the region and the profile we want to pick up from ~/.aws/credentials
  @aws_profile = ENV['AWS_PROFILE'] || 'default'
  @aws_region  = ENV['AWS_REGION'] || ini[@aws_profile]['region']

  @ssh_user_name = ini['opzworks']['ssh-user-name'].strip
  @berks_repository_path = ini['opzworks']['berks-repository-path'].strip

  @berks_base_path =
    ini['opzworks']['berks-base-path'].strip unless ini['opzworks']['berks-base-path'].nil?
  @berks_s3_bucket =
    ini['opzworks']['berks-s3-bucket'].strip unless ini['opzworks']['berks-s3-bucket'].nil?
  @berks_tarball_name =
    ini['opzworks']['berks-tarball-name'].strip unless ini['opzworks']['berks-tarball-name'].nil?
  @berks_github_org =
    ini['opzworks']['berks-github-org'].strip unless ini['opzworks']['berks-github-org'].nil?
end

Instance Attribute Details

#aws_profileObject (readonly)

Returns the value of attribute aws_profile.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def aws_profile
  @aws_profile
end

#aws_regionObject (readonly)

Returns the value of attribute aws_region.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def aws_region
  @aws_region
end

#berks_base_pathObject (readonly)

Returns the value of attribute berks_base_path.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def berks_base_path
  @berks_base_path
end

#berks_github_orgObject (readonly)

Returns the value of attribute berks_github_org.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def berks_github_org
  @berks_github_org
end

#berks_repository_pathObject (readonly)

Returns the value of attribute berks_repository_path.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def berks_repository_path
  @berks_repository_path
end

#berks_s3_bucketObject (readonly)

Returns the value of attribute berks_s3_bucket.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def berks_s3_bucket
  @berks_s3_bucket
end

#berks_tarball_nameObject (readonly)

Returns the value of attribute berks_tarball_name.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def berks_tarball_name
  @berks_tarball_name
end

#ssh_user_nameObject (readonly)

Returns the value of attribute ssh_user_name.



9
10
11
# File 'lib/opzworks/config.rb', line 9

def ssh_user_name
  @ssh_user_name
end