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 cost.enabled setting when nil #249

Merged
merged 1 commit into from
Jul 13, 2022
Merged
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
6 changes: 3 additions & 3 deletions lib/terraspace/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def defaults
config.cloud.record = "changes" # IE: changes or all
config.cloud.stack = ":APP-:ROLE-:MOD_NAME-:ENV-:EXTRA-:REGION"
config.cloud.cost = ActiveSupport::OrderedOptions.new
config.cloud.cost.enabled = cast_value(ENV['TS_COST'])
config.cloud.cost.enabled = cast_boolean(ENV['TS_COST'])
config.cloud.vcs = ActiveSupport::OrderedOptions.new
config.cloud.vcs.name = nil # github, gitlab, bitbucket. Else default to registered terraspace_vcs_* plugin

Expand Down Expand Up @@ -102,8 +102,8 @@ def defaults
# https://stackoverflow.com/questions/36228873/ruby-how-to-convert-a-string-to-boolean
# https://github.com/rails/rails/blob/5-1-stable/activemodel/lib/active_model/type/boolean.rb
# so dont have to add activemodel as a dependency just for this method
FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
def cast_value(value)
FALSE_VALUES = [nil, false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
def cast_boolean(value)
if value == ""
nil
else
Expand Down