From 644ff4a90c1d479add8fc272dadd8284244d4f8b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 2 Jun 2021 10:25:59 +0200 Subject: [PATCH] outposts: fix error when validating kubeconfig Signed-off-by: Jens Langhammer --- authentik/outposts/api/outpost_service_connections.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/authentik/outposts/api/outpost_service_connections.py b/authentik/outposts/api/outpost_service_connections.py index fdc28ca8b..8f2b04bd1 100644 --- a/authentik/outposts/api/outpost_service_connections.py +++ b/authentik/outposts/api/outpost_service_connections.py @@ -8,7 +8,7 @@ from kubernetes.config.config_exception import ConfigException from kubernetes.config.kube_config import load_kube_config_from_dict from rest_framework import mixins, serializers from rest_framework.decorators import action -from rest_framework.fields import BooleanField, CharField, SerializerMethodField +from rest_framework.fields import BooleanField, CharField, ReadOnlyField from rest_framework.request import Request from rest_framework.response import Response from rest_framework.serializers import ModelSerializer @@ -30,11 +30,7 @@ from authentik.outposts.models import ( class ServiceConnectionSerializer(ModelSerializer, MetaNameSerializer): """ServiceConnection Serializer""" - component = SerializerMethodField() - - def get_component(self, obj: OutpostServiceConnection) -> str: - """Get object component so that we know how to edit the object""" - return obj.component + component = ReadOnlyField() class Meta: @@ -122,7 +118,7 @@ class KubernetesServiceConnectionSerializer(ServiceConnectionSerializer): def validate_kubeconfig(self, kubeconfig): """Validate kubeconfig by attempting to load it""" if kubeconfig == {}: - if not self.validated_data["local"]: + if not self.initial_data["local"]: raise serializers.ValidationError( _( "You can only use an empty kubeconfig when connecting to a local cluster."