Skip to content

Commit 6b8d9f2

Browse files
authored
fix(controller): pods ptypes request app permission error
1 parent 3ccb267 commit 6b8d9f2

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

rootfs/api/views.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -402,20 +402,20 @@ def post_save(self, config):
402402
raise DryccException(str(e)) from e
403403

404404

405-
class PodViewSet(BaseDryccViewSet):
405+
class PodViewSet(AppResourceViewSet):
406406
model = models.app.App
407407
serializer_class = serializers.PodSerializer
408408

409409
def list(self, *args, **kwargs):
410-
pods = self.get_object().list_pods(*args, **kwargs)
410+
pods = self.get_app().list_pods(*args, **kwargs)
411411
data = self.get_serializer(pods, many=True).data
412412
# fake out pagination for now
413413
pagination = {'results': data, 'count': len(data)}
414414
return Response(pagination, status=status.HTTP_200_OK)
415415

416416
def describe(self, *args, **kwargs):
417417
pod_name = kwargs["name"]
418-
data = self.get_object().describe_pod(pod_name)
418+
data = self.get_app().describe_pod(pod_name)
419419
if len(data) == 0:
420420
raise DryccException("this process not found")
421421
# fake out pagination for now
@@ -426,35 +426,32 @@ def delete(self, request, **kwargs):
426426
pod_names = request.data.get("pod_ids")
427427
pod_names = pod_names.split(",")
428428
for pod_name in set(pod_names):
429-
delete_pod.delay(self.get_object(), **{"pod_name": pod_name})
429+
delete_pod.delay(self.get_app(), **{"pod_name": pod_name})
430430
return Response(status=status.HTTP_200_OK)
431431

432432

433-
class PtypesViewSet(BaseDryccViewSet):
433+
class PtypesViewSet(AppResourceViewSet):
434434
model = models.app.App
435435
serializer_class = serializers.PtypesSerializer
436436

437-
def get_queryset(self, *args, **kwargs):
438-
return self.model.objects.all(*args, **kwargs)
439-
440437
def list(self, *args, **kwargs):
441-
deploys = self.get_object().list_deployments(*args, **kwargs)
438+
deploys = self.get_app().list_deployments(*args, **kwargs)
442439
data = self.get_serializer(deploys, many=True).data
443440
# fake out pagination for now
444441
pagination = {'results': data, 'count': len(data)}
445442
return Response(pagination, status=status.HTTP_200_OK)
446443

447444
def describe(self, *args, **kwargs):
448445
deployment_name = kwargs["name"]
449-
data = self.get_object().describe_deployment(deployment_name)
446+
data = self.get_app().describe_deployment(deployment_name)
450447
if len(data) == 0:
451448
raise DryccException("this ptype not found")
452449
# fake out pagination for now
453450
pagination = {'results': data, 'count': len(data)}
454451
return Response(pagination, status=status.HTTP_200_OK)
455452

456453
def restart(self, request, *args, **kwargs):
457-
app = self.get_object()
454+
app = self.get_app()
458455
ptypes = []
459456
types = request.data.get("types", "").split(",")
460457
types = [ptype for ptype in set(types) if ptype != ""]
@@ -472,7 +469,7 @@ def restart(self, request, *args, **kwargs):
472469
return Response(status=status.HTTP_204_NO_CONTENT)
473470

474471
def scale(self, request, **kwargs):
475-
app = self.get_object()
472+
app = self.get_app()
476473
latest_release = app.release_set.filter(failed=False).latest()
477474
if latest_release.build is not None and latest_release.state == "created":
478475
raise DryccException('There is an executing pipeline, please wait')

0 commit comments

Comments
 (0)