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

Allow specifying config values as environment variables #80

Merged
merged 2 commits into from
Mar 20, 2018
Merged

Conversation

lkysow
Copy link
Member

@lkysow lkysow commented Mar 20, 2018

Fixes #38.

Builds off the great work by @psalaberria002 in #77.

psalaberria002 and others added 2 commits March 17, 2018 00:28
- added tests
- moved AutomaticEnv() call into the init() function of the server flag
so it's set when we run the tests. Before it was in main().
- Set SetTypeByDefaultValue to true so boolean flags can be specified as
env vars.

// Configure viper to accept env vars prefixed with ATLANTIS_ that can be
// used instead of flags.
s.Viper.SetEnvPrefix("ATLANTIS")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psalaberria002 I moved this in here so that I could test this functionality. I liked it better in main.go but the tests don't run through there so this is a compromise.

s.Viper.SetEnvPrefix("ATLANTIS")
s.Viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
s.Viper.AutomaticEnv()
s.Viper.SetTypeByDefaultValue(true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benefits of testing! Without this you can't set a boolean flag as an env var, ex. ATLANTIS_ALLOW_FORK_PRS=true won't work without this.

@codecov
Copy link

codecov bot commented Mar 20, 2018

Codecov Report

Merging #80 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #80   +/-   ##
=======================================
  Coverage   64.09%   64.09%           
=======================================
  Files          40       40           
  Lines        1916     1916           
=======================================
  Hits         1228     1228           
  Misses        626      626           
  Partials       62       62
Impacted Files Coverage Δ
cmd/server.go 75.92% <100%> (ø) ⬆️

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 c7c582c...c8f68e2. Read the comment docs.

@lkysow lkysow merged commit 9b80b0f into master Mar 20, 2018
@lkysow lkysow deleted the envvars branch March 20, 2018 19:19
@psalaberria002
Copy link
Contributor

Awesome

meringu pushed a commit to meringu/atlantis that referenced this pull request May 29, 2023
runatlantis#80)

* adding atlantis bootstrap mode to support getting started with atlantis for first time users

* removed unwanted confirm variable

* vendoring dependencies

* more vendoring

* more more and more vendoring

* comment about bootstrap package

* Proposed changes (runatlantis#84)

* reviewed all the comments

* removing required approval flag since we will default to false
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.

2 participants