From a3fccbdaff257c26f410b5fd0e53ffa3d787ed93 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 12 May 2021 20:36:18 +0200 Subject: [PATCH] outposts: add build_hash for docker image Signed-off-by: Jens Langhammer --- authentik/lib/default.yml | 1 + authentik/outposts/controllers/base.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/authentik/lib/default.yml b/authentik/lib/default.yml index 6f4aa46e8..24d3fcf2c 100644 --- a/authentik/lib/default.yml +++ b/authentik/lib/default.yml @@ -42,6 +42,7 @@ outposts: # Placeholders: # %(type)s: Outpost type; proxy, ldap, etc # %(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" authentik: diff --git a/authentik/outposts/controllers/base.py b/authentik/outposts/controllers/base.py index ef22b79d5..fe342cb0f 100644 --- a/authentik/outposts/controllers/base.py +++ b/authentik/outposts/controllers/base.py @@ -1,11 +1,12 @@ """Base Controller""" from dataclasses import dataclass +from os import environ from typing import Optional from structlog.stdlib import get_logger 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.sentry import SentryIgnoredException from authentik.outposts.models import Outpost, OutpostServiceConnection @@ -69,4 +70,8 @@ class BaseController: def get_container_image(self) -> str: """Get container image to use for this outpost""" 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, ""), + }