Skip to content

Support loading client config file from XDG_CONFIG_HOME #253

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

Open
wants to merge 3 commits into
base: python-3
Choose a base branch
from

Conversation

stephenfin
Copy link

It's a standard, and it stop us littering our home directory with yet another config file :)

A small bug is addressed where the path indicated by BEAKER_CLIENT_CONF does not exist is also addressed.

No functional changes yet: this is pure code motion.

Signed-off-by: Stephen Finucane <[email protected]>
Otherwise, this fails when we later attempt to access the file.

Signed-off-by: Stephen Finucane <[email protected]>
@stephenfin stephenfin changed the title Support loading files from XDG_CONFIG_HOME Support loading client config file from XDG_CONFIG_HOME Mar 4, 2025
if user_config_file:
if not os.path.exists(user_config_file):
sys.stderr.write(
"File at '%s' indicated by BEAKER_CLIENT_CONF does not exist"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%s parameter here is not used


# ~/.beaker
user_config_file = os.path.expanduser('~/.beaker')
if os.path.exists(user_config_file):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to check isfile instead of exists as it's passed to load_from_file

@JohnVillalovos JohnVillalovos requested a review from Copilot June 13, 2025 12:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates client configuration loading to follow XDG_CONFIG_HOME standards and deprecates legacy config paths, while also addressing a bug where BEAKER_CLIENT_CONF points to an unavailable file.

  • Introduces get_user_config_file to prioritize configuration from BEAKER_CLIENT_CONF, then XDG, and finally legacy paths with deprecation warnings.
  • Adds get_system_config_file to load the system-wide configuration file.
  • Adjusts initialization to use the updated configuration look-up functions.
Comments suppressed due to low confidence (1)

Client/src/bkr/client/init.py:29

  • [nitpick] Consider appending a newline to the error message for improved readability.
File at '%s' indicated by BEAKER_CLIENT_CONF does not exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants