lib/terraformer/terraform.rb in terraform-exporter-0.0.2 vs lib/terraformer/terraform.rb in terraform-exporter-0.0.3
- old
+ new
@@ -28,17 +28,16 @@
def tfstate(generated_tfstate, tfstate_path)
unless tfstate_path.nil?
if File.file?(tfstate_path)
tfstate = parse_json_file(tfstate_path)
else
- puts "[ERROR] File not found while trying to merge state file with: #{tfstate_path}."
- raise TerraformFileNotFound
+ raise TerraformFileNotFound, "File not found while trying to merge state file with: #{tfstate_path}."
end
else
tfstate_path = "terraform.tfstate"
if File.file?(tfstate_path)
- UserInput.ask("File: #{tfstate_path} already exists. Overwrite?", "Y", "n")
+ UserInput.ask("File: #{tfstate_path} already exists and the 'merge' option was not passed. Overwrite?", "Y", "n")
end
tfstate = tfstate_skeleton
end
tfstate["serial"] = tfstate["serial"] + 1
@@ -53,11 +52,10 @@
def parse_json_file(file_path)
file_content = File.read(file_path)
JSON.parse(file_content)
rescue JSON::ParserError
- puts "[ERROR] Unable to parse: #{file_path}."
- raise TerraformInvalidTfstateFile
+ raise TerraformInvalidTfstateFile, "Unable to parse: #{file_path}."
end
def tfstate_skeleton
{
"version" => 3,