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

Juju config directory location fix on 3.x #976

Merged
merged 4 commits into from
Oct 26, 2023
Merged
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
19 changes: 9 additions & 10 deletions juju/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,17 @@ def juju_config_dir():
* ~/.local/share/juju

"""
# Check $JUJU_DATA first
config_dir = os.environ.get('JUJU_DATA', None)
# Set it to ~/.local/share/juju as default
config_dir = Path('~/.local/share/juju')

# Second option: $XDG_DATA_HOME for ~/.local/share
if not config_dir:
config_dir = os.environ.get('XDG_DATA_HOME', None)
# Check $JUJU_DATA
if juju_data := os.environ.get('JUJU_DATA'):
config_dir = Path(juju_data)
# Secondly check: $XDG_DATA_HOME for ~/.local/share
elif xdg_data_home := os.environ.get('XDG_DATA_HOME'):
config_dir = Path(xdg_data_home) / 'juju'

# Third option: just set it to ~/.local/share/juju
if not config_dir:
config_dir = '~/.local/share/juju'

return os.path.abspath(os.path.expanduser(config_dir))
return str(config_dir.expanduser().resolve())


def juju_ssh_key_paths():
Expand Down
Loading