ex-aws / ex_aws

A flexible, easy to use set of clients AWS APIs for Elixir
https://hex.pm/packages/ex_aws
MIT License
1.26k stars 521 forks source link

Credential loading doesn't respect XDG_CONFIG_HOME #932

Open pcapel opened 1 year ago

pcapel commented 1 year ago

Environment

Current behavior

Credentials are looked up in the home directory without respecting potential placement in XDG_CONFIG_HOME

Expected behavior

Specification compliance

I had set up some aliases a while back to get configuration where I expect it, since the cli compliance isn't quite there yet either. I should have remembered that, but definitely didn't! Took me a bit to figure out, but it wasn't too bad.

I'd say there are two enhancements that can be made here:

  1. Support searching in XDG_CONFIG/DATA_HOME for the required values
  2. Produce more appropriate errors/warnings surrounding the failure to locate expected files within directories

The primary issue is that the failure mode for an entry being missing is the same as the failure mode for not finding the configuration at all. Respecting the XDG spec isn't a huge deal to me personally, but it was a bit of a goose chase to figure out why things were failing when my configurations looked the same as a team mate's. Granted, I am the one who forgot about aliasing my config locations 😊 so that's on me!

I'd be happy to put in a little work to get a PR put together for one or both of the enhancements, depending on what is felt to be the best course for the project. I don't have a strong opinion personally as I'm relatively new to Elixir. I'd say that at the very least an error message that clearly delineates between a key not being set and the entire config file not being found is preferable to the current behavior.

Thanks for the project though! Works like a charm when I configure it correctly 😝

bernardd commented 1 year ago

Hi @pcapel - thanks for the report :) I'd be happy to consider PRs for both those things (as well as the crash on unset $HOME). XDG support isn't really on my radar at the moment, but if it can be done neatly without breaking anything else then I've got no objections to it.