Skip to content

Commit 078f060

Browse files
authored
Merge pull request #976 from cderici/juju-config-dir-fix-3.x
#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.
2 parents 03332e6 + 49d3e86 commit 078f060

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

juju/utils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ def juju_config_dir():
4747
* ~/.local/share/juju
4848
4949
"""
50-
# Check $JUJU_DATA first
51-
config_dir = os.environ.get('JUJU_DATA', None)
50+
# Set it to ~/.local/share/juju as default
51+
config_dir = Path('~/.local/share/juju')
5252

53-
# Second option: $XDG_DATA_HOME for ~/.local/share
54-
if not config_dir:
55-
config_dir = os.environ.get('XDG_DATA_HOME', None)
53+
# Check $JUJU_DATA
54+
if juju_data := os.environ.get('JUJU_DATA'):
55+
config_dir = Path(juju_data)
56+
# Secondly check: $XDG_DATA_HOME for ~/.local/share
57+
elif xdg_data_home := os.environ.get('XDG_DATA_HOME'):
58+
config_dir = Path(xdg_data_home) / 'juju'
5659

57-
# Third option: just set it to ~/.local/share/juju
58-
if not config_dir:
59-
config_dir = '~/.local/share/juju'
60-
61-
return os.path.abspath(os.path.expanduser(config_dir))
60+
return str(config_dir.expanduser().resolve())
6261

6362

6463
def juju_ssh_key_paths():

0 commit comments

Comments
 (0)