Skip to content

Commit

Permalink
Merge pull request #81 from FullStackWithLawrence/next
Browse files Browse the repository at this point in the history
add SingletonConfig
  • Loading branch information
lpm0073 authored Dec 30, 2023
2 parents 91a42cc + b1ef699 commit f959458
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- name: Get IAM user info
run: |
aws sts get-caller-identity
aws sts get-caller-identity | sed -E 's/(arn:aws:iam::)[0-9]+(:user\/\w+)/\1************\2/' | jq '.Account="************"'
- name: Run Python tests
uses: ./.github/actions/tests/python
Expand Down
20 changes: 19 additions & 1 deletion terraform/python/rekognition_api/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,22 @@ def get_dns_record_from_hosted_zone(self) -> str:
return None


aws_infrastructure_config = AWSInfrastructureConfig()
class SingletonConfig:
"""Singleton for Settings"""

_instance = None

def __new__(cls):
"""Create a new instance of Settings"""
if cls._instance is None:
cls._instance = super(SingletonConfig, cls).__new__(cls)
cls._instance._config = AWSInfrastructureConfig()
return cls._instance

@property
def config(self):
"""Return the settings"""
return self._config # pylint: disable=E1101


aws_infrastructure_config = SingletonConfig().config
4 changes: 3 additions & 1 deletion terraform/python/rekognition_api/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def __init__(self, **data: Any): # noqa: C901
self._aws_access_key_id_source = "environ"
self._aws_secret_access_key_source = "environ"
except ProfileNotFound:
logger.warning("aws_profile %s not found", self.aws_profile)
# only log this if the aws_profile is set
if self.aws_profile:
logger.warning("aws_profile %s not found", self.aws_profile)

if self.aws_profile:
self._aws_access_key_id_source = "aws_profile"
Expand Down

0 comments on commit f959458

Please sign in to comment.