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: add data before in audit record of service discovery and domain resolution #1615

Merged
merged 1 commit into from
Sep 19, 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
10 changes: 10 additions & 0 deletions apiserver/paasng/paasng/platform/bkapp_model/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def retrieve(self, request, code):
@swagger_auto_schema(responses={200: SvcDiscConfigSLZ()}, request_body=SvcDiscConfigSLZ)
def upsert(self, request, code):
application = self.get_application()
svc_disc = SvcDiscConfig.objects.filter(application_id=application.id).first()
data_before = None
if svc_disc:
data_before = DataDetail(type=DataType.RAW_DATA, data=SvcDiscConfigSLZ(svc_disc).data)

slz = SvcDiscConfigSLZ(data=request.data)
slz.is_valid(raise_exception=True)
Expand All @@ -285,6 +289,7 @@ def upsert(self, request, code):
action_id=AppAction.BASIC_DEVELOP,
operation=OperationEnum.CREATE if created else OperationEnum.MODIFY,
target=OperationTarget.SERVICE_DISCOVERY,
data_before=data_before,
data_after=DataDetail(type=DataType.RAW_DATA, data=data),
)
return Response(data, status=status.HTTP_200_OK)
Expand All @@ -303,6 +308,10 @@ def retrieve(self, request, code):
@swagger_auto_schema(responses={200: DomainResolutionSLZ()}, request_body=DomainResolutionSLZ)
def upsert(self, request, code):
application = self.get_application()
domain_resolution = DomainResolution.objects.filter(application_id=application.id).first()
data_before = None
if domain_resolution:
data_before = DataDetail(type=DataType.RAW_DATA, data=DomainResolutionSLZ(domain_resolution).data)

slz = DomainResolutionSLZ(data=request.data)
slz.is_valid(raise_exception=True)
Expand All @@ -329,6 +338,7 @@ def upsert(self, request, code):
action_id=AppAction.BASIC_DEVELOP,
operation=OperationEnum.CREATE if created else OperationEnum.MODIFY,
target=OperationTarget.DOMAIN_RESOLUTION,
data_before=data_before,
data_after=DataDetail(type=DataType.RAW_DATA, data=data),
)
return Response(data, status=status.HTTP_200_OK)