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 Aug 14, 2024
1 parent 5622362 commit e6844cc
Showing 1 changed file with 6 additions and 2 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

0 comments on commit e6844cc

Please sign in to comment.