Commit 90b49a88 authored by Rich's avatar Rich
Browse files

Update config schema to allow variables per code

parent 33791f33
......@@ -3,7 +3,7 @@
_gemname=terraform-wrapper
pkgname=ruby-${_gemname}
pkgver=1.0.3
pkgver=1.1.0
pkgrel=1
pkgdesc="A ruby wrapper for managing Terraform binaries and remote state."
arch=(any)
......
......@@ -75,15 +75,28 @@ module TerraformWrapper
logger.fatal("Invalid YAML in configuration file: #{@path}") unless yaml.kind_of?(Hash)
identifiers = yaml.key?("identifiers") ? yaml["identifiers"] : Hash.new
@variables = TerraformWrapper::Shared::Variables.new(config: @name, component: @code.name, service: @service, identifiers: identifiers)
@variables.add_variables(variables: yaml["globals"]) if yaml.key?("globals")
@variables = TerraformWrapper::Shared::Variables.new(config: @name, component: @code.name, service: @service, identifiers: identifiers)
if yaml.key?("globals") then
logger.fatal("Key 'globals' is not a hash in configuration file: #{@path}") unless yaml["globals"].kind_of?(Hash)
globals = yaml["globals"]
@variables.add_variables(variables: globals["variables"]) if globals.key?("variables")
end
if yaml.key?("terraform") then
logger.fatal("Key 'terraform' is not a hash in configuration file: #{@path}") unless yaml["terraform"].kind_of?(Hash)
terraform = yaml["terraform"]
@variables.add_variables(variables: terraform["variables"]) if terraform.key?("variables")
@variables.add_files(base: @base, files: terraform["files"]) if terraform.key?("files")
[ "globals", @code.name ].each do |extra|
if terraform.key?(extra) then
logger.fatal("Key '#{extra}' under 'terraform' is not a hash in configuration file: #{@path}") unless terraform[extra].kind_of?(Hash)
section = terraform[extra]
@variables.add_variables(variables: section["variables"]) if section.key?("variables")
@variables.add_files(base: @base, files: section["files"]) if section.key?("files")
end
end
end
@auths = Array.new
......
......@@ -34,7 +34,7 @@ module TerraformWrapper
def upgrade_task
desc "Upgrades the Terraform infrastructure component modules, providers and lock file."
task :upgrade => :binary do |t, args|
task :upgrade => [:binary, :clean] do |t, args|
runner = TerraformWrapper::Shared::Runner.new(binary: @binary, code: @code)
logger.info("Upgrading Terraform component: #{@code.name}...")
......
......@@ -4,7 +4,7 @@ module TerraformWrapper
###############################################################################
VERSION = "1.0.3"
VERSION = "1.1.0"
###############################################################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment