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: allow configuring flags with "-" as environment variables #441

Merged
merged 3 commits into from Apr 5, 2022
Merged

fix: allow configuring flags with "-" as environment variables #441

merged 3 commits into from Apr 5, 2022

Conversation

cfstras
Copy link
Contributor

@cfstras cfstras commented Mar 31, 2022

Dashes are not allowed in variable names in most shells. While you can work around this with env, this doesn't work when you want to export it as a global env var (because shells will also ignore env variables with dashes in them).

For example MOCKERY_DISABLE_VERSION_STRING.

So, this workaround works:

➜ env "MOCKERY_DISABLE-VERSION-STRING=true" mockery showconfig | grep versionstring
disableversionstring: true

But this doesn't:

➜ MOCKERY_DISABLE_VERSION_STRING=true mockery showconfig | grep versionstring
disableversionstring: false

After this fix, we can use it:

➜ MOCKERY_DISABLE_VERSION_STRING=true ./mockery showconfig | grep versionstring
disableversionstring: true

For example MOCKERY_DISABLE_VERSION_STRING
@LandonTClipp
Copy link
Contributor

Thanks for the find @cfstras , could you add a unit test to this? Once that's done we can merge.

@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2022

Codecov Report

Merging #441 (17abd96) into master (b11695e) will increase coverage by 0.65%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #441      +/-   ##
==========================================
+ Coverage   69.80%   70.46%   +0.65%     
==========================================
  Files           7        7              
  Lines        1262     1263       +1     
==========================================
+ Hits          881      890       +9     
+ Misses        333      320      -13     
- Partials       48       53       +5     
Impacted Files Coverage Δ
cmd/mockery.go 21.49% <100.00%> (+3.87%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b11695e...17abd96. Read the comment docs.

@cfstras
Copy link
Contributor Author

cfstras commented Apr 4, 2022

@LandonTClipp added one that covers all the config vars, and found an unused field in the process :)

@LandonTClipp LandonTClipp merged commit c943e69 into vektra:master Apr 5, 2022
@LandonTClipp
Copy link
Contributor

Thanks for the contribution @cfstras, getting it built now.

@cfstras cfstras deleted the fix/support-more-env-keys branch April 5, 2022 06:08
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.

None yet

3 participants