Skip to content

Commit

Permalink
[DPE-1316] external secrets in opensearch (on integration tests stabi…
Browse files Browse the repository at this point in the history
…lization) (#136)

## Issue


## Solution
  • Loading branch information
juditnovak authored Oct 20, 2023
1 parent e0ec52d commit 888070c
Show file tree
Hide file tree
Showing 9 changed files with 2,368 additions and 309 deletions.
1,016 changes: 920 additions & 96 deletions lib/charms/data_platform_libs/v0/data_interfaces.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/charms/opensearch/v0/opensearch_relation_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def validate_index_name(self, index_name: str) -> bool:
forbidden_chars = [" ", ",", ":", '"', "*", "+", "\\", "/", "|", "?", "#", ">", "<"]
if any([char in index_name for char in forbidden_chars]):
logger.error(
f"invalid index name {index_name} - index name includes one or more of the following forbidden characters: {forbidden_chars}"
f"invalid index name {index_name} - index name includes one or more of "
f"the following forbidden characters: {forbidden_chars}"
)
return False

Expand Down
8 changes: 7 additions & 1 deletion lib/charms/opensearch/v0/opensearch_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ def _on_secret_changed(self, event: SecretChangedEvent):
"""Refresh secret and re-run corresponding actions if needed."""
if not event.secret.label:
logger.info("Secret %s has no label, ignoring it.", event.secret.id)
return

try:
label_parts = self.breakdown_label(event.secret.label)
except ValueError:
logging.info(f"Label {event.secret.label} was meaningless for us, returning")
return

label_parts = self.breakdown_label(event.secret.label)
if (
label_parts["application_name"] != self._charm.app.name
or label_parts["scope"] != Scope.APP
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def juju_has_secrets(mocker: MockerFixture):
NOTE: This is needed, as normally JujuVersion is set to 0.0.0 in tests
(i.e. not the real juju version)
"""
juju_version = os.environ["LIBJUJU_VERSION_SPECIFIER"][:2] # Removing == symbol
juju_version = os.environ["LIBJUJU_VERSION_SPECIFIER"]
if juju_version.startswith("=="):
juju_version = juju_version[2:] # Removing == symbol

if juju_version < "3":
mocker.patch.object(
JujuVersion, "has_secrets", new_callable=PropertyMock
Expand Down
Loading

0 comments on commit 888070c

Please sign in to comment.