Skip to content

Commit

Permalink
feat: disable wip-provider-pacts in production until the feature is p…
Browse files Browse the repository at this point in the history
…assed alpha testing
  • Loading branch information
bethesque committed Jul 8, 2018
1 parent 27860f4 commit 3f9a1c7
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 78 deletions.
5 changes: 4 additions & 1 deletion lib/pact_broker/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ module PactBroker
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'latest-untagged'], Api::Resources::LatestPact, {resource_name: "latest_untagged_pact_publication", tag: :untagged}
add ['pacts', 'provider', :provider_name, 'latest'], Api::Resources::LatestProviderPacts, {resource_name: "latest_provider_pact_publications"}
add ['pacts', 'provider', :provider_name, 'latest', :tag], Api::Resources::LatestProviderPacts, {resource_name: "latest_tagged_provider_pact_publications"}
add ['pacts', 'provider', :provider_name, 'wip'], Api::Resources::WipProviderPacts, {resource_name: "wip_provider_pact_publications"}
add ['pacts', 'latest'], Api::Resources::LatestPacts, {resource_name: "latest_pacts"}

if ENV['RACK_ENV'] != 'production'
add ['pacts', 'provider', :provider_name, 'wip'], Api::Resources::WipProviderPacts, {resource_name: "wip_provider_pact_publications"}
end

# Deprecated pact
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publications", deprecated: "true"} # Deprecate, singular /pact
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'latest'], Api::Resources::LatestPact, {resource_name: "latest_pact_publications", deprecated: "true"}
Expand Down
158 changes: 81 additions & 77 deletions lib/pact_broker/api/resources/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,84 +16,88 @@ def allowed_methods
end

def to_json
{ _links: links }.to_json
end

def links
{
_links: {
'self' =>
{
href: base_url,
title: 'Index',
templated: false
},
'pb:publish-pact' => {
href: base_url + '/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}',
title: 'Publish a pact',
templated: true
},
'pb:latest-pact-versions' =>
{
href: base_url + '/pacts/latest',
title: 'Latest pact versions',
templated: false
},
'pb:pacticipants' =>
{
href: base_url + '/pacticipants',
title: 'Pacticipants',
templated: false
},
'pb:latest-provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}/latest',
title: 'Latest pacts by provider',
templated: true
},
'pb:latest-provider-pacts-with-tag' =>
{
href: base_url + '/pacts/provider/{provider}/latest/{tag}',
title: 'Latest pacts for provider with the specified tag',
templated: true
},
'pb:provider-pacts-with-tag' =>
{
href: base_url + '/pacts/provider/{provider}/tag/{tag}',
title: 'All pact versions for the provider with the specified consumer version tag',
templated: true
},
'pb:provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}',
title: 'All pact versions for the specified provider',
templated: true
},
'pb:wip-provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}/wip',
title: 'WIP pact versions for the specified provider',
templated: true
},
'pb:latest-version' => {
href: base_url + '/pacticipants/{pacticipant}/latest-version',
title: 'Latest pacticipant version',
templated: true
},
'pb:latest-tagged-version' => {
href: base_url + '/pacticipants/{pacticipant}/latest-version/{tag}',
title: 'Latest pacticipant version with the specified tag',
templated: true
},
'pb:webhooks' => {
href: base_url + '/webhooks',
title: 'Webhooks',
templated: false
},
'curies' =>
[{
name: 'pb',
href: base_url + '/doc/{rel}?context=index',
templated: true
}]
}
}.to_json
'self' =>
{
href: base_url,
title: 'Index',
templated: false
},
'pb:publish-pact' => {
href: base_url + '/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}',
title: 'Publish a pact',
templated: true
},
'pb:latest-pact-versions' =>
{
href: base_url + '/pacts/latest',
title: 'Latest pact versions',
templated: false
},
'pb:pacticipants' =>
{
href: base_url + '/pacticipants',
title: 'Pacticipants',
templated: false
},
'pb:latest-provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}/latest',
title: 'Latest pacts by provider',
templated: true
},
'pb:latest-provider-pacts-with-tag' =>
{
href: base_url + '/pacts/provider/{provider}/latest/{tag}',
title: 'Latest pacts for provider with the specified tag',
templated: true
},
'pb:provider-pacts-with-tag' =>
{
href: base_url + '/pacts/provider/{provider}/tag/{tag}',
title: 'All pact versions for the provider with the specified consumer version tag',
templated: true
},
'pb:provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}',
title: 'All pact versions for the specified provider',
templated: true
},
'pb:wip-provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}/wip',
title: 'WIP pact versions for the specified provider',
templated: true
},
'pb:latest-version' => {
href: base_url + '/pacticipants/{pacticipant}/latest-version',
title: 'Latest pacticipant version',
templated: true
},
'pb:latest-tagged-version' => {
href: base_url + '/pacticipants/{pacticipant}/latest-version/{tag}',
title: 'Latest pacticipant version with the specified tag',
templated: true
},
'pb:webhooks' => {
href: base_url + '/webhooks',
title: 'Webhooks',
templated: false
},
'curies' =>
[{
name: 'pb',
href: base_url + '/doc/{rel}?context=index',
templated: true
}]
}.tap do | it |
it.delete('pb:wip-provider-pacts') if ENV['RACK_ENV'] == 'production'
end
end
end
end
Expand Down

0 comments on commit 3f9a1c7

Please sign in to comment.