Skip to content
This repository was archived by the owner on Jul 8, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""Cloudflared charm service."""

import logging
import os
import pathlib
import re
import subprocess # nosec
Expand Down Expand Up @@ -129,6 +130,7 @@ def _reconcile(self, _: ops.EventBase) -> None:
config = {
"tunnel-token": tunnel_spec.tunnel_token,
"metrics-port": metrics_ports[instance],
**self._proxy_config(),
}
if all(charmed_cloudflared.get(key) == str(value) for key, value in config.items()):
continue
Expand All @@ -139,6 +141,18 @@ def _reconcile(self, _: ops.EventBase) -> None:
charmed_cloudflared.start(enable=True)
self.unit.status = ops.ActiveStatus()

def _proxy_config(self) -> dict[str, str]:
"""Get HTTP proxy related configurations from the juju model configuration.

Returns:
A dictionary of HTTP proxy related configurations.
"""
return {
"http-proxy": os.environ.get("JUJU_CHARM_HTTP_PROXY", ""),
"https-proxy": os.environ.get("JUJU_CHARM_HTTPS_PROXY", ""),
"no-proxy": os.environ.get("JUJU_CHARM_NO_PROXY", ""),
}

def _subprocess_run(self, cmd: list[str]) -> None:
"""Run a subprocess command.

Expand Down
Loading