Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added Viper configuration (#31) #75

Merged
merged 16 commits into from
Jul 29, 2022
Merged

Conversation

vmarchese
Copy link
Contributor

I have made the following changes to Close #31 :

  • Added viper support with the following ways in order of precedence:
    • command line flags
    • environment variables
    • configuration files
  • The error in the viper.BindPFlag now bubbles up to the main so I had to change the new<command> signature
  • Added a doc.go file in the root folder to have a general documentation in the godoc
  • Added a generic test in cmd/gremlins_test.go to check the correct order of precedence for cfg files and env vars
  • updated docs to reflect the changes

The configuration file is a YAML file structured as follows:

<command>:
   <flag name>: <flag value>
   <flag name>: <flag value>
   ...

For the current command (i.e. unleash) is trivially:

unleash:
  dry-run: true
  tags: tag1,tag2,tag3

@pull-request-size pull-request-size bot added the s/L Size: Denotes a Pull Request that changes 100-499 lines label Jul 28, 2022
@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #75 (32a3427) into main (d86f93f) will increase coverage by 0.39%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
+ Coverage   86.38%   86.77%   +0.39%     
==========================================
  Files          10       11       +1     
  Lines         573      590      +17     
==========================================
+ Hits          495      512      +17     
  Misses         61       61              
  Partials       17       17              
Flag Coverage Δ
unittests 86.77% <100.00%> (+0.39%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/configuration/viper.go 100.00% <100.00%> (ø)

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 d86f93f...32a3427. Read the comment docs.

@k3rn31 k3rn31 force-pushed the issue-30-config branch from 6d73ef7 to 77471ee Compare July 28, 2022 14:57
@k3rn31 k3rn31 changed the title Added Viper configuration WIP Added Viper configuration Jul 28, 2022
@k3rn31 k3rn31 requested a review from giose86 July 28, 2022 15:44
@vmarchese vmarchese changed the title WIP Added Viper configuration Added Viper configuration (#31) Jul 28, 2022
@k3rn31 k3rn31 merged commit 0e22564 into go-gremlins:main Jul 29, 2022
@k3rn31 k3rn31 added the c/feature Category: An issue or PR related to a new feature label Jul 29, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
c/feature Category: An issue or PR related to a new feature s/L Size: Denotes a Pull Request that changes 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for a configuration file
2 participants