-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set BlockedStatus if
@
is not used when running `juju config AM con…
…fig_file=@FILE_NAME` (#284) * set app in BlockedStatus if @ is not used while running juju config * pin ruff * update charm_tracing.py lib * unping ruff * add example on how to use `config_file` config option
- Loading branch information
1 parent
618fefe
commit 4fdf682
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,12 @@ options: | |
default: "" | ||
description: > | ||
Alertmanager configuration file (yaml), with the exclusion of the templates section. | ||
Refer to https://www.prometheus.io/docs/alerting/latest/configuration/ for full details. | ||
To send the contents of a file to this configuration option, the symbol `@` must be used. | ||
Usage: `juju config alertmanager [email protected]` | ||
For more information on configuring the Alertmanager, refer to: | ||
https://www.prometheus.io/docs/alerting/latest/configuration/ | ||
templates_file: | ||
type: string | ||
default: "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,6 +351,15 @@ def _get_local_config(self) -> Optional[Tuple[Optional[dict], Optional[str]]]: | |
config = self.config["config_file"] | ||
if config: | ||
local_config = yaml.safe_load(cast(str, config)) | ||
|
||
# If `juju config` is executed like this `config_file=am.yaml` instead of | ||
# `[email protected]` local_config will be the string `am.yaml` instead | ||
# of its content (dict). | ||
if not isinstance(local_config, dict): | ||
msg = f"Unable to set config from file. Use juju config {self.unit.name} config_file=@FILENAME" | ||
logger.error(msg) | ||
raise ConfigUpdateFailure(msg) | ||
|
||
local_templates = cast(str, self.config["templates_file"]) or None | ||
return local_config, local_templates | ||
return None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
route: | ||
receiver: test_receiver | ||
group_by: | ||
- alertname | ||
group_wait: 1234s | ||
group_interval: 4321s | ||
repeat_interval: 1111h | ||
receivers: | ||
- name: test_receiver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters