Skip to content
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

fix home directory config not loading #1282

Merged
merged 3 commits into from Jun 16, 2021

Conversation

@timecode
Copy link
Contributor

@timecode timecode commented Nov 25, 2020

Issue

The provision to use the convention of an extension-less config file from the user's home directory does not work as expected. The dependency being used to load the config file, viper, requires explicit knowledge of the "type" of the file, as it cannot deduce the implicit type from the file extension. Without knowledge of the file's "type", viper simply defaults to a "type" of "", which results in no attempt being made to load the file.

Solution

Specify the config type when specifying the extension-less config file name.

For example:

viper.SetConfigName(".cobra")
viper.SetConfigType("yaml")

Fix

This fix adds an explicit viper.SetConfigType() call at points referencing the typically extension-less config file

@CLAassistant
Copy link

@CLAassistant CLAassistant commented Nov 25, 2020

CLA assistant check
All committers have signed the CLA.

@jharshman
Copy link
Collaborator

@jharshman jharshman commented Dec 18, 2020

@timecode , can you provide a failing test that your solution fixes?

@jharshman jharshman self-assigned this Dec 18, 2020
@timecode
Copy link
Contributor Author

@timecode timecode commented Dec 23, 2020

Hi @jharshman, test added :-)

@github-actions
Copy link

@github-actions github-actions bot commented Feb 22, 2021

This PR is being marked as stale due to a long period of inactivity

@timecode
Copy link
Contributor Author

@timecode timecode commented Feb 22, 2021

😢

@jharshman
Copy link
Collaborator

@jharshman jharshman commented Jun 14, 2021

@timecode, apologies for letting this go to stale. Additionally, not sure what I was thinking, but you can remove that test. This is just adding an additional method from the viper package. No need to test. But thanks for updating the .golden file.

@jharshman jharshman self-requested a review Jun 14, 2021
@jharshman jharshman merged commit 9a43267 into spf13:master Jun 16, 2021
8 checks passed
@jharshman
Copy link
Collaborator

@jharshman jharshman commented Jun 16, 2021

@timecode merged. Thank you for your contribution and patience.

@renovate renovate bot mentioned this pull request Jul 1, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants