Skip to content

Commit

Permalink
Add input processing to Packer for shell interpolation
Browse files Browse the repository at this point in the history
Issue #88

* Added to_command_hash_elements to allow processing packers inputs.
* Now interpolation of shell commands will function as expected in packer.
* Leveraged mainly for generating aws keys in template to allow seemless role assumption for provisioners and builders.
  • Loading branch information
disaac committed Sep 14, 2019
1 parent 42f5440 commit a7784b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/covalence/core/entities/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def to_command_option
"#{name} = #{parse_input(value())}"
end

def to_command_hash_elements
return name, parse_input(value()).delete_prefix('"').delete_suffix('"')
end

private

def get_value(input)
Expand Down
4 changes: 2 additions & 2 deletions lib/covalence/core/entities/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def materialize_cmd_inputs(path)
File.open("#{path}/covalence-inputs.tfvars",'w') {|f| f.write(config)}
elsif type == "packer"
config = Hash.new
inputs.each do |name, input|
config[name] = input.value
inputs.values.map(&:to_command_hash_elements).each do |name, input|
config["#{name}"] = input
end
config_json = JSON.generate(config)
logger.info "path: #{path} module_path: #{module_path}\nStack inputs:\n\n#{config_json}"
Expand Down

0 comments on commit a7784b1

Please sign in to comment.