Skip to content

Commit

Permalink
chore: update is_badge_url? with new badge path
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 4, 2022
1 parent 7ec6bc3 commit 595e035
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ def templated_can_i_deploy_badge_url pacticipant_name, base_url = ""
templated_can_i_deploy_url(pacticipant_name, base_url) + "/badge"
end

def templated_can_i_deploy_branch_to_environment_badge_url pacticipant_name, base_url = ""
pacticipant_url_from_params({ pacticipant_name: pacticipant_name }, base_url) + "/branches/{branch}/latest-version/can-i-deploy/to-environment/{environment}/badge"
end

def label_url label, base_url
"#{labels_url(label.pacticipant, base_url)}/#{url_encode(label.name)}"
end
Expand Down
5 changes: 3 additions & 2 deletions lib/pact_broker/api/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module Api
module Paths
PACT_BADGE_PATH = %r{^/pacts/provider/[^/]+/consumer/.*/badge(?:\.[A-Za-z]+)?$}.freeze
MATRIX_BADGE_PATH = %r{^/matrix/provider/[^/]+/latest/[^/]+/consumer/[^/]+/latest/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze
CAN_I_DEPLOY_BADGE_PATH = %r{^/pacticipants/[^/]+/latest-version/[^/]+/can-i-deploy/to/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze
CAN_I_DEPLOY_TAG_BADGE_PATH = %r{^/pacticipants/[^/]+/latest-version/[^/]+/can-i-deploy/to/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze
CAN_I_DEPLOY_BRANCH_ENV_BADGE_PATH = %r{^/pacticipants/[^/]+/branches/[^/]+/latest-version/can-i-deploy/to-environment/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze
VERIFICATION_RESULTS = %r{^/pacts/provider/[^/]+/consumer/[^/]+/pact-version/[^/]+/verification-results/[^/]+}

extend self
Expand All @@ -14,7 +15,7 @@ def is_verification_results_path?(path)

def is_badge_path?(path)
# Optimise by checking include? first - regexp slow
path.include?("/badge") && (path =~ PACT_BADGE_PATH || path =~ MATRIX_BADGE_PATH || path =~ CAN_I_DEPLOY_BADGE_PATH)
path.include?("/badge") && (path =~ PACT_BADGE_PATH || path =~ MATRIX_BADGE_PATH || path =~ CAN_I_DEPLOY_TAG_BADGE_PATH || path =~ CAN_I_DEPLOY_BRANCH_ENV_BADGE_PATH)
end
end
end
Expand Down

0 comments on commit 595e035

Please sign in to comment.