Skip to content

Commit

Permalink
Merge pull request #976 from cderici/juju-config-dir-fix-3.x
Browse files Browse the repository at this point in the history
#976

#### Description

Forward port of #975 

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. There's one CI failure on the master branch about add manual machine ssh that's unrelated to this change, that one's aside, all the others need to be passing.
  • Loading branch information
jujubot authored Oct 26, 2023
2 parents 03332e6 + 49d3e86 commit 078f060
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 @@ -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

0 comments on commit 078f060

Please sign in to comment.