Skip to content

Commit

Permalink
Merge pull request #975 from cderici/juju-config-dir-fix-2.9
Browse files Browse the repository at this point in the history
#975

#### Description

XDG_DATA_HOME is supposed to point to the parent directory for applications. We were incorrectly setting that as Juju config dir.

#### QA Steps

No operational logic changes. All CI tests need to pass.

#### Notes & Discussions

Thanks @jameinel for pointing this out!
  • Loading branch information
jujubot authored Oct 26, 2023
2 parents bed2be9 + 4be986a commit 1e341f7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions juju/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,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

0 comments on commit 1e341f7

Please sign in to comment.