Skip to content

Commit

Permalink
[MISC] update wrapper methods context
Browse files Browse the repository at this point in the history
  * Update the wrapper methods context to the wrapped method.
  * Increase libpatch

Signed-off-by: Guillaume Boutry <[email protected]>
  • Loading branch information
gboutry committed Sep 10, 2024
1 parent f43364e commit 1accd1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/charms/data_platform_libs/v0/data_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent):
"""

import copy
import functools
import json
import logging
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -331,7 +332,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 39
LIBPATCH = 40

PYDEPS = ["ops>=2.0.0"]

Expand Down Expand Up @@ -492,12 +493,13 @@ def wrapper(self, *args, **kwargs):
return f(self, *args, **kwargs)

wrapper.leader_only = True
return wrapper
return functools.wraps(f)(wrapper)


def juju_secrets_only(f):
"""Decorator to ensure that certain operations would be only executed on Juju3."""

@functools.wraps(f)
def wrapper(self, *args, **kwargs):
if not self.secrets_enabled:
raise SecretsUnavailableError("Secrets unavailable on current Juju version")
Expand All @@ -509,6 +511,7 @@ def wrapper(self, *args, **kwargs):
def dynamic_secrets_only(f):
"""Decorator to ensure that certain operations would be only executed when NO static secrets are defined."""

@functools.wraps(f)
def wrapper(self, *args, **kwargs):
if self.static_secret_fields:
raise IllegalOperationError(
Expand All @@ -522,6 +525,7 @@ def wrapper(self, *args, **kwargs):
def either_static_or_dynamic_secrets(f):
"""Decorator to ensure that static and dynamic secrets won't be used in parallel."""

@functools.wraps(f)
def wrapper(self, *args, **kwargs):
if self.static_secret_fields and set(self.current_secret_fields) - set(
self.static_secret_fields
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def fetch_old_versions():
for commit in last_commits:
check_call(f"git checkout {commit}", shell=True)
version = check_output(
"grep LIBPATCH lib/charms/data_platform_libs/v0/data_interfaces.py | cut -d ' ' -f 3",
"grep ^LIBPATCH lib/charms/data_platform_libs/v0/data_interfaces.py | cut -d ' ' -f 3",
shell=True,
universal_newlines=True,
)
Expand Down

0 comments on commit 1accd1d

Please sign in to comment.