Skip to content

Commit

Permalink
Merge pull request #15 from Mexx77/master
Browse files Browse the repository at this point in the history
export AWS_PROFILE
  • Loading branch information
naftulikay authored Aug 14, 2019
2 parents 8c18170 + 6619a8e commit 7d9d9ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/.installed.cfg
/.python-version
/.vagrant
/.idea

__pycache__
*.pyc
Expand Down
6 changes: 4 additions & 2 deletions src/awsenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ def format(self, export=True):
return "\n".join([
"{}AWS_ACCESS_KEY_ID={}".format("export " if export else "", self.aws_access_key_id),
"{}AWS_SECRET_ACCESS_KEY={}".format("export " if export else "", self.aws_secret_access_key),
"{}AWS_SESSION_TOKEN={}".format("export " if export else "", self.aws_session_token)
"{}AWS_SESSION_TOKEN={}".format("export " if export else "", self.aws_session_token),
"{}AWS_PROFILE={}".format("export " if export else "", self.name)
])
else:
return "\n".join([
"{}AWS_ACCESS_KEY_ID={}".format("export " if export else "", self.aws_access_key_id),
"{}AWS_SECRET_ACCESS_KEY={}".format("export " if export else "", self.aws_secret_access_key)
"{}AWS_SECRET_ACCESS_KEY={}".format("export " if export else "", self.aws_secret_access_key),
"{}AWS_PROFILE={}".format("export " if export else "", self.name)
])
@property
def aws_access_key_id(self):
Expand Down
6 changes: 3 additions & 3 deletions src/awsenv/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def test_constructor(self):
self.assertEqual('session token', fixture.session_token)

def test_format(self):
fixture = AWSProfile(None, 'a', 'b', 'c')
result_export = "export AWS_ACCESS_KEY_ID=a\nexport AWS_SECRET_ACCESS_KEY=b\nexport AWS_SESSION_TOKEN=c"
result_no_export = "AWS_ACCESS_KEY_ID=a\nAWS_SECRET_ACCESS_KEY=b\nAWS_SESSION_TOKEN=c"
fixture = AWSProfile('p', 'a', 'b', 'c')
result_export = "export AWS_ACCESS_KEY_ID=a\nexport AWS_SECRET_ACCESS_KEY=b\nexport AWS_SESSION_TOKEN=c\nexport AWS_PROFILE=p"
result_no_export = "AWS_ACCESS_KEY_ID=a\nAWS_SECRET_ACCESS_KEY=b\nAWS_SESSION_TOKEN=c\nAWS_PROFILE=p"

self.assertEqual(result_export, fixture.format())
self.assertEqual(result_no_export, fixture.format(export=False))
Expand Down

0 comments on commit 7d9d9ff

Please sign in to comment.