Closed fabianofranz closed 5 years ago
@jtopjian PTAL
@fabianofranz Thank you for submitting this.
I understand the use-case and you raise a really good point. Taking this a step further, if someone wanted to do further customizations, then additional callbacks would be required. So I've broke this down into two main ideas:
I created a solution here which should work: https://github.com/gophercloud/utils/compare/master...jtopjian:loadyaml-refactor
There's a unit test that provides an example of how this can be used. And since the other unit tests pass, this confirms this change is also backwards compatible.
There is one caveat: I have not provided a way to override the GetCloudFromYAML
or AuthOptions
functions. There is way too much logic and internal/private functions being used to make sense to allow someone to override, IMO.
Let me know what you think and/or if you have any questions.
@jtopjian right, customizing the YAML loading logic would be my next need, so thanks for doing this! I believe that file loading is the place where most use cases for customization would exist, so no problem with leaving GetCloudFromYAML
out.
LGTM
@fabianofranz Sounds good. I've merged #93 with this functionality. I'm going to close this PR but please let me know if you have any questions.
Thanks again for raising this topic!
Cloud configs can be loaded from several files (cloud.yaml, clouds-public.yaml, secure.yaml) in a number of different locations (user's config dir, host config dir, current dir, a dir specified by an env var), and there's no way for users of the
clientconfig
packages to know which one(s) were actually used after callingGetCloudFromYAML
.This PR introduces the ability to call it by providing a callback function that receives the full path to the file(s) loaded. An example use case would be to log the path as
info
ordebug
log levels inside the callback function, so that end users could use it for debugging purposes.No API changes, all existing exported functions were kept as is.