*: simplify extracting current version info
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		@ -1,6 +1,4 @@
 | 
			
		||||
"""authentik administration overview"""
 | 
			
		||||
from os import environ
 | 
			
		||||
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from drf_spectacular.utils import extend_schema
 | 
			
		||||
from packaging.version import parse
 | 
			
		||||
@ -10,7 +8,7 @@ from rest_framework.request import Request
 | 
			
		||||
from rest_framework.response import Response
 | 
			
		||||
from rest_framework.views import APIView
 | 
			
		||||
 | 
			
		||||
from authentik import ENV_GIT_HASH_KEY, __version__
 | 
			
		||||
from authentik import __version__, get_build_hash
 | 
			
		||||
from authentik.admin.tasks import VERSION_CACHE_KEY, update_latest_version
 | 
			
		||||
from authentik.core.api.utils import PassiveSerializer
 | 
			
		||||
 | 
			
		||||
@ -25,7 +23,7 @@ class VersionSerializer(PassiveSerializer):
 | 
			
		||||
 | 
			
		||||
    def get_build_hash(self, _) -> str:
 | 
			
		||||
        """Get build hash, if version is not latest or released"""
 | 
			
		||||
        return environ.get(ENV_GIT_HASH_KEY, "")
 | 
			
		||||
        return get_build_hash()
 | 
			
		||||
 | 
			
		||||
    def get_version_current(self, _) -> str:
 | 
			
		||||
        """Get current version"""
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
"""authentik admin tasks"""
 | 
			
		||||
import re
 | 
			
		||||
from os import environ
 | 
			
		||||
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.core.validators import URLValidator
 | 
			
		||||
@ -9,7 +8,7 @@ from prometheus_client import Info
 | 
			
		||||
from requests import RequestException
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
 | 
			
		||||
from authentik import ENV_GIT_HASH_KEY, __version__
 | 
			
		||||
from authentik import __version__, get_build_hash
 | 
			
		||||
from authentik.events.models import Event, EventAction, Notification
 | 
			
		||||
from authentik.events.monitored_tasks import (
 | 
			
		||||
    MonitoredTask,
 | 
			
		||||
@ -36,7 +35,7 @@ def _set_prom_info():
 | 
			
		||||
        {
 | 
			
		||||
            "version": __version__,
 | 
			
		||||
            "latest": cache.get(VERSION_CACHE_KEY, ""),
 | 
			
		||||
            "build_hash": environ.get(ENV_GIT_HASH_KEY, ""),
 | 
			
		||||
            "build_hash": get_build_hash(),
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user