INNER CODE UNIT · Python
_normalize_cloudflared_image
ChrispyBacon-dev/DockFlare · dockflare-agent/app/main.py:30
def _normalize_cloudflared_image(raw_value, default_image):
"""Sanitize the configured cloudflared image reference."""
if not raw_value:
return default_image
candidate = raw_value.strip()
if not candidate:
logging.warning("CLOUDFLARED_IMAGE is blank after trimming; falling back to default %s", default_image)
return default_image
# Split on whitespace to drop inline comments or accidental extra tokens.
candidate = candidate.split()[0]
if "#" in candidate:
candidate = candidate.split("#", 1)[0].strip()
if not candidate:
logging.warning("CLOUDFLARED_IMAGE only contained a comment; falling back to default %s", default_image)
return default_image