Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support harbor webhook #1470

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading