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: do validate svc discovery redundantly #1729

Merged
merged 1 commit into from
Nov 14, 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from paas_wl.bk_app.cnative.specs.constants import ScalingPolicy
from paas_wl.bk_app.processes.serializers import MetricSpecSLZ
from paas_wl.workloads.autoscaling.constants import DEFAULT_METRICS
from paasng.platform.applications.models import Application
from paasng.platform.bkapp_model.constants import PORT_PLACEHOLDER, ExposedTypeName, NetworkProtocol
from paasng.platform.modules.constants import DeployHookType
from paasng.utils.dictx import get_items
Expand Down Expand Up @@ -296,19 +295,6 @@ def to_internal_value(self, data):
data = {"bk_app_code": data}
return super().to_internal_value(data)

def validate(self, attrs):
"""校验应用和模块存在,否则抛出异常"""
try:
application = Application.objects.get(code=attrs["bk_app_code"])
except Application.DoesNotExist:
raise serializers.ValidationError(_("应用{}不存在").format(attrs["bk_app_code"]))

# Check if module exists when the "module_name" is set
if module_name := attrs["module_name"]: # noqa: SIM102
if not application.modules.filter(name=module_name).exists():
raise serializers.ValidationError(_("模块{}不存在").format(module_name))
return attrs


BkSaaSList: TypeAlias = List[Dict[str, Optional[str]]]

Expand Down