From 32afa214fd566cf46923cb656c255291d0d91457 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:28:44 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20k8s=20token=20=E4=B8=8D=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=20(#9460)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/authentication/api/connection_token.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 8d3703ef2..41cce13f7 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -23,6 +23,7 @@ from orgs.mixins.api import RootOrgViewMixin from perms.models import ActionChoices from terminal.connect_methods import NativeClient, ConnectMethodUtil from terminal.models import EndpointRule +from assets.const import CloudTypes from ..models import ConnectionToken from ..serializers import ( ConnectionTokenSerializer, ConnectionTokenSecretSerializer, @@ -340,6 +341,11 @@ class SuperConnectionTokenViewSet(ConnectionTokenViewSet): token.is_valid() serializer = self.get_serializer(instance=token) expire_now = request.data.get('expire_now', True) + + # TODO 暂时特殊处理 k8s 不过期 + if token.asset.type == CloudTypes.K8S: + expire_now = False + if expire_now: token.expire() return Response(serializer.data, status=status.HTTP_200_OK)