Skip to content

Commit

Permalink
fix: permissions in created files (#239)
Browse files Browse the repository at this point in the history
* fix: permissions in created files

* use g=r

* use new permissions

* fix lint

* fix umask command

* use os.umask() instead of subprocess.run

* fix lint
  • Loading branch information
lucabello authored Jan 22, 2025
1 parent ebda655 commit 5e618e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/grafana_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,21 @@ def __new__(cls, *args: Any, **kwargs: Dict[Any, Any]):

def __init__(self, *args):
super().__init__(*args)
os.umask(0o077)

# Property to facilitate centralized status update
self.status = CompoundStatus()

charm_root = self.charm_dir.absolute()
self.loki_rules_paths = RulesMapping(
# TODO how to inject topology only for this charm's own rules?
# FIXED: this is already handled by re-using the *Rules classes
# FIXED: this is already handled by reusing the *Rules classes
src=charm_root.joinpath(*LOKI_RULES_SRC_PATH.split("/")),
dest=charm_root.joinpath(*LOKI_RULES_DEST_PATH.split("/")),
)
self.metrics_rules_paths = RulesMapping(
# TODO how to inject topology only for this charm's own rules?
# FIXED: this is already handled by re-using the *Rules classes
# FIXED: this is already handled by reusing the *Rules classes
src=charm_root.joinpath(*METRICS_RULES_SRC_PATH.split("/")),
dest=charm_root.joinpath(*METRICS_RULES_DEST_PATH.split("/")),
)
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from unittest.mock import patch

import pytest


@pytest.fixture(autouse=True)
def patch_buffer_file_for_charm_tracing(tmp_path):
with patch(
"charms.tempo_coordinator_k8s.v0.charm_tracing.BUFFER_DEFAULT_CACHE_FILE_NAME",
str(tmp_path / "foo.json"),
):
yield

0 comments on commit 5e618e7

Please sign in to comment.