Skip to content

Commit

Permalink
Fixes #388: Catch invalid/incorrect repo error during vagrant operati…
Browse files Browse the repository at this point in the history
…ons.
  • Loading branch information
seth-reeser committed Mar 2, 2016
1 parent 3c3d4a1 commit 9178089
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 3.43.0
version: 3.43.1
major:
description: "Catapult uses Semantic Versioning. During a MAJOR increment, incompatable API changes are made which require a manual upgrade path. Please follow these directions:"
notice: "NEW MAJOR VERSION OF CATAPULT AVAILABLE"
Expand Down
26 changes: 16 additions & 10 deletions catapult/catapult.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,10 @@ def Command::getSignatureKey(key, dateStamp, regionName, serviceName)
request = Net::HTTP::Get.new uri.request_uri
request.basic_auth "#{@configuration["company"]["bitbucket_username"]}", "#{@configuration["company"]["bitbucket_password"]}"
response = http.request request # Net::HTTPResponse object
if response.code.to_f.between?(399,600)
@api_bitbucket_repo_access = 500
if response.code.to_f == 404
catapult_exception("The Bitbucket repo #{instance["repo"]} does not exist")
elsif response.code.to_f.between?(399,600)
puts " - The Bitbucket API seems to be down, skipping... (this may impact provisioning and automated deployments)".color(Colors::RED)
else
api_bitbucket_repo_repositories = JSON.parse(response.body)
if response.code.to_f == 200
Expand All @@ -1032,8 +1034,10 @@ def Command::getSignatureKey(key, dateStamp, regionName, serviceName)
request = Net::HTTP::Get.new uri.request_uri
request.basic_auth "#{@configuration["company"]["bitbucket_username"]}", "#{@configuration["company"]["bitbucket_password"]}"
response = http.request request # Net::HTTPResponse object
if response.code.to_f.between?(399,600)
@api_bitbucket_repo_access = 500
if response.code.to_f == 404
catapult_exception("The Bitbucket repo #{instance["repo"]} does not exist")
elsif response.code.to_f.between?(399,600)
puts " - The Bitbucket API seems to be down, skipping... (this may impact provisioning and automated deployments)".color(Colors::RED)
else
api_bitbucket_repo_privileges = JSON.parse(response.body)
api_bitbucket_repo_privileges.each do |member|
Expand All @@ -1050,8 +1054,10 @@ def Command::getSignatureKey(key, dateStamp, regionName, serviceName)
request = Net::HTTP::Get.new uri.request_uri
request.basic_auth "#{@configuration["company"]["bitbucket_username"]}", "#{@configuration["company"]["bitbucket_password"]}"
response = http.request request # Net::HTTPResponse object
if response.code.to_f.between?(399,600)
@api_bitbucket_repo_access = 500
if response.code.to_f == 404
catapult_exception("The Bitbucket repo #{instance["repo"]} does not exist")
elsif response.code.to_f.between?(399,600)
puts " - The Bitbucket API seems to be down, skipping... (this may impact provisioning and automated deployments)".color(Colors::RED)
else
api_bitbucket_repo_group_privileges = JSON.parse(response.body)
api_bitbucket_repo_group_privileges.each do |group|
Expand All @@ -1065,9 +1071,7 @@ def Command::getSignatureKey(key, dateStamp, regionName, serviceName)
end
end
end
if @api_bitbucket_repo_access == 500
puts " - The Bitbucket API seems to be down, skipping... (this may impact provisioning and automated deployments)".color(Colors::RED)
elsif @api_bitbucket_repo_access === false
if @api_bitbucket_repo_access === false
catapult_exception("Your Bitbucket user #{@configuration["company"]["bitbucket_username"]} does not have write access to this repository.")
elsif @api_bitbucket_repo_access === true
puts " - Verified your Bitbucket user #{@configuration["company"]["bitbucket_username"]} has write access."
Expand All @@ -1079,7 +1083,9 @@ def Command::getSignatureKey(key, dateStamp, regionName, serviceName)
request = Net::HTTP::Get.new uri.request_uri
request.basic_auth "#{@configuration["company"]["github_username"]}", "#{@configuration["company"]["github_password"]}"
response = http.request request # Net::HTTPResponse object
if response.code.to_f.between?(399,600)
if response.code.to_f == 404
catapult_exception("The GitHub repo #{instance["repo"]} does not exist")
elsif response.code.to_f.between?(399,600)
puts " - The GitHub API seems to be down, skipping... (this may impact provisioning and automated deployments)".color(Colors::RED)
else
if response.code.to_f == 204
Expand Down

0 comments on commit 9178089

Please sign in to comment.