Skip to content

Commit

Permalink
feat: Add support for multiple webhooks \n\n BREAKING CHANGE: Change …
Browse files Browse the repository at this point in the history
…data structure of repo_mapping attribute
  • Loading branch information
fabidick22 committed Jun 7, 2023
1 parent f96cd07 commit e28764a
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/call_receiver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,9 @@ def process_ecr_push_event(detail):
}))


def call_flux_webhook(repository):
# Retrieve the map of values from Secrets Manager
webhook_map = get_webhook_map()

# Find the webhook endpoint corresponding to the event repository
webhook_url = None
token = None
if repository in webhook_map:
repo_data = webhook_map[repository]
webhook_url = repo_data.get('webhook')
token = repo_data.get('token', get_global_token())

def make_requests(webhook_url, repository, headers):
# Call the Flux webhook with the token and corresponding endpoint
if webhook_url:
headers = {'Authorization': f'Bearer {token}'}
response = session.post(webhook_url, headers=headers)
print(json.dumps({
'message': 'Webhook response',
Expand All @@ -66,6 +54,23 @@ def call_flux_webhook(repository):
'repository': repository
}))

def call_flux_webhook(repository):
# Retrieve the map of values from Secrets Manager
webhook_map = get_webhook_map()

# Find the webhook endpoint corresponding to the event repository
webhook_url = None
token = None
if repository in webhook_map:
repo_data = webhook_map[repository]
webhook_urls = repo_data.get('webhook')
token = repo_data.get('token', get_global_token())
for webhook in webhook_urls:
headers = {'Authorization': f'Bearer {token}'}
make_requests(webhook, repository, headers)




def lambda_handler(event, context):
# Extract event information
Expand Down

0 comments on commit e28764a

Please sign in to comment.