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

dotenv support #189

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/templates/base/project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ terraform.tfvars
# Common ruby files
*.gem
*.rbc
.env*
.idea
/.bundle
/.config
Expand Down
1 change: 1 addition & 0 deletions lib/terraspace/booter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Terraspace
module Booter
def boot
Dotenv.new.load!
run_hooks
Terraspace::Bundle.require # load plugins
load_plugin_default_configs
Expand Down
25 changes: 25 additions & 0 deletions lib/terraspace/dotenv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'dotenv'

module Terraspace
class Dotenv
def load!
::Dotenv.load(*files)
end

# dotenv files with the following precedence:
#
# - .env.dev.local - Highest precedence
# - .env.dev
# - .env.local
# - .env - Lowest precedence
#
def files
[
".env.#{Terraspace.env}.local",
".env.#{Terraspace.env}",
".env.local",
".env",
].compact
end
end
end
1 change: 1 addition & 0 deletions terraspace.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "bundler"
spec.add_dependency "cli-format"
spec.add_dependency "deep_merge"
spec.add_dependency "dotenv"
spec.add_dependency "dsl_evaluator"
spec.add_dependency "eventmachine-tail"
spec.add_dependency "graph"
Expand Down