Skip to content

Commit

Permalink
fix: support harbor webhook (#1470)
Browse files Browse the repository at this point in the history
Signed-off-by: liangjunhao <[email protected]>
  • Loading branch information
paterleng authored Jun 13, 2024
1 parent 3273599 commit 7c1ad03
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions console/views/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,22 @@ def post(self, request, service_id, *args, **kwargs):
# 校验
repository = request.data.get("repository")
if not repository:
logger.debug("缺少repository信息")
event_data = request.data.get("event_data")
repository = event_data.get("repository")

if not repository:
result = general_message(400, "failed", "缺少repository信息")
return Response(result, status=400)

push_data = request.data.get("push_data")
pusher = push_data.get("pusher")
tag = push_data.get("tag")
if not push_data:
pusher = request.data.get("operator")
for resource in event_data.get('resources', []):
tag = resource.get('tag')
else:
pusher = push_data.get("pusher")
tag = push_data.get("tag")

repo_name = repository.get("repo_name")
if not repo_name:
repository_namespace = repository.get("namespace")
Expand All @@ -593,6 +602,8 @@ def post(self, request, service_id, *args, **kwargs):
repo_name = "fake.repo.aliyun.com/" + repository_namespace + "/" + repository_name
else:
repo_name = repository.get("repo_full_name")
if event_data:
repo_name = repository.get("repo_full_name")
if not repo_name:
result = general_message(400, "failed", "缺少repository名称信息")
return Response(result, status=400)
Expand Down

0 comments on commit 7c1ad03

Please sign in to comment.