outposts: add build_hash for docker image

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-12 20:36:18 +02:00
parent bdf9f26d07
commit a3fccbdaff
2 changed files with 8 additions and 2 deletions

View File

@ -42,6 +42,7 @@ outposts:
# Placeholders: # Placeholders:
# %(type)s: Outpost type; proxy, ldap, etc # %(type)s: Outpost type; proxy, ldap, etc
# %(version)s: Current version; 2021.4.1 # %(version)s: Current version; 2021.4.1
# %(build_hash)s: Build hash if you're running a beta version
docker_image_base: "beryju/authentik-%(type)s:%(version)s" docker_image_base: "beryju/authentik-%(type)s:%(version)s"
authentik: authentik:

View File

@ -1,11 +1,12 @@
"""Base Controller""" """Base Controller"""
from dataclasses import dataclass from dataclasses import dataclass
from os import environ
from typing import Optional from typing import Optional
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
from structlog.testing import capture_logs from structlog.testing import capture_logs
from authentik import __version__ from authentik import ENV_GIT_HASH_KEY, __version__
from authentik.lib.config import CONFIG from authentik.lib.config import CONFIG
from authentik.lib.sentry import SentryIgnoredException from authentik.lib.sentry import SentryIgnoredException
from authentik.outposts.models import Outpost, OutpostServiceConnection from authentik.outposts.models import Outpost, OutpostServiceConnection
@ -69,4 +70,8 @@ class BaseController:
def get_container_image(self) -> str: def get_container_image(self) -> str:
"""Get container image to use for this outpost""" """Get container image to use for this outpost"""
image_name_template: str = CONFIG.y("outposts.docker_image_base") image_name_template: str = CONFIG.y("outposts.docker_image_base")
return image_name_template % {"type": self.outpost.type, "version": __version__} return image_name_template % {
"type": self.outpost.type,
"version": __version__,
"build_hash": environ.get(ENV_GIT_HASH_KEY, ""),
}