delete embedded outpost if it is disabled
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
d28c58adca
commit
e14f1e2cfb
|
@ -3,6 +3,7 @@ from prometheus_client import Gauge
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.blueprints.apps import ManagedAppConfig
|
from authentik.blueprints.apps import ManagedAppConfig
|
||||||
|
from authentik.lib.config import CONFIG
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
@ -39,22 +40,25 @@ class AuthentikOutpostConfig(ManagedAppConfig):
|
||||||
OutpostType,
|
OutpostType,
|
||||||
)
|
)
|
||||||
|
|
||||||
outpost, updated = Outpost.objects.update_or_create(
|
if CONFIG.get_bool("outposts.disable_embedded_outpost", False):
|
||||||
defaults={
|
outpost, updated = Outpost.objects.update_or_create(
|
||||||
"name": "authentik Embedded Outpost",
|
defaults={
|
||||||
"type": OutpostType.PROXY,
|
"name": "authentik Embedded Outpost",
|
||||||
},
|
"type": OutpostType.PROXY,
|
||||||
managed=MANAGED_OUTPOST,
|
},
|
||||||
)
|
managed=MANAGED_OUTPOST,
|
||||||
if updated:
|
|
||||||
if KubernetesServiceConnection.objects.exists():
|
|
||||||
outpost.service_connection = KubernetesServiceConnection.objects.first()
|
|
||||||
elif DockerServiceConnection.objects.exists():
|
|
||||||
outpost.service_connection = DockerServiceConnection.objects.first()
|
|
||||||
outpost.config = OutpostConfig(
|
|
||||||
kubernetes_disabled_components=[
|
|
||||||
"deployment",
|
|
||||||
"secret",
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
outpost.save()
|
if updated:
|
||||||
|
if KubernetesServiceConnection.objects.exists():
|
||||||
|
outpost.service_connection = KubernetesServiceConnection.objects.first()
|
||||||
|
elif DockerServiceConnection.objects.exists():
|
||||||
|
outpost.service_connection = DockerServiceConnection.objects.first()
|
||||||
|
outpost.config = OutpostConfig(
|
||||||
|
kubernetes_disabled_components=[
|
||||||
|
"deployment",
|
||||||
|
"secret",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
outpost.save()
|
||||||
|
else:
|
||||||
|
Outpost.objects.delete(managed=MANAGED_OUTPOST)
|
||||||
|
|
Reference in New Issue