Skip to content

Commit

Permalink
config: unify conflicting PRIVATE_SUBDIR definitions
Browse files Browse the repository at this point in the history
We had conflicting definitions of the same name PRIVATE_SUBDIR and
due to that some places using it in one or the other way from one
of the two sources.

Furthermore the definitions were different, once with and once without
a leading slash.

This commit unifies this to one place defining the string in just one way
(no leading slash) and adapts users that assumed differently.

Signed-off-by: Christian Ehrhardt <[email protected]>
  • Loading branch information
cpaelzer authored and renanrodrigo committed Sep 5, 2023
1 parent 4e7685f commit 72c6b4c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion uaclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
CONFIG_FIELD_ENVVAR_ALLOWLIST,
DEFAULT_CONFIG_FILE,
DEFAULT_DATA_DIR,
PRIVATE_SUBDIR,
)
from uaclient.files import notices, state_files
from uaclient.files.notices import Notice
from uaclient.yaml import safe_load

LOG = logging.getLogger(util.replace_top_level_logger_name(__name__))

PRIVATE_SUBDIR = "private"
MERGE_ID_KEY_MAP = {
"availableResources": "name",
"resourceEntitlements": "type",
Expand Down
6 changes: 3 additions & 3 deletions uaclient/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
UAC_RUN_PATH = "/run/ubuntu-advantage/"
DEFAULT_DATA_DIR = "/var/lib/ubuntu-advantage"
MACHINE_TOKEN_FILE = "machine-token.json"
PRIVATE_SUBDIR = "/private"
PRIVATE_SUBDIR = "private"
DEFAULT_PRIVATE_MACHINE_TOKEN_PATH = (
DEFAULT_DATA_DIR + PRIVATE_SUBDIR + "/" + MACHINE_TOKEN_FILE
DEFAULT_DATA_DIR + "/" + PRIVATE_SUBDIR + "/" + MACHINE_TOKEN_FILE
)
DEFAULT_PRIVATE_DATA_DIR = DEFAULT_DATA_DIR + PRIVATE_SUBDIR
DEFAULT_PRIVATE_DATA_DIR = DEFAULT_DATA_DIR + "/" + PRIVATE_SUBDIR
MESSAGES_SUBDIR = "/messages"
MESSAGES_DIR = DEFAULT_DATA_DIR + MESSAGES_SUBDIR
CANDIDATE_CACHE_PATH = UAC_RUN_PATH + "candidate-version"
Expand Down
2 changes: 1 addition & 1 deletion uaclient/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
):
file_name = defaults.MACHINE_TOKEN_FILE
self.private_file = UAFile(
file_name, directory + defaults.PRIVATE_SUBDIR
file_name, directory + "/" + defaults.PRIVATE_SUBDIR
)
self.public_file = UAFile(file_name, directory, False)
self.machine_token_overlay_path = machine_token_overlay_path
Expand Down
3 changes: 1 addition & 2 deletions uaclient/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

from uaclient import apt, exceptions, http, messages
from uaclient.config import (
PRIVATE_SUBDIR,
UA_CONFIGURABLE_KEYS,
VALID_UA_CONFIG_KEYS,
DataPath,
get_config_path,
parse_config,
)
from uaclient.conftest import FakeNotice
from uaclient.defaults import DEFAULT_CONFIG_FILE
from uaclient.defaults import DEFAULT_CONFIG_FILE, PRIVATE_SUBDIR
from uaclient.entitlements import valid_services
from uaclient.entitlements.entitlement_status import ApplicationStatus
from uaclient.files import notices
Expand Down

0 comments on commit 72c6b4c

Please sign in to comment.