lib/terragov/buildpaths.rb in terragov-0.2.5.1 vs lib/terragov/buildpaths.rb in terragov-0.2.5.2
- old
+ new
@@ -37,23 +37,15 @@
stack_project_data: stack_project_data,
secret_project_data: secret_project_data
}
end
- def data_validation(path, required = false)
- if required
- if File.exist?(path)
- true
- else
- abort("Invalid directory or file: #{path}")
- end
+ def data_validation(path)
+ if File.exist?(path)
+ true
else
- if File.exist?(path)
- true
- else
- false
- end
+ false
end
end
def data_paths(options = {})
# The path order is important for passing the var files in the correct
@@ -86,12 +78,14 @@
end
end
def build_command(options = {})
paths = base(options)
- abort('Cannot find main repository') unless data_validation(paths[:terraform_dir], true)
+ abort("Error: cannot find main repository (#{paths[:terraform_dir]})") unless data_validation(paths[:terraform_dir])
+ abort("Error: cannot find project (#{paths[:project_dir]}).") unless data_validation(paths[:project_dir])
+ abort("Error: cannot find backend file (#{paths[:backend_file]}).\nDid you specify the right stack?") unless data_validation(paths[:backend_file])
var_paths = data_paths(options)
- abort("Can't find any var files") unless check_var_files(var_paths)
+ abort("Error: cannot find any var files") unless check_var_files(var_paths)
$full_vars = []
data_paths(options).each do |path|
if data_validation(path)
# TODO: write sops class