Include git hash in env variables for functions
This commit is contained in:
@@ -9,6 +9,7 @@ from redirects_base import Content, Customer, Redirects, Tag
|
||||
bucket_config = ''
|
||||
bucket_data = ''
|
||||
function_url = ''
|
||||
git_version = ''
|
||||
s3_client = None
|
||||
redirects: Redirects | None = None
|
||||
|
||||
@@ -35,15 +36,18 @@ class Record(BaseModel):
|
||||
s3: S3Event
|
||||
|
||||
def lambda_handler(event: dict, context):
|
||||
global s3_client, bucket_config, bucket_data, function_url, redirects
|
||||
global s3_client, bucket_config, bucket_data, function_url, redirects, git_version
|
||||
|
||||
if s3_client is None:
|
||||
print("Init Function")
|
||||
bucket_config = os.environ.get('BUCKET_CONFIG', 'standout-config')
|
||||
bucket_data = os.environ.get('BUCKET_DATA', 'standout-data')
|
||||
function_url = os.environ.get('FUNCTION_URL', 'https://api.standout.it/dev')
|
||||
print(f'Bucket Config: {bucket_config}')
|
||||
git_version = os.environ.get('GIT_VERSION', '00000000')
|
||||
|
||||
print(f' Version: {git_version}')
|
||||
print(f' Bucket Data: {bucket_data}')
|
||||
print(f'Bucket Config: {bucket_config}')
|
||||
s3_client = boto3.client('s3')
|
||||
|
||||
### Process records
|
||||
@@ -65,6 +69,7 @@ def lambda_handler(event: dict, context):
|
||||
if redirects is None:
|
||||
try:
|
||||
redirects = downloadRedirects(client = s3_client, context = context)
|
||||
redirects.version = git_version
|
||||
except s3_client.exceptions.NoSuchKey as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
@@ -17,4 +17,5 @@ class Customer(BaseModel):
|
||||
tags: Optional[Dict[str, Optional[Tag]] ]
|
||||
|
||||
class Redirects(BaseModel):
|
||||
version: str
|
||||
customers: Dict[str, Optional[Customer]] | None = None
|
||||
|
||||
Reference in New Issue
Block a user