pact_broker 2.116.0 → 2.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/Gemfile +3 -4
  4. data/lib/pact_broker/api/contracts/dry_validation_errors_formatter.rb +3 -0
  5. data/lib/pact_broker/api/decorators/version_decorator.rb +3 -1
  6. data/lib/pact_broker/api/resources/index.rb +48 -0
  7. data/lib/pact_broker/api/resources/latest_provider_pacts_for_branch.rb +26 -0
  8. data/lib/pact_broker/api/resources/pact_versions_for_branch.rb +15 -1
  9. data/lib/pact_broker/api/resources/provider_pacts_for_consumer_branch.rb +47 -0
  10. data/lib/pact_broker/api/resources/provider_states.rb +9 -3
  11. data/lib/pact_broker/api.rb +9 -0
  12. data/lib/pact_broker/doc/views/index/branch-pact-versions.markdown +7 -0
  13. data/lib/pact_broker/doc/views/index/latest-branch-pact-versions.markdown +7 -0
  14. data/lib/pact_broker/doc/views/index/latest-main-branch-pact-versions.markdown +7 -0
  15. data/lib/pact_broker/doc/views/index/latest-provider-pacts-with-branch.markdown +7 -0
  16. data/lib/pact_broker/doc/views/index/latest-provider-pacts-with-main-branch.markdown +7 -0
  17. data/lib/pact_broker/doc/views/index/latest-provider-pacts-with-tag.markdown +3 -1
  18. data/lib/pact_broker/doc/views/index/main-branch-pact-versions.markdown +7 -0
  19. data/lib/pact_broker/doc/views/index/provider-pacts-with-branch.markdown +7 -0
  20. data/lib/pact_broker/doc/views/index/provider-pacts-with-main-branch.markdown +7 -0
  21. data/lib/pact_broker/doc/views/index/provider-pacts-with-tag.markdown +2 -0
  22. data/lib/pact_broker/doc/views/pact/provider-states.markdown +10 -3
  23. data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +8 -0
  24. data/lib/pact_broker/pacts/provider_state_service.rb +10 -2
  25. data/lib/pact_broker/pacts/repository.rb +30 -0
  26. data/lib/pact_broker/pacts/service.rb +20 -0
  27. data/lib/pact_broker/version.rb +1 -1
  28. data/pact_broker.gemspec +8 -4
  29. metadata +90 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b6fe2169fc6d5b3554dc0da5de9e5e73fddbb186fb56a0bede25809d7ef3254
4
- data.tar.gz: 5c0e050b04a5d478b46b016a8bda1eae907457c4d7dac7985ca6c8c1c4b25226
3
+ metadata.gz: 66a321653a387b5b79c1929494938563e608901abf69bdf97c99062e6b97570d
4
+ data.tar.gz: b3b33dee60c7a5cdf1ad8471929821ad4f5c8ee07c9c8e54d147c0cc590b7492
5
5
  SHA512:
6
- metadata.gz: 3fa91a39b55d0d3783e9ac6ce873bc1c2b88434409d6b64e49aff53747b1d776806fedf1342285741883bcf6aebe11e7bdca79fe91fc2ac1ec5fbe29d3fb4d31
7
- data.tar.gz: 6fc4a2ff15cfb1a0cda2b83d73317c0ff28b835c1bc1205c68ebfcea52428c619c5439c96ad35d2dcdfd06aeda670c2ebc4c8ad6bc4f7f68dd3d9e720712b67b
6
+ metadata.gz: afb8062161928832aa645ca3f9b611e7d5969a7ee23de3987f3c4eda24f0efe4bfd0a393894225ac1836e4da4bee4d05fe3d3ada1f898292e3269ca8259e8675
7
+ data.tar.gz: 80da5823d947745d6c165bd744693886e8e744f32bbe218bd2fe61b328b0bcd95712c8f7140cdc6ce73db6293e3c6ebfdb3ed5d229a704b6299c188806d95b9e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ <a name="v2.117.0"></a>
2
+ ### v2.117.0 (2025-10-28)
3
+
4
+ #### Features
5
+
6
+ * add provider pacts by branch endpoints ([0ccff2ec](/../../commit/0ccff2ec))
7
+ * PACT-4511/updated matrix decorator to return app instance for an env if present (#838) ([8bc24e72](/../../commit/8bc24e72))
8
+ * support provider states by branch/env ([f4db396f](/../../commit/f4db396f))
9
+
10
+ #### Bug Fixes
11
+
12
+ * update hal relations for provider pacts ([b6e8e8e3](/../../commit/b6e8e8e3))
13
+ * drop pact-support pin ([3c7eb4c5](/../../commit/3c7eb4c5))
14
+ * fixed the text fixtures (#826) ([28035c27](/../../commit/28035c27))
15
+
16
+ * **test**
17
+ * update expectation of webhook_certificates source format dependant on rb version ([5364c1b1](/../../commit/5364c1b1))
18
+
19
+ * **deps**
20
+ * add mutex_m/csv/ostruct/pstore ([075d2522](/../../commit/075d2522))
21
+
1
22
  <a name="v2.116.0"></a>
2
23
  ### v2.116.0 (2025-07-04)
3
24
 
data/Gemfile CHANGED
@@ -9,8 +9,7 @@ gem "conventional-changelog", "~>1.3"
9
9
  gem "bump", "~> 0.5"
10
10
  gem "padrino-core", ">= 0.16.0.pre3", require: false
11
11
  gem "rackup", "~> 2.2"
12
- # TODO: using release-candidate of pact-support is release remove this and restore to gemspec.
13
- gem "pact-support", github: "pact-foundation/pact-support", branch: "release-1.21.3.rc1"
12
+ gem "thor", "~> 1.4" # thor is secondary dependency but bumping here to avoid CVEs
14
13
 
15
14
  group :development do
16
15
  gem "pry-byebug"
@@ -35,11 +34,11 @@ group :test do
35
34
  gem "approvals", ">=0.0.24", "<1.0.0"
36
35
  gem "tzinfo", "~>2.0"
37
36
  gem "faraday-retry", "~>2.0"
38
- gem "openapi_first", "2.9.2" # pinned to specific version due to changelog volatility
37
+ gem "openapi_first", "~>2.0"
39
38
  end
40
39
 
41
40
  group :pg, optional: true do
42
- gem "pg", "~>1.2"
41
+ gem "pg", "~>1.6"
43
42
  end
44
43
 
45
44
  group :mysql, optional: true do
@@ -41,6 +41,9 @@ module PactBroker
41
41
  add_error(errors_hash, error.path.first, "#{error.path.last} #{error.text} (at index #{error.path[1]})")
42
42
  elsif error_path_classes == [Symbol, Integer]
43
43
  add_error(errors_hash, error.path.first, "#{error.text} (at index #{error.path[1]})")
44
+ elsif error_path_classes == [Symbol, Symbol, Integer]
45
+ # this should be refactored to dynamically handle patterns instead of hardcoding the patterns
46
+ add_error(errors_hash, error.path.first, "#{error.path[1]} #{error.text} (at index #{error.path[2]})")
44
47
  else
45
48
  # Don't have any usecases for this - will deal with it when it happens
46
49
  raise PactBroker::Error, "Cannot currently format an error message with path classes #{error_path_classes}"
@@ -83,7 +83,9 @@ module PactBroker
83
83
  name: deployed_version.environment.display_name,
84
84
  href: deployed_version_url(deployed_version, context.fetch(:base_url)),
85
85
  currently_deployed: deployed_version.currently_deployed
86
- }
86
+ }.tap do |hash|
87
+ hash[:application_instance] = deployed_version.application_instance unless deployed_version.application_instance.nil?
88
+ end
87
89
  end
88
90
  end
89
91
 
@@ -49,6 +49,54 @@ module PactBroker
49
49
  title: "All versions of a pact for a given consumer, provider and consumer version tag",
50
50
  templated: false
51
51
  },
52
+ "pb:branch-pact-versions" =>
53
+ {
54
+ href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}",
55
+ title: "All versions of pacts for a provider, for a named consumers branch",
56
+ templated: true
57
+ },
58
+ "pb:latest-branch-pact-versions" =>
59
+ {
60
+ href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest",
61
+ title: "Latest version of pact for a provider, for a named consumers branch",
62
+ templated: true
63
+ },
64
+ "pb:main-branch-pact-versions" =>
65
+ {
66
+ href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch",
67
+ title: "All versions of pacts for a provider, for a named consumers main branch",
68
+ templated: true
69
+ },
70
+ "pb:latest-main-branch-pact-versions" =>
71
+ {
72
+ href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/latest",
73
+ title: "Latest version of pact for a provider, for a named consumers main branch",
74
+ templated: true
75
+ },
76
+ "pb:provider-pacts-with-main-branch" =>
77
+ {
78
+ href: base_url + "/pacts/provider/{provider}/branch",
79
+ title: "All pacts for a provider, for any consumers main branch",
80
+ templated: true
81
+ },
82
+ "pb:provider-pacts-with-branch" =>
83
+ {
84
+ href: base_url + "/pacts/provider/{provider}/branch/{branch}",
85
+ title: "All pacts for a provider, for any consumers named branch",
86
+ templated: true
87
+ },
88
+ "pb:latest-provider-pacts-with-main-branch" =>
89
+ {
90
+ href: base_url + "/pacts/provider/{provider}/branch/latest",
91
+ title: "Latest pact for a provider, for any consumers main branch",
92
+ templated: true
93
+ },
94
+ "pb:latest-provider-pacts-with-branch" =>
95
+ {
96
+ href: base_url + "/pacts/provider/{provider}/branch/{branch}/latest",
97
+ title: "Latest pacts for a provider, for any consumers named branch",
98
+ templated: true
99
+ },
52
100
  "pb:pacticipants" =>
53
101
  {
54
102
  href: base_url + "/pacticipants",
@@ -0,0 +1,26 @@
1
+ require "pact_broker/api/resources/provider_pacts"
2
+ require "pact_broker/configuration"
3
+ require "pact_broker/api/decorators/provider_pacts_decorator"
4
+
5
+ module PactBroker
6
+ module Api
7
+ module Resources
8
+ class LatestProviderPactsForBranch < ProviderPacts
9
+ private
10
+
11
+ def pacts
12
+ pact_service.find_latest_pacts_for_provider_by_consumer_branch(
13
+ provider_name,
14
+ branch_name: identifier_from_path[:branch_name],
15
+ main_branch: identifier_from_path[:branch_name].nil?,
16
+ )
17
+ end
18
+
19
+ def resource_title
20
+ suffix = identifier_from_path[:branch_name] ? " with consumer version branch '#{identifier_from_path[:branch_name]}'" : ""
21
+ "Latest pact versions for the provider #{identifier_from_path[:provider_name]}#{suffix}#{!!identifier_from_path[:main_branch] ? ' for main branch' : ''}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -14,13 +14,27 @@ module PactBroker
14
14
  end
15
15
 
16
16
  def allowed_methods
17
- ["DELETE", "OPTIONS"]
17
+ ["GET", "DELETE", "OPTIONS"]
18
18
  end
19
19
 
20
20
  def resource_exists?
21
21
  consumer && provider
22
22
  end
23
23
 
24
+ def to_json
25
+ decorator_class(:pact_versions_decorator).new(pacts).to_json(**decorator_options(identifier_from_path))
26
+ end
27
+
28
+ def pacts
29
+ @pacts ||= pact_service.find_pacts_for_provider_and_consumer_by_consumer_branch(
30
+ provider_name,
31
+ consumer_name,
32
+ branch_name: identifier_from_path[:branch_name],
33
+ main_branch: identifier_from_path[:branch_name].nil?,
34
+ latest: identifier_from_path[:resource_name] == "latest_pact_publications_for_main_branch" || identifier_from_path[:resource_name] == "latest_pact_publications_for_branch"
35
+ )
36
+ end
37
+
24
38
  def delete_resource
25
39
  pact_service.delete_all_pact_publications_between consumer_name, and: provider_name, branch_name: identifier_from_path[:branch_name]
26
40
  set_post_deletion_response
@@ -0,0 +1,47 @@
1
+ require "pact_broker/api/resources/base_resource"
2
+ require "pact_broker/configuration"
3
+ require "pact_broker/api/decorators/provider_pacts_decorator"
4
+
5
+ module PactBroker
6
+ module Api
7
+ module Resources
8
+ class ProviderPactsForConsumerBranch < BaseResource
9
+
10
+ def content_types_provided
11
+ [["application/hal+json", :to_json]]
12
+ end
13
+
14
+ def allowed_methods
15
+ ["GET", "OPTIONS"]
16
+ end
17
+
18
+ def resource_exists?
19
+ !!provider
20
+ end
21
+
22
+ def policy_name
23
+ :'pacts::provider_pacts'
24
+ end
25
+
26
+ def to_json
27
+ decorator_class(:provider_pacts_decorator).new(pacts).to_json(**decorator_options(identifier_from_path.merge(title: resource_title)))
28
+ end
29
+
30
+ private
31
+
32
+ def pacts
33
+ pact_service.find_pacts_for_provider_by_consumer_branch(
34
+ provider_name,
35
+ branch_name: identifier_from_path[:branch_name],
36
+ main_branch: identifier_from_path[:branch_name].nil?,
37
+ )
38
+ end
39
+
40
+ def resource_title
41
+ suffix = identifier_from_path[:branch_name] ? " with consumer version branch '#{identifier_from_path[:branch_name]}'" : ""
42
+ "All pact versions for the provider #{identifier_from_path[:provider_name]}#{suffix}#{!!identifier_from_path[:main_branch] ? ' for main branch' : ''}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -25,12 +25,18 @@ module PactBroker
25
25
  :'pacts::pact'
26
26
  end
27
27
 
28
- private
28
+ def environment_uuid
29
+ identifier_from_path[:environment_uuid]
30
+ end
29
31
 
30
- # attr_reader :provider_states
32
+ def branch_name
33
+ identifier_from_path[:branch_name]
34
+ end
35
+
36
+ private
31
37
 
32
38
  def provider_states
33
- @provider_states ||= provider_state_service.list_provider_states(provider)
39
+ @provider_states ||= provider_state_service.list_provider_states(provider, branch_name, environment_uuid)
34
40
  end
35
41
  end
36
42
  end
@@ -33,6 +33,9 @@ module PactBroker
33
33
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "versions"], Api::Resources::PactVersions, {resource_name: "pact_publications"}
34
34
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "versions", :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publication", deprecated: true} # Not the standard URL, but keep for backwards compatibility
35
35
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "tag", :tag], Api::Resources::TaggedPactVersions, {resource_name: "tagged_pact_publications"}
36
+ add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch"], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_main_branch"}
37
+ add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", "latest"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_main_branch"}
38
+ add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name, "latest"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_branch"}
36
39
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_branch"}
37
40
 
38
41
  # Pacts
@@ -43,10 +46,16 @@ module PactBroker
43
46
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "version", :consumer_version_number, "diff", "previous-distinct"], Api::Resources::PactContentDiff, {resource_name: "previous_distinct_pact_version_diff"}
44
47
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "version", :consumer_version_number, "diff", "version", :comparison_consumer_version], Api::Resources::PactContentDiff, {resource_name: "pact_version_diff_by_consumer_version"}
45
48
  add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "pact-version", :pact_version_sha, "diff", "pact-version", :comparison_pact_version_sha], Api::Resources::PactContentDiff, {resource_name: "pact_version_diff_by_pact_version_sha"}
49
+ add ["pacts", "provider", :provider_name, "branch", "latest"], Api::Resources::LatestProviderPactsForBranch, {resource_name: "latest_main_branch_provider_pact_publications"}
50
+ add ["pacts", "provider", :provider_name, "branch", :branch_name, "latest"], Api::Resources::LatestProviderPactsForBranch, {resource_name: "latest_branch_provider_pact_publications"}
51
+ add ["pacts", "provider", :provider_name, "branch", :branch_name], Api::Resources::ProviderPactsForConsumerBranch, {resource_name: "branch_provider_pact_publications"}
52
+ add ["pacts", "provider", :provider_name, "branch"], Api::Resources::ProviderPactsForConsumerBranch, {resource_name: "main_branch_provider_pact_publications"}
46
53
 
47
54
  # Provider states
48
55
 
49
56
  add ["pacts", "provider", :provider_name, "provider-states"], Api::Resources::ProviderStates, { resource_name: "provider_states" }
57
+ add ["pacts", "provider", :provider_name, "provider-states", "branch", :branch_name], Api::Resources::ProviderStates, { resource_name: "provider_states_for_branch" }
58
+ add ["pacts", "provider", :provider_name, "provider-states", "environment", :environment_uuid], Api::Resources::ProviderStates, { resource_name: "provider_states_for_environment" }
50
59
 
51
60
 
52
61
  # Verifications
@@ -0,0 +1,7 @@
1
+ # Branch pact versions
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}`
6
+
7
+ Lists all the pact versions with the specified consumer, provider and consumer version branch.
@@ -0,0 +1,7 @@
1
+ # Latest Branch pact versions
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest`
6
+
7
+ Returns the latest pact version with the specified consumer, provider and consumer version branch.
@@ -0,0 +1,7 @@
1
+ # Latest main branch pact versions
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/latest`
6
+
7
+ Lists all latest pact version with the specified consumer, provider and the consumers main branch.
@@ -0,0 +1,7 @@
1
+ # Latest pacts for provider with the specified consumer branch
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/branch/{branch}/latest`
6
+
7
+ Given a provider name and a consumer version branch name, this resource returns the latest pact for each consumer that has the specified branch.
@@ -0,0 +1,7 @@
1
+ # Latest pacts for provider with the consumer main branch
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/branch/latest`
6
+
7
+ Given a provider name, this resource returns the latest pact for each consumers specified main branch.
@@ -1,5 +1,7 @@
1
- # Latest pacts for provider with the specified tag
1
+ # Latest pacts for provider with the specified consumer version tag
2
2
 
3
3
  Allowed methods: `GET`
4
4
 
5
+ Path: `/pacts/provider/{provider}/latest/{tag}`
6
+
5
7
  Given a provider name and a consumer version tag name, this resource returns the latest pact for each consumer that has the specified tag.
@@ -0,0 +1,7 @@
1
+ # Main Branch pact versions
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/consumer/{consumer}/branch`
6
+
7
+ Lists all the pact versions with the specified consumer, provider and the consumers main branch.
@@ -0,0 +1,7 @@
1
+ # Provider pacts with consumer branch
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/branch/{branch}`
6
+
7
+ Given a pacticipant name and a consumer branch, this resource returns all the pact versions for all consumers of this provider with the specified consumer branch. For most use cases, the `latest-provider-pacts-with-branch` relation will better serve consumer needs by only returning the latest pact version for specified consumer branches.
@@ -0,0 +1,7 @@
1
+ # All pacts for provider with the consumer main branch
2
+
3
+ Allowed methods: `GET`
4
+
5
+ Path: `/pacts/provider/{provider}/branch`
6
+
7
+ Given a provider name, this resource returns the latest pact for each consumers specified main branch.
@@ -2,4 +2,6 @@
2
2
 
3
3
  Allowed methods: `GET`
4
4
 
5
+ Path: `/pacts/provider/{provider}/tag/{tag}`
6
+
5
7
  Given a pacticipant name and a consumer version tag, this resource returns all the pact versions for all consumers of this provider with the specified tag. The most common use of this resource is to find all the `production` pact versions for the mobile consumers of an API, so that backwards compatibility can be maintained.
@@ -2,12 +2,20 @@
2
2
 
3
3
  Allowed methods: `GET`
4
4
 
5
- Path: `/pacts/provider/{provider}/provider-states`
6
-
7
5
  This resource returns a aggregated de-duplicated list of all provider states for a given provider.
8
6
 
7
+ Path: `/pacts/provider/{provider}/provider-states`
8
+
9
9
  Provider states are collected from the latest pact on the main branch for any dependant consumers.
10
10
 
11
+ Path: `/pacts/provider/{provider}/provider-states/branch/{branch_name}`
12
+
13
+ Provider states are collected from the latest pacts on the specified branch for any dependant consumers.
14
+
15
+ Path: `/pacts/provider/{provider}/provider-states/environment/{environment_name}`
16
+
17
+ Provider states are collected from the latest pacts in the specified environment for any dependant consumers.
18
+
11
19
  Example response
12
20
 
13
21
  ```json
@@ -25,4 +33,3 @@ Example response
25
33
  ]
26
34
  }
27
35
  ```
28
-
@@ -44,6 +44,14 @@ module PactBroker
44
44
  .remove_overridden_revisions_from_complete_query
45
45
  end
46
46
 
47
+ def for_main_branches
48
+ consumers_join = { Sequel[:pact_publications][:consumer_id] => Sequel[:consumers][:id] }
49
+ query = self
50
+ query
51
+ .join(:pacticipants, consumers_join, { table_alias: :consumers })
52
+ .remove_overridden_revisions_from_complete_query
53
+ end
54
+
47
55
  def for_currently_deployed_versions(environment_name)
48
56
  deployed_versions_join = {
49
57
  Sequel[:pact_publications][:consumer_version_id] => Sequel[:deployed_versions][:version_id]
@@ -11,8 +11,16 @@ module PactBroker
11
11
  extend PactBroker::Services
12
12
  extend PactBroker::Repositories::Scopes
13
13
 
14
- def self.list_provider_states(provider)
15
- query = scope_for(PactPublication).eager_for_domain_with_content.for_provider_and_consumer_version_selector(provider, PactBroker::Pacts::Selector.latest_for_main_branch)
14
+ def self.list_provider_states(provider, branch_name = nil, environment_name = nil)
15
+ selector =
16
+ if branch_name
17
+ PactBroker::Pacts::Selector.latest_for_branch(branch_name)
18
+ elsif environment_name
19
+ PactBroker::Pacts::Selector.for_environment(environment_name)
20
+ else
21
+ PactBroker::Pacts::Selector.latest_for_main_branch
22
+ end
23
+ query = scope_for(PactPublication).eager_for_domain_with_content.for_provider_and_consumer_version_selector(provider, selector)
16
24
  query.all.flat_map do | pact_publication |
17
25
  { "providerStates" => pact_publication.to_domain.content_object.provider_states, "consumer" => pact_publication.to_domain.consumer.name }
18
26
  end
@@ -151,6 +151,36 @@ module PactBroker
151
151
  query.all.sort_by{ | p| p.consumer_name.downcase }.collect(&:to_head_pact)
152
152
  end
153
153
 
154
+ def find_pacts_by_consumer_branch(provider_name, options = {})
155
+ consumer_name = options[:consumer]
156
+ latest = options.fetch(:latest, false)
157
+ branch = options[:branch_name]
158
+ main_branch = options.fetch(:main_branch, false)
159
+
160
+ query = scope_for(PactPublication)
161
+ .eager_for_domain_with_content
162
+ .for_provider_name(provider_name)
163
+
164
+ if consumer_name
165
+ query = query.for_consumer_name(consumer_name)
166
+ end
167
+
168
+ if main_branch
169
+ if latest
170
+ query = query.latest_for_main_branches
171
+ else
172
+ query = query.for_main_branches
173
+ end
174
+ else
175
+ if latest
176
+ query = query.latest_for_consumer_branch(branch)
177
+ else
178
+ query = query.for_branch_name(branch)
179
+ end
180
+ end
181
+ query.all.sort_by{ | p| p.consumer_name.downcase }.collect(&:to_head_pact)
182
+ end
183
+
154
184
  def find_for_verification(provider_name, consumer_version_selectors)
155
185
  PactsForVerificationRepository.new.find(provider_name, consumer_version_selectors)
156
186
  end
@@ -95,6 +95,26 @@ module PactBroker
95
95
  pact_repository.find_latest_pacts_for_provider provider_name, options[:tag]
96
96
  end
97
97
 
98
+ def find_latest_pacts_for_provider_by_consumer_branch provider_name, options = {}
99
+ options[:latest] = true
100
+ pact_repository.find_pacts_by_consumer_branch provider_name, options
101
+ end
102
+
103
+ def find_pacts_for_provider_by_consumer_branch provider_name, options = {}
104
+ pact_repository.find_pacts_by_consumer_branch provider_name, options
105
+ end
106
+
107
+ def find_pacts_for_provider_and_consumer_by_consumer_branch provider_name, consumer, options = {}
108
+ options[:consumer] = consumer
109
+ pact_repository.find_pacts_by_consumer_branch provider_name, options
110
+ end
111
+
112
+ def find_latest_pacts_for_provider_and_consumer_by_consumer_branch provider_name, consumer, options = {}
113
+ options[:consumer] = consumer
114
+ options[:latest] = true
115
+ pact_repository.find_pacts_by_consumer_branch provider_name, options
116
+ end
117
+
98
118
  def find_pact_versions_for_provider provider_name, options = {}
99
119
  pact_repository.find_pact_versions_for_provider provider_name, options[:tag]
100
120
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = "2.116.0"
2
+ VERSION = "2.117.0"
3
3
  end
data/pact_broker.gemspec CHANGED
@@ -57,11 +57,9 @@ Gem::Specification.new do |gem|
57
57
  gem.add_runtime_dependency "sequel", "~> 5.90"
58
58
  gem.add_runtime_dependency "webmachine", ">= 2.0.0.beta", "< 3.0"
59
59
  gem.add_runtime_dependency "semver2", "~> 3.4.2"
60
- gem.add_runtime_dependency "rack", "~> 3.1", ">= 3.1.16"
60
+ gem.add_runtime_dependency "rack", "~> 3.2"
61
61
  gem.add_runtime_dependency "redcarpet", ">= 3.5.1", "~>3.5"
62
- # TODO: restore this with when latest master is released as 1.21.3
63
- # remove the Gemfile entry pointing to master
64
- # gem.add_runtime_dependency "pact-support" , ">= 1.21.3", "~> 1.21"
62
+ gem.add_runtime_dependency "pact-support" , ">= 1.21.2", "~> 1.21"
65
63
  gem.add_runtime_dependency "haml", "~>5.0"
66
64
  gem.add_runtime_dependency "sucker_punch", "~>3.0"
67
65
  gem.add_runtime_dependency "rack-protection", "~> 4.1"
@@ -72,4 +70,10 @@ Gem::Specification.new do |gem|
72
70
  gem.add_runtime_dependency "anyway_config", "~> 2.1"
73
71
  gem.add_runtime_dependency "request_store", "~> 1.5"
74
72
  gem.add_runtime_dependency "moments", "~> 0.2"
73
+ # dropped in ruby 3.4 stdlib
74
+ gem.add_runtime_dependency "mutex_m", "~> 0.3" # until as-notifications -> webmachine requires it
75
+ gem.add_runtime_dependency "csv", "~> 3.0" # lib/pact_broker/api/decorators/relationships_csv_decorator.rb
76
+ # dropped in ruby 3.5 stdlib
77
+ gem.add_runtime_dependency "ostruct", "~> 0.5"
78
+ gem.add_development_dependency "pstore", "~> 0.1" # until webmachine requires it
75
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.116.0
4
+ version: 2.117.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -135,20 +135,14 @@ dependencies:
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '3.1'
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- version: 3.1.16
138
+ version: '3.2'
142
139
  type: :runtime
143
140
  prerelease: false
144
141
  version_requirements: !ruby/object:Gem::Requirement
145
142
  requirements:
146
143
  - - "~>"
147
144
  - !ruby/object:Gem::Version
148
- version: '3.1'
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: 3.1.16
145
+ version: '3.2'
152
146
  - !ruby/object:Gem::Dependency
153
147
  name: redcarpet
154
148
  requirement: !ruby/object:Gem::Requirement
@@ -169,6 +163,26 @@ dependencies:
169
163
  - - "~>"
170
164
  - !ruby/object:Gem::Version
171
165
  version: '3.5'
166
+ - !ruby/object:Gem::Dependency
167
+ name: pact-support
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: 1.21.2
173
+ - - "~>"
174
+ - !ruby/object:Gem::Version
175
+ version: '1.21'
176
+ type: :runtime
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 1.21.2
183
+ - - "~>"
184
+ - !ruby/object:Gem::Version
185
+ version: '1.21'
172
186
  - !ruby/object:Gem::Dependency
173
187
  name: haml
174
188
  requirement: !ruby/object:Gem::Requirement
@@ -309,6 +323,62 @@ dependencies:
309
323
  - - "~>"
310
324
  - !ruby/object:Gem::Version
311
325
  version: '0.2'
326
+ - !ruby/object:Gem::Dependency
327
+ name: mutex_m
328
+ requirement: !ruby/object:Gem::Requirement
329
+ requirements:
330
+ - - "~>"
331
+ - !ruby/object:Gem::Version
332
+ version: '0.3'
333
+ type: :runtime
334
+ prerelease: false
335
+ version_requirements: !ruby/object:Gem::Requirement
336
+ requirements:
337
+ - - "~>"
338
+ - !ruby/object:Gem::Version
339
+ version: '0.3'
340
+ - !ruby/object:Gem::Dependency
341
+ name: csv
342
+ requirement: !ruby/object:Gem::Requirement
343
+ requirements:
344
+ - - "~>"
345
+ - !ruby/object:Gem::Version
346
+ version: '3.0'
347
+ type: :runtime
348
+ prerelease: false
349
+ version_requirements: !ruby/object:Gem::Requirement
350
+ requirements:
351
+ - - "~>"
352
+ - !ruby/object:Gem::Version
353
+ version: '3.0'
354
+ - !ruby/object:Gem::Dependency
355
+ name: ostruct
356
+ requirement: !ruby/object:Gem::Requirement
357
+ requirements:
358
+ - - "~>"
359
+ - !ruby/object:Gem::Version
360
+ version: '0.5'
361
+ type: :runtime
362
+ prerelease: false
363
+ version_requirements: !ruby/object:Gem::Requirement
364
+ requirements:
365
+ - - "~>"
366
+ - !ruby/object:Gem::Version
367
+ version: '0.5'
368
+ - !ruby/object:Gem::Dependency
369
+ name: pstore
370
+ requirement: !ruby/object:Gem::Requirement
371
+ requirements:
372
+ - - "~>"
373
+ - !ruby/object:Gem::Version
374
+ version: '0.1'
375
+ type: :development
376
+ prerelease: false
377
+ version_requirements: !ruby/object:Gem::Requirement
378
+ requirements:
379
+ - - "~>"
380
+ - !ruby/object:Gem::Version
381
+ version: '0.1'
312
382
  description: A server that stores and returns pact files generated by the pact gem.
313
383
  It enables head/prod cross testing of the consumer and provider projects.
314
384
  email:
@@ -681,6 +751,7 @@ files:
681
751
  - lib/pact_broker/api/resources/latest_pact.rb
682
752
  - lib/pact_broker/api/resources/latest_pacts.rb
683
753
  - lib/pact_broker/api/resources/latest_provider_pacts.rb
754
+ - lib/pact_broker/api/resources/latest_provider_pacts_for_branch.rb
684
755
  - lib/pact_broker/api/resources/latest_verification_for_latest_pact.rb
685
756
  - lib/pact_broker/api/resources/latest_verification_for_pact.rb
686
757
  - lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb
@@ -708,6 +779,7 @@ files:
708
779
  - lib/pact_broker/api/resources/pagination_methods.rb
709
780
  - lib/pact_broker/api/resources/previous_distinct_pact_version.rb
710
781
  - lib/pact_broker/api/resources/provider_pacts.rb
782
+ - lib/pact_broker/api/resources/provider_pacts_for_consumer_branch.rb
711
783
  - lib/pact_broker/api/resources/provider_pacts_for_verification.rb
712
784
  - lib/pact_broker/api/resources/provider_states.rb
713
785
  - lib/pact_broker/api/resources/publish_contracts.rb
@@ -806,18 +878,26 @@ files:
806
878
  - lib/pact_broker/doc/views/can-i-deploy.markdown
807
879
  - lib/pact_broker/doc/views/consumer-version.markdown
808
880
  - lib/pact_broker/doc/views/consumer.markdown
881
+ - lib/pact_broker/doc/views/index/branch-pact-versions.markdown
809
882
  - lib/pact_broker/doc/views/index/environment.markdown
810
883
  - lib/pact_broker/doc/views/index/environments.markdown
884
+ - lib/pact_broker/doc/views/index/latest-branch-pact-versions.markdown
885
+ - lib/pact_broker/doc/views/index/latest-main-branch-pact-versions.markdown
811
886
  - lib/pact_broker/doc/views/index/latest-pact-versions.markdown
887
+ - lib/pact_broker/doc/views/index/latest-provider-pacts-with-branch.markdown
888
+ - lib/pact_broker/doc/views/index/latest-provider-pacts-with-main-branch.markdown
812
889
  - lib/pact_broker/doc/views/index/latest-provider-pacts-with-tag.markdown
813
890
  - lib/pact_broker/doc/views/index/latest-provider-pacts.markdown
814
891
  - lib/pact_broker/doc/views/index/latest-tagged-version.markdown
815
892
  - lib/pact_broker/doc/views/index/latest-version.markdown
893
+ - lib/pact_broker/doc/views/index/main-branch-pact-versions.markdown
816
894
  - lib/pact_broker/doc/views/index/pacticipant-branch-version.markdown
817
895
  - lib/pact_broker/doc/views/index/pacticipant-branch.markdown
818
896
  - lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown
819
897
  - lib/pact_broker/doc/views/index/pacticipant-version.markdown
820
898
  - lib/pact_broker/doc/views/index/pacticipants.markdown
899
+ - lib/pact_broker/doc/views/index/provider-pacts-with-branch.markdown
900
+ - lib/pact_broker/doc/views/index/provider-pacts-with-main-branch.markdown
821
901
  - lib/pact_broker/doc/views/index/provider-pacts-with-tag.markdown
822
902
  - lib/pact_broker/doc/views/index/provider-pacts.markdown
823
903
  - lib/pact_broker/doc/views/index/publish-contracts.markdown
@@ -1209,7 +1289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1209
1289
  - !ruby/object:Gem::Version
1210
1290
  version: '0'
1211
1291
  requirements: []
1212
- rubygems_version: 3.6.9
1292
+ rubygems_version: 3.7.2
1213
1293
  specification_version: 4
1214
1294
  summary: See description
1215
1295
  test_files: []