Skip to content

Commit

Permalink
Always remove quotes from expression values
Browse files Browse the repository at this point in the history
  • Loading branch information
zzaakiirr committed Nov 12, 2024
1 parent 44bc927 commit d8d45ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/core/terraform_config/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def argument(name, value, optional: false, raw: false)
"#{tf_value(value)}\n"
end

# remove quotes from expression values
content = content.gsub(/("#{EXPRESSION_PATTERN}.*")/) { ::Regexp.last_match(1)[1...-1] }

put("#{name} = #{content}", indent: 2)
end

Expand Down Expand Up @@ -58,7 +61,6 @@ def tf_string_value(value)
def tf_hash_value(value)
JSON.pretty_generate(value.crush)
.gsub(/"(\w+)":/) { "#{::Regexp.last_match(1)}:" } # remove quotes from keys
.gsub(/("#{EXPRESSION_PATTERN}.*")/) { ::Regexp.last_match(1)[1...-1] } # remove quotes from expression values
end

def expression?(value)
Expand Down
2 changes: 1 addition & 1 deletion spec/core/terraform_config/gvc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
domain = "app.example.com"
locations = ["aws-us-east-1", "aws-us-east-2"]
pull_secrets = ["cpln_secret.docker.name"]
pull_secrets = [cpln_secret.docker.name]
env = {
var1 = "value"
var2 = 1
Expand Down

0 comments on commit d8d45ab

Please sign in to comment.