Skip to content

Commit 3f9a1c7

Browse files
committed
feat: disable wip-provider-pacts in production until the feature is passed alpha testing
1 parent 27860f4 commit 3f9a1c7

File tree

2 files changed

+85
-78
lines changed

2 files changed

+85
-78
lines changed

lib/pact_broker/api.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ module PactBroker
3838
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'latest-untagged'], Api::Resources::LatestPact, {resource_name: "latest_untagged_pact_publication", tag: :untagged}
3939
add ['pacts', 'provider', :provider_name, 'latest'], Api::Resources::LatestProviderPacts, {resource_name: "latest_provider_pact_publications"}
4040
add ['pacts', 'provider', :provider_name, 'latest', :tag], Api::Resources::LatestProviderPacts, {resource_name: "latest_tagged_provider_pact_publications"}
41-
add ['pacts', 'provider', :provider_name, 'wip'], Api::Resources::WipProviderPacts, {resource_name: "wip_provider_pact_publications"}
4241
add ['pacts', 'latest'], Api::Resources::LatestPacts, {resource_name: "latest_pacts"}
4342

43+
if ENV['RACK_ENV'] != 'production'
44+
add ['pacts', 'provider', :provider_name, 'wip'], Api::Resources::WipProviderPacts, {resource_name: "wip_provider_pact_publications"}
45+
end
46+
4447
# Deprecated pact
4548
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publications", deprecated: "true"} # Deprecate, singular /pact
4649
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'latest'], Api::Resources::LatestPact, {resource_name: "latest_pact_publications", deprecated: "true"}

lib/pact_broker/api/resources/index.rb

+81-77
Original file line numberDiff line numberDiff line change
@@ -16,84 +16,88 @@ def allowed_methods
1616
end
1717

1818
def to_json
19+
{ _links: links }.to_json
20+
end
21+
22+
def links
1923
{
20-
_links: {
21-
'self' =>
22-
{
23-
href: base_url,
24-
title: 'Index',
25-
templated: false
26-
},
27-
'pb:publish-pact' => {
28-
href: base_url + '/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}',
29-
title: 'Publish a pact',
30-
templated: true
31-
},
32-
'pb:latest-pact-versions' =>
33-
{
34-
href: base_url + '/pacts/latest',
35-
title: 'Latest pact versions',
36-
templated: false
37-
},
38-
'pb:pacticipants' =>
39-
{
40-
href: base_url + '/pacticipants',
41-
title: 'Pacticipants',
42-
templated: false
43-
},
44-
'pb:latest-provider-pacts' =>
45-
{
46-
href: base_url + '/pacts/provider/{provider}/latest',
47-
title: 'Latest pacts by provider',
48-
templated: true
49-
},
50-
'pb:latest-provider-pacts-with-tag' =>
51-
{
52-
href: base_url + '/pacts/provider/{provider}/latest/{tag}',
53-
title: 'Latest pacts for provider with the specified tag',
54-
templated: true
55-
},
56-
'pb:provider-pacts-with-tag' =>
57-
{
58-
href: base_url + '/pacts/provider/{provider}/tag/{tag}',
59-
title: 'All pact versions for the provider with the specified consumer version tag',
60-
templated: true
61-
},
62-
'pb:provider-pacts' =>
63-
{
64-
href: base_url + '/pacts/provider/{provider}',
65-
title: 'All pact versions for the specified provider',
66-
templated: true
67-
},
68-
'pb:wip-provider-pacts' =>
69-
{
70-
href: base_url + '/pacts/provider/{provider}/wip',
71-
title: 'WIP pact versions for the specified provider',
72-
templated: true
73-
},
74-
'pb:latest-version' => {
75-
href: base_url + '/pacticipants/{pacticipant}/latest-version',
76-
title: 'Latest pacticipant version',
77-
templated: true
78-
},
79-
'pb:latest-tagged-version' => {
80-
href: base_url + '/pacticipants/{pacticipant}/latest-version/{tag}',
81-
title: 'Latest pacticipant version with the specified tag',
82-
templated: true
83-
},
84-
'pb:webhooks' => {
85-
href: base_url + '/webhooks',
86-
title: 'Webhooks',
87-
templated: false
88-
},
89-
'curies' =>
90-
[{
91-
name: 'pb',
92-
href: base_url + '/doc/{rel}?context=index',
93-
templated: true
94-
}]
95-
}
96-
}.to_json
24+
'self' =>
25+
{
26+
href: base_url,
27+
title: 'Index',
28+
templated: false
29+
},
30+
'pb:publish-pact' => {
31+
href: base_url + '/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}',
32+
title: 'Publish a pact',
33+
templated: true
34+
},
35+
'pb:latest-pact-versions' =>
36+
{
37+
href: base_url + '/pacts/latest',
38+
title: 'Latest pact versions',
39+
templated: false
40+
},
41+
'pb:pacticipants' =>
42+
{
43+
href: base_url + '/pacticipants',
44+
title: 'Pacticipants',
45+
templated: false
46+
},
47+
'pb:latest-provider-pacts' =>
48+
{
49+
href: base_url + '/pacts/provider/{provider}/latest',
50+
title: 'Latest pacts by provider',
51+
templated: true
52+
},
53+
'pb:latest-provider-pacts-with-tag' =>
54+
{
55+
href: base_url + '/pacts/provider/{provider}/latest/{tag}',
56+
title: 'Latest pacts for provider with the specified tag',
57+
templated: true
58+
},
59+
'pb:provider-pacts-with-tag' =>
60+
{
61+
href: base_url + '/pacts/provider/{provider}/tag/{tag}',
62+
title: 'All pact versions for the provider with the specified consumer version tag',
63+
templated: true
64+
},
65+
'pb:provider-pacts' =>
66+
{
67+
href: base_url + '/pacts/provider/{provider}',
68+
title: 'All pact versions for the specified provider',
69+
templated: true
70+
},
71+
'pb:wip-provider-pacts' =>
72+
{
73+
href: base_url + '/pacts/provider/{provider}/wip',
74+
title: 'WIP pact versions for the specified provider',
75+
templated: true
76+
},
77+
'pb:latest-version' => {
78+
href: base_url + '/pacticipants/{pacticipant}/latest-version',
79+
title: 'Latest pacticipant version',
80+
templated: true
81+
},
82+
'pb:latest-tagged-version' => {
83+
href: base_url + '/pacticipants/{pacticipant}/latest-version/{tag}',
84+
title: 'Latest pacticipant version with the specified tag',
85+
templated: true
86+
},
87+
'pb:webhooks' => {
88+
href: base_url + '/webhooks',
89+
title: 'Webhooks',
90+
templated: false
91+
},
92+
'curies' =>
93+
[{
94+
name: 'pb',
95+
href: base_url + '/doc/{rel}?context=index',
96+
templated: true
97+
}]
98+
}.tap do | it |
99+
it.delete('pb:wip-provider-pacts') if ENV['RACK_ENV'] == 'production'
100+
end
97101
end
98102
end
99103
end

0 commit comments

Comments
 (0)