Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MISC] gboutry: update wrapper methods context #192

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading