lib/terraspace_bundler/mod/registry.rb in terraspace-bundler-0.2.0 vs lib/terraspace_bundler/mod/registry.rb in terraspace-bundler-0.3.0
- old
+ new
@@ -1,10 +1,12 @@
require 'net/http'
require 'open-uri'
class TerraspaceBundler::Mod
class Registry
+ include TB::Util::Logging
+
def initialize(source, version)
@source, @version = source, version
end
# Terrafile example
@@ -39,10 +41,11 @@
when 302
next_url = "#{base_site}#{resp.header["location"]}"
resp = http_request(next_url)
download_url = resp.header["x-terraform-get"]
else
- raise "Unable to lookup up module in Terraform Registry: #{resp}"
+ logger.error "ERROR: Unable to lookup up module in Terraform Registry: #{@source}".color(:red)
+ exit 1
end
url = download_url.sub(%r{/archive/.*},'')
# IE: git::https://github.com/terraform-aws-modules/terraform-aws-security-group?ref=v3.10.0
url.sub(/^git::/,'').sub(/\?.*/,'')