Skip to content

Commit

Permalink
Shared credential provider now supports inline comments on the profil…
Browse files Browse the repository at this point in the history
…e name line.

Fixes #837
  • Loading branch information
trevorrowe committed Jun 12, 2015
1 parent 63f5bf4 commit cd96ad0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Unreleased Changes
------------------

* Issue - Shared Credentials - Resolved an issue where the shared credentials
provider would fail to parse profiles which contained an inline comment.

See [related GitHub issue #837](https://github.com/aws/aws-sdk-ruby/issues/837)

* Feature - Aws::IAM - Added `Aws::IAM::User#exists?`.

See [related GitHub issue #840](https://github.com/aws/aws-sdk-ruby/issues/840)
Expand Down
2 changes: 1 addition & 1 deletion aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def ini_parse(file)
map = {}
file.lines.each do |line|
line = line.split(/^|\s;/).first # remove comments
section = line.match(/^\s*\[([^\[\]]+)\]\s*$/) unless line.nil?
section = line.match(/^\s*\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
if section
current_section = section[1]
elsif current_section
Expand Down
13 changes: 13 additions & 0 deletions aws-sdk-core/spec/aws/shared_credentials_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,18 @@ module Aws
expect(creds.set?).to eq(false)
end

it 'supports inline comments with the profile' do
file = <<-FILE
[default] # comment
aws_access_key_id=commented-akid
aws_secret_access_key=commented-secret
FILE
allow(File).to receive(:read).and_return(file)
creds = SharedCredentials.new(path:mock_credential_file).credentials
expect(creds.access_key_id).to eq('commented-akid')
expect(creds.secret_access_key).to eq('commented-secret')

end

end
end

0 comments on commit cd96ad0

Please sign in to comment.