Skip to content

Commit

Permalink
fix expansion for the case of ENV var is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
pvshewale committed Apr 19, 2023
1 parent 0a5a212 commit 47f0cb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/terraspace/plugin/expander/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def var_value(unexpanded)
elsif !ENV[name].blank?
return ENV[name]
else
return unexpanded
return ''
end
if downcase == "namespace" && Terraspace.config.layering.enable_names.expansion
value = friendly_name(value)
Expand Down
6 changes: 4 additions & 2 deletions spec/terraspace/provider/expander/generic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let(:props) do
{
bucket: "my-bucket",
key: ":env/:build_dir/terraform.tfstate", # variable notation expanded by terraspace
key: ":env/:TEAM/:ENVNOTSET/:build_dir/terraform.tfstate", # variable notation expanded by terraspace
region: "us-west-2",
encrypt: true,
dynamodb_table: "terraform_locks"
Expand All @@ -15,12 +15,14 @@
mod
end

before { stub_const('ENV', {'TEAM' => 'backend'}) }

context "default path" do
it "expand" do
result = expander.expand(props)
expect(result).to eq({
bucket: "my-bucket",
key: "dev/stacks/core/terraform.tfstate",
key: "dev/backend/stacks/core/terraform.tfstate",
region: "us-west-2",
encrypt: true,
dynamodb_table: "terraform_locks"
Expand Down

0 comments on commit 47f0cb3

Please sign in to comment.