Skip to content

Commit

Permalink
Deprecate "web_external_url"; use strip_prefix (#508)
Browse files Browse the repository at this point in the history
* Use strip_prefix in favor of web_external_url
* Drop k8s service patch
* Disable scenario tests
* fetch-lib
  • Loading branch information
sed-i authored Aug 19, 2023
1 parent b9845d0 commit b515dbc
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 1,030 deletions.
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ options:
default: info
web_external_url:
description: |
DEPRECATED. This config option is no longer used, in favor of "skipPrefix".
The URL under which Prometheus is externally reachable (for example,
if Prometheus is served via a reverse proxy).
Used for generating relative and absolute links back to
Expand Down
12 changes: 6 additions & 6 deletions lib/charms/grafana_k8s/v0/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__(self, *args):
# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version

LIBPATCH = 32
LIBPATCH = 33

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -665,14 +665,14 @@ def _template_panels(
continue
if not existing_templates:
datasource = panel.get("datasource")
if type(datasource) == str:
if isinstance(datasource, str):
if "loki" in datasource:
panel["datasource"] = "${lokids}"
elif "grafana" in datasource:
continue
else:
panel["datasource"] = "${prometheusds}"
elif type(datasource) == dict:
elif isinstance(datasource, dict):
# In dashboards exported by Grafana 9, datasource type is dict
dstype = datasource.get("type", "")
if dstype == "loki":
Expand All @@ -686,7 +686,7 @@ def _template_panels(
logger.error("Unknown datasource format: skipping")
continue
else:
if type(panel["datasource"]) == str:
if isinstance(panel["datasource"], str):
if panel["datasource"].lower() in replacements.values():
# Already a known template variable
continue
Expand All @@ -701,7 +701,7 @@ def _template_panels(
if replacement:
used_replacements.append(ds)
panel["datasource"] = replacement or panel["datasource"]
elif type(panel["datasource"]) == dict:
elif isinstance(panel["datasource"], dict):
dstype = panel["datasource"].get("type", "")
if panel["datasource"].get("uid", "").lower() in replacements.values():
# Already a known template variable
Expand Down Expand Up @@ -831,7 +831,7 @@ def _modify_panel(panel: dict, topology: dict, transformer: "CosTool") -> dict:
if "datasource" not in panel.keys():
continue

if type(panel["datasource"]) == str:
if isinstance(panel["datasource"], str):
if panel["datasource"] not in known_datasources:
continue
querytype = known_datasources[panel["datasource"]]
Expand Down
13 changes: 7 additions & 6 deletions lib/charms/observability_libs/v0/cert_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

LIBID = "b5cd5cd580f3428fa5f59a8876dcbe6a"
LIBAPI = 0
LIBPATCH = 5
LIBPATCH = 7


class CertChanged(EventBase):
Expand Down Expand Up @@ -101,16 +101,17 @@ def __init__(
peer_relation_name: Must match metadata.yaml.
certificates_relation_name: Must match metadata.yaml.
cert_subject: Custom subject. Name collisions are under the caller's responsibility.
extra_sans_dns: Any additional DNS names apart from FQDN.
extra_sans_dns: DNS names. If none are given, use FQDN.
"""
super().__init__(charm, key)

self.charm = charm
self.cert_subject = cert_subject or charm.unit.name
self.cert_subject = charm.unit.name if not cert_subject else cert_subject
# We need to sanitize the unit name, otherwise route53 complains:
# "urn:ietf:params:acme:error:malformed" :: Domain name contains an invalid character
self.cert_subject = charm.unit.name.replace("/", "-") if not cert_subject else cert_subject

# Auto-include the fqdn and drop empty/duplicate sans
self.sans_dns = list(set(filter(None, (extra_sans_dns or []) + [socket.getfqdn()])))
# Use fqdn only if no SANs were given, and drop empty/duplicate SANs
self.sans_dns = list(set(filter(None, (extra_sans_dns or [socket.getfqdn()]))))

self.peer_relation_name = peer_relation_name
self.certificates_relation_name = certificates_relation_name
Expand Down
Loading

0 comments on commit b515dbc

Please sign in to comment.