pact_broker 2.64.0 → 2.68.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/Gemfile +1 -0
- data/db/ddl_statements/latest_triggered_webhooks.rb +66 -0
- data/db/migrations/20180119_update_latest_triggered_webhooks.rb +5 -39
- data/db/migrations/20200930_update_latest_triggered_webhooks.rb +15 -0
- data/db/migrations/20201006_add_wip_to_verification.rb +5 -0
- data/db/migrations/20201023_create_verification_number_sequence.rb +20 -0
- data/db/migrations/20201024_create_version_order_sequence.rb +20 -0
- data/db/migrations/migration_helper.rb +10 -2
- data/docker-compose-issue-repro.yml +18 -0
- data/issue-reproduction/Dockerfile-pact-broker +42 -0
- data/lib/db.rb +7 -1
- data/lib/pact_broker/api/decorators/decorator_context.rb +2 -2
- data/lib/pact_broker/api/decorators/pagination_links.rb +34 -0
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +4 -2
- data/lib/pact_broker/api/decorators/versions_decorator.rb +5 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +18 -6
- data/lib/pact_broker/api/paths.rb +4 -3
- data/lib/pact_broker/api/resources/can_i_deploy.rb +14 -0
- data/lib/pact_broker/api/resources/group.rb +0 -1
- data/lib/pact_broker/api/resources/index.rb +5 -0
- data/lib/pact_broker/api/resources/label.rb +0 -1
- data/lib/pact_broker/api/resources/latest_pact.rb +1 -1
- data/lib/pact_broker/api/resources/pact.rb +8 -0
- data/lib/pact_broker/api/resources/pact_versions.rb +4 -0
- data/lib/pact_broker/api/resources/pact_webhooks.rb +1 -1
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +10 -1
- data/lib/pact_broker/api/resources/tag.rb +0 -1
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +4 -0
- data/lib/pact_broker/api/resources/verification.rb +4 -0
- data/lib/pact_broker/api/resources/verifications.rb +14 -2
- data/lib/pact_broker/api/resources/versions.rb +12 -1
- data/lib/pact_broker/app.rb +2 -2
- data/lib/pact_broker/configuration.rb +3 -0
- data/lib/pact_broker/db/clean.rb +100 -43
- data/lib/pact_broker/doc/views/integrations.markdown +5 -1
- data/lib/pact_broker/doc/views/pacticipant/versions.markdown +9 -0
- data/lib/pact_broker/domain/pacticipant.rb +4 -0
- data/lib/pact_broker/domain/tag.rb +2 -0
- data/lib/pact_broker/domain/version.rb +1 -0
- data/lib/pact_broker/domain/webhook_request.rb +2 -1
- data/lib/pact_broker/feature_toggle.rb +8 -4
- data/lib/pact_broker/groups/service.rb +0 -3
- data/lib/pact_broker/locale/en.yml +1 -0
- data/lib/pact_broker/matrix/aggregated_row.rb +1 -0
- data/lib/pact_broker/matrix/deployment_status_summary.rb +1 -1
- data/lib/pact_broker/matrix/query_results_with_deployment_status_summary.rb +1 -0
- data/lib/pact_broker/matrix/service.rb +3 -0
- data/lib/pact_broker/pacticipants/repository.rb +6 -5
- data/lib/pact_broker/pacticipants/service.rb +5 -18
- data/lib/pact_broker/pacts/all_pact_publications.rb +1 -0
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +15 -1
- data/lib/pact_broker/pacts/pact_publication.rb +1 -0
- data/lib/pact_broker/pacts/repository.rb +1 -0
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +7 -3
- data/lib/pact_broker/tags/repository.rb +2 -5
- data/lib/pact_broker/test/http_test_data_builder.rb +121 -0
- data/lib/pact_broker/test/test_data_builder.rb +23 -3
- data/lib/pact_broker/ui/views/matrix/show.haml +8 -0
- data/lib/pact_broker/verifications/repository.rb +16 -9
- data/lib/pact_broker/verifications/sequence.rb +21 -16
- data/lib/pact_broker/verifications/service.rb +2 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/sequence.rb +21 -17
- data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +1 -1
- data/script/reproduce-issue.rb +20 -0
- data/spec/features/create_webhook_spec.rb +18 -0
- data/spec/features/get_versions_spec.rb +8 -0
- data/spec/features/wip_pacts_spec.rb +258 -33
- data/spec/fixtures/approvals/modifiable_resources.approved.json +74 -0
- data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +0 -3
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +7 -2
- data/spec/lib/pact_broker/api/decorators/versions_decorator_spec.rb +14 -9
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +6 -5
- data/spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb +51 -0
- data/spec/lib/pact_broker/api/resources/default_base_resource_approval_spec.rb +59 -0
- data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +17 -6
- data/spec/lib/pact_broker/api/resources/latest_pact_spec.rb +2 -2
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +17 -3
- data/spec/lib/pact_broker/db/clean_spec.rb +72 -4
- data/spec/lib/pact_broker/db/delete_overwritten_data_spec.rb +1 -1
- data/spec/lib/pact_broker/domain/webhook_request_spec.rb +1 -1
- data/spec/lib/pact_broker/feature_toggle_spec.rb +9 -1
- data/spec/lib/pact_broker/matrix/integration_spec.rb +1 -1
- data/spec/lib/pact_broker/pacticipants/repository_spec.rb +8 -1
- data/spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb +99 -0
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +24 -2
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +12 -0
- data/spec/lib/pact_broker/verifications/sequence_spec.rb +48 -22
- data/spec/lib/pact_broker/verifications/service_spec.rb +4 -2
- data/spec/lib/pact_broker/webhooks/render_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +20 -0
- data/spec/spec_helper.rb +5 -0
- data/tasks/database.rb +8 -0
- metadata +21 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1076b8629f5570c2304ec89fc169be77c2b6f54aaf832ceec91d5a939806f97
|
|
4
|
+
data.tar.gz: 28c09fcdf4d7abc16f367b8c6aaebfd3f3baaa68850ae5809aefb33d92bae8fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fd730f1c2500942f680f66c4f526b138e71fd6f27a194b85fc280f9f1d959d6ecf79e88cb4aa685d451373cc9c3ac80714751a7d3658ec75c00f874925a8a39
|
|
7
|
+
data.tar.gz: 4327534a89cbaae5d76a86bb36aeb220668fd41805837923188e4ae1bfe2e3968d416b4c26338c6b80cc911552bb3f41db2ac0feef4a0bf70470820d1f780136
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
+
<a name="v2.68.1"></a>
|
|
2
|
+
### v2.68.1 (2020-10-24)
|
|
3
|
+
|
|
4
|
+
#### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* set default User-Agent header in webhook requests ([caa71f9b](/../../commit/caa71f9b))
|
|
7
|
+
|
|
8
|
+
<a name="v2.68.0"></a>
|
|
9
|
+
### v2.68.0 (2020-10-23)
|
|
10
|
+
|
|
11
|
+
#### Features
|
|
12
|
+
|
|
13
|
+
* use a sequence for the version order on postgres ([da497a76](/../../commit/da497a76))
|
|
14
|
+
* only cascade apps for 404s (not 405s) ([4e1b3083](/../../commit/4e1b3083))
|
|
15
|
+
* use a sequence for the verification number on postgres ([b8f029ee](/../../commit/b8f029ee))
|
|
16
|
+
* optimise query to find latest verification for pact ([db17ef5a](/../../commit/db17ef5a))
|
|
17
|
+
|
|
18
|
+
<a name="v2.67.0"></a>
|
|
19
|
+
### v2.67.0 (2020-10-16)
|
|
20
|
+
|
|
21
|
+
#### Features
|
|
22
|
+
|
|
23
|
+
* **wip pacts**
|
|
24
|
+
* if a pact was successfully verified because it was included as a WIP pact, keep it as WIP ([16cae55d](/../../commit/16cae55d))
|
|
25
|
+
* add 'wip' column to verification results ([34f98592](/../../commit/34f98592))
|
|
26
|
+
|
|
27
|
+
#### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* typo when rendering created webhook for old webhooks path ([1e6a06a0](/../../commit/1e6a06a0))
|
|
30
|
+
* include can-i-deploy badge in is_badge_path? logic ([31ea5f34](/../../commit/31ea5f34))
|
|
31
|
+
|
|
32
|
+
* **pacts for verification**
|
|
33
|
+
* gracefully log empty request body ([0e48d13a](/../../commit/0e48d13a))
|
|
34
|
+
|
|
35
|
+
* **can-i-deploy**
|
|
36
|
+
* gracefully handle pacticipant not found ([f6903b23](/../../commit/f6903b23))
|
|
37
|
+
|
|
38
|
+
<a name="v2.66.0"></a>
|
|
39
|
+
### v2.66.0 (2020-10-01)
|
|
40
|
+
|
|
41
|
+
#### Features
|
|
42
|
+
|
|
43
|
+
* paginate pacticipant versions ([f489ba7b](/../../commit/f489ba7b))
|
|
44
|
+
|
|
45
|
+
* **webhooks**
|
|
46
|
+
* add event name to group by clause when selecting latest triggered webhooks ([134f12c8](/../../commit/134f12c8))
|
|
47
|
+
|
|
48
|
+
#### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* maintain latest and tag params when submitting page after following link from can-i-deploy debug logs ([6e2f1a85](/../../commit/6e2f1a85))
|
|
51
|
+
|
|
52
|
+
<a name="v2.65.0"></a>
|
|
53
|
+
### v2.65.0 (2020-09-25)
|
|
54
|
+
|
|
55
|
+
#### Features
|
|
56
|
+
|
|
57
|
+
* **pacts for verification**
|
|
58
|
+
* allow API to be disabled by setting PACT_BROKER_FEATURES=disable_pacts_for_verification ([bab116b3](/../../commit/bab116b3))
|
|
59
|
+
* update wording for inclusion notice when selector has a consumer specified ([61370d1f](/../../commit/61370d1f))
|
|
60
|
+
|
|
1
61
|
<a name="v2.64.0"></a>
|
|
2
62
|
### v2.64.0 (2020-09-25)
|
|
3
63
|
|
data/Gemfile
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# These views find the latest triggered webhook for each webhook/consumer/provider
|
|
2
|
+
# by finding the latest execution date for each webhook
|
|
3
|
+
# then taking the row with the max ID in case there there are two
|
|
4
|
+
# triggered webhooks for the same UUID and same creation date
|
|
5
|
+
# Not sure if this is strictly necessary to do the extra step, but better to be
|
|
6
|
+
# safe than sorry.
|
|
7
|
+
# I probably could just take the max ID for each webhook/consumer/provider, but
|
|
8
|
+
# something in my head says that
|
|
9
|
+
# relying on the primary key for order is not a good idea, even though
|
|
10
|
+
# according to the SQL it should be fine.
|
|
11
|
+
def latest_triggered_webhook_creation_dates_v2
|
|
12
|
+
"select webhook_uuid, consumer_id, provider_id, max(created_at) as latest_triggered_webhook_created_at
|
|
13
|
+
from triggered_webhooks
|
|
14
|
+
group by webhook_uuid, consumer_id, provider_id"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Ignore ltwcd.latest_triggered_webhook_created_at, it's there because postgres doesn't allow you to modify
|
|
18
|
+
# the names and types of columns in a view
|
|
19
|
+
def latest_triggered_webhook_ids_v2
|
|
20
|
+
"select tw.webhook_uuid, tw.consumer_id, tw.provider_id, ltwcd.latest_triggered_webhook_created_at, max(tw.id) as latest_triggered_webhook_id
|
|
21
|
+
from latest_triggered_webhook_creation_dates ltwcd
|
|
22
|
+
inner join triggered_webhooks tw
|
|
23
|
+
on tw.consumer_id = ltwcd.consumer_id
|
|
24
|
+
and tw.provider_id = ltwcd.provider_id
|
|
25
|
+
and tw.webhook_uuid = ltwcd.webhook_uuid
|
|
26
|
+
and tw.created_at = ltwcd.latest_triggered_webhook_created_at
|
|
27
|
+
group by tw.webhook_uuid, tw.consumer_id, tw.provider_id, ltwcd.latest_triggered_webhook_created_at"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def latest_triggered_webhooks_v2
|
|
31
|
+
"select tw.*
|
|
32
|
+
from triggered_webhooks tw
|
|
33
|
+
inner join latest_triggered_webhook_ids ltwi
|
|
34
|
+
on tw.consumer_id = ltwi.consumer_id
|
|
35
|
+
and tw.provider_id = ltwi.provider_id
|
|
36
|
+
and tw.webhook_uuid = ltwi.webhook_uuid
|
|
37
|
+
and tw.id = ltwi.latest_triggered_webhook_id"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# use explicit columns - can't drop event_name in 20200922_add_event_to_triggered_webhook.rb
|
|
41
|
+
# if tw.* is used because you can't remove columns from a view in postgres
|
|
42
|
+
def latest_triggered_webhooks_v3_rollback(is_postgres)
|
|
43
|
+
if is_postgres
|
|
44
|
+
"select tw.id, tw.trigger_uuid, tw.trigger_type, tw.pact_publication_id, tw.webhook_id, tw.webhook_uuid, tw.consumer_id, tw.provider_id, tw.status, tw.created_at, tw.updated_at, tw.verification_id, ''::text as event_name
|
|
45
|
+
from triggered_webhooks tw
|
|
46
|
+
inner join latest_triggered_webhook_ids ltwi
|
|
47
|
+
on tw.consumer_id = ltwi.consumer_id
|
|
48
|
+
and tw.provider_id = ltwi.provider_id
|
|
49
|
+
and tw.webhook_uuid = ltwi.webhook_uuid
|
|
50
|
+
and tw.id = ltwi.latest_triggered_webhook_id"
|
|
51
|
+
else
|
|
52
|
+
latest_triggered_webhooks_v2
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
##### v3
|
|
57
|
+
|
|
58
|
+
# screw dates, just use IDs.
|
|
59
|
+
def latest_triggered_webhooks_v3
|
|
60
|
+
"select tw.id, tw.trigger_uuid, tw.trigger_type, tw.pact_publication_id, tw.webhook_id, tw.webhook_uuid, tw.consumer_id, tw.provider_id, tw.status, tw.created_at, tw.updated_at, tw.verification_id, tw.event_name
|
|
61
|
+
from triggered_webhooks tw
|
|
62
|
+
inner join (select max(id) as max_id
|
|
63
|
+
from triggered_webhooks
|
|
64
|
+
group by webhook_uuid, consumer_id, provider_id, event_name) latest_ids
|
|
65
|
+
on latest_ids.max_id = tw.id"
|
|
66
|
+
end
|
|
@@ -1,44 +1,10 @@
|
|
|
1
|
+
require_relative '../ddl_statements/latest_triggered_webhooks'
|
|
2
|
+
|
|
1
3
|
Sequel.migration do
|
|
2
4
|
up do
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# triggered webhooks for the same UUID and same creation date
|
|
7
|
-
# Not sure if this is strictly necessary to do the extra step, but better to be
|
|
8
|
-
# safe than sorry.
|
|
9
|
-
# I probably could just take the max ID for each webhook/consumer/provider, but
|
|
10
|
-
# something in my head says that
|
|
11
|
-
# relying on the primary key for order is not a good idea, even though
|
|
12
|
-
# according to the SQL it should be fine.
|
|
13
|
-
|
|
14
|
-
create_or_replace_view(:latest_triggered_webhook_creation_dates,
|
|
15
|
-
"select webhook_uuid, consumer_id, provider_id, max(created_at) as latest_triggered_webhook_created_at
|
|
16
|
-
from triggered_webhooks
|
|
17
|
-
group by webhook_uuid, consumer_id, provider_id"
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
# Ignore ltwcd.latest_triggered_webhook_created_at, it's there because postgres doesn't allow you to modify
|
|
21
|
-
# the names and types of columns in a view
|
|
22
|
-
create_or_replace_view(:latest_triggered_webhook_ids,
|
|
23
|
-
"select tw.webhook_uuid, tw.consumer_id, tw.provider_id, ltwcd.latest_triggered_webhook_created_at, max(tw.id) as latest_triggered_webhook_id
|
|
24
|
-
from latest_triggered_webhook_creation_dates ltwcd
|
|
25
|
-
inner join triggered_webhooks tw
|
|
26
|
-
on tw.consumer_id = ltwcd.consumer_id
|
|
27
|
-
and tw.provider_id = ltwcd.provider_id
|
|
28
|
-
and tw.webhook_uuid = ltwcd.webhook_uuid
|
|
29
|
-
and tw.created_at = ltwcd.latest_triggered_webhook_created_at
|
|
30
|
-
group by tw.webhook_uuid, tw.consumer_id, tw.provider_id, ltwcd.latest_triggered_webhook_created_at"
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
create_or_replace_view(:latest_triggered_webhooks,
|
|
34
|
-
"select tw.*
|
|
35
|
-
from triggered_webhooks tw
|
|
36
|
-
inner join latest_triggered_webhook_ids ltwi
|
|
37
|
-
on tw.consumer_id = ltwi.consumer_id
|
|
38
|
-
and tw.provider_id = ltwi.provider_id
|
|
39
|
-
and tw.webhook_uuid = ltwi.webhook_uuid
|
|
40
|
-
and tw.id = ltwi.latest_triggered_webhook_id"
|
|
41
|
-
)
|
|
5
|
+
create_or_replace_view(:latest_triggered_webhook_creation_dates, latest_triggered_webhook_creation_dates_v2)
|
|
6
|
+
create_or_replace_view(:latest_triggered_webhook_ids, latest_triggered_webhook_ids_v2)
|
|
7
|
+
create_or_replace_view(:latest_triggered_webhooks, latest_triggered_webhooks_v2)
|
|
42
8
|
end
|
|
43
9
|
|
|
44
10
|
down do
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative '../ddl_statements/latest_triggered_webhooks'
|
|
2
|
+
require_relative 'migration_helper'
|
|
3
|
+
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
up do
|
|
6
|
+
# TODO
|
|
7
|
+
# drop_view(:latest_triggered_webhook_ids)
|
|
8
|
+
# drop_view(:latest_triggered_webhook_creation_dates)
|
|
9
|
+
create_or_replace_view(:latest_triggered_webhooks, latest_triggered_webhooks_v3)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
down do
|
|
13
|
+
create_or_replace_view(:latest_triggered_webhooks, latest_triggered_webhooks_v3_rollback(PactBroker::MigrationHelper.postgres?))
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative 'migration_helper'
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
if PactBroker::MigrationHelper.postgres?
|
|
6
|
+
row = from(:verification_sequence_number).select(:value).limit(1).first
|
|
7
|
+
start = row ? row[:value] + 100 : 1
|
|
8
|
+
run("CREATE SEQUENCE verification_number_sequence START WITH #{start}")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
down do
|
|
13
|
+
if PactBroker::MigrationHelper.postgres?
|
|
14
|
+
nextval = execute("SELECT nextval('verification_number_sequence') as val") { |v| v.first["val"].to_i }
|
|
15
|
+
# Add a safety margin!
|
|
16
|
+
from(:verification_sequence_number).update(value: nextval + 100)
|
|
17
|
+
run("DROP SEQUENCE verification_number_sequence")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative 'migration_helper'
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
if PactBroker::MigrationHelper.postgres?
|
|
6
|
+
row = from(:version_sequence_number).select(:value).limit(1).first
|
|
7
|
+
start = row ? row[:value] + 100 : 1
|
|
8
|
+
run("CREATE SEQUENCE version_order_sequence START WITH #{start}")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
down do
|
|
13
|
+
if PactBroker::MigrationHelper.postgres?
|
|
14
|
+
nextval = execute("SELECT nextval('version_order_sequence') as val") { |v| v.first["val"].to_i }
|
|
15
|
+
# Add a safety margin!
|
|
16
|
+
from(:version_sequence_number).update(value: nextval + 100)
|
|
17
|
+
run("DROP SEQUENCE version_order_sequence")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -4,7 +4,7 @@ module PactBroker
|
|
|
4
4
|
extend self
|
|
5
5
|
|
|
6
6
|
def large_text_type
|
|
7
|
-
if
|
|
7
|
+
if postgres?
|
|
8
8
|
:text
|
|
9
9
|
else
|
|
10
10
|
# Assume mysql
|
|
@@ -13,11 +13,19 @@ module PactBroker
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def with_mysql
|
|
16
|
-
if
|
|
16
|
+
if mysql?
|
|
17
17
|
yield
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def mysql?
|
|
22
|
+
adapter =~ /mysql/
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def postgres?
|
|
26
|
+
adapter == 'postgres'
|
|
27
|
+
end
|
|
28
|
+
|
|
21
29
|
def adapter
|
|
22
30
|
Sequel::Model.db.adapter_scheme.to_s
|
|
23
31
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: "3"
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
pact-broker:
|
|
5
|
+
build:
|
|
6
|
+
context: .
|
|
7
|
+
dockerfile: issue-reproduction/Dockerfile-pact-broker
|
|
8
|
+
ports:
|
|
9
|
+
- "9292:9292"
|
|
10
|
+
command: bundle exec rackup -p 9292 -o 0.0.0.0
|
|
11
|
+
|
|
12
|
+
repro-issue:
|
|
13
|
+
build:
|
|
14
|
+
context: .
|
|
15
|
+
dockerfile: issue-reproduction/Dockerfile-pact-broker
|
|
16
|
+
depends_on:
|
|
17
|
+
- pact-broker
|
|
18
|
+
command: dockerize -wait http://pact-broker:9292 -timeout 30s /home/script/reproduce-issue.rb
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
FROM ruby:2.5.3-alpine
|
|
2
|
+
|
|
3
|
+
RUN apk update \
|
|
4
|
+
&& apk --no-cache add \
|
|
5
|
+
"build-base>=0.5" \
|
|
6
|
+
"bash>=4.4" \
|
|
7
|
+
"ca-certificates>=20190108" \
|
|
8
|
+
"git>=2.20" \
|
|
9
|
+
"postgresql-dev>=11.3" \
|
|
10
|
+
"sqlite-dev>=3.28" \
|
|
11
|
+
"sqlite>=3.28" \
|
|
12
|
+
"tzdata>=2019" \
|
|
13
|
+
"mariadb-dev>=10.3" \
|
|
14
|
+
&& rm -rf /var/cache/apk/*
|
|
15
|
+
|
|
16
|
+
RUN apk add --no-cache openssl less
|
|
17
|
+
|
|
18
|
+
ENV DOCKERIZE_VERSION v0.6.1
|
|
19
|
+
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
|
20
|
+
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
|
21
|
+
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
WORKDIR /home
|
|
25
|
+
|
|
26
|
+
COPY Gemfile /home/Gemfile
|
|
27
|
+
COPY pact_broker.gemspec /home/pact_broker.gemspec
|
|
28
|
+
COPY lib/pact_broker/version.rb /home/lib/pact_broker/version.rb
|
|
29
|
+
COPY .gitignore /home/.gitignore
|
|
30
|
+
|
|
31
|
+
RUN gem install bundler -v '~>2.0.0' \
|
|
32
|
+
&& bundle install --jobs 3 --retry 3
|
|
33
|
+
|
|
34
|
+
COPY lib /home/lib
|
|
35
|
+
COPY db /home/db
|
|
36
|
+
COPY public /home/public
|
|
37
|
+
COPY tasks /home/tasks
|
|
38
|
+
COPY config.ru /home/config.ru
|
|
39
|
+
COPY Rakefile /home/Rakefile
|
|
40
|
+
COPY script /home/script
|
|
41
|
+
|
|
42
|
+
RUN ls /home
|
data/lib/db.rb
CHANGED
|
@@ -27,7 +27,9 @@ module DB
|
|
|
27
27
|
def self.connect db_credentials
|
|
28
28
|
# Keep this conifiguration in sync with lib/pact_broker/app.rb#configure_database_connection
|
|
29
29
|
Sequel.datetime_class = DateTime
|
|
30
|
-
|
|
30
|
+
if ENV['DEBUG'] == 'true'
|
|
31
|
+
logger = Logger.new($stdout)
|
|
32
|
+
end
|
|
31
33
|
con = Sequel.connect(db_credentials.merge(:logger => logger, :pool_class => Sequel::ThreadedConnectionPool, :encoding => 'utf8'))
|
|
32
34
|
con.extension(:connection_validator)
|
|
33
35
|
con.extension(:pagination)
|
|
@@ -58,6 +60,10 @@ module DB
|
|
|
58
60
|
!!(PACT_BROKER_DB.adapter_scheme.to_s =~ /mysql/)
|
|
59
61
|
end
|
|
60
62
|
|
|
63
|
+
def self.postgres?
|
|
64
|
+
!!(PACT_BROKER_DB.adapter_scheme.to_s == "postgres")
|
|
65
|
+
end
|
|
66
|
+
|
|
61
67
|
PACT_BROKER_DB ||= connection_for_env ENV.fetch('RACK_ENV')
|
|
62
68
|
|
|
63
69
|
def self.health_check
|
|
@@ -2,14 +2,14 @@ module PactBroker
|
|
|
2
2
|
module Api
|
|
3
3
|
module Decorators
|
|
4
4
|
class DecoratorContext < Hash
|
|
5
|
-
|
|
6
|
-
attr_reader :base_url, :resource_url, :resource_title, :env
|
|
5
|
+
attr_reader :base_url, :resource_url, :resource_title, :env, :query_string
|
|
7
6
|
|
|
8
7
|
def initialize base_url, resource_url, env, options = {}
|
|
9
8
|
@base_url = self[:base_url] = base_url
|
|
10
9
|
@resource_url = self[:resource_url] = resource_url
|
|
11
10
|
@resource_title = self[:resource_title] = options[:resource_title]
|
|
12
11
|
@env = self[:env] = env
|
|
12
|
+
@query_string = self[:query_string] = (env['QUERY_STRING'] && !env['QUERY_STRING'].empty? ? env['QUERY_STRING'] : nil)
|
|
13
13
|
merge!(options)
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'roar/decorator'
|
|
2
|
+
require 'roar/json/hal'
|
|
3
|
+
|
|
4
|
+
module PactBroker
|
|
5
|
+
module Api
|
|
6
|
+
module Decorators
|
|
7
|
+
module PaginationLinks
|
|
8
|
+
include Roar::JSON::HAL
|
|
9
|
+
include Roar::JSON::HAL::Links
|
|
10
|
+
|
|
11
|
+
link :next do | context |
|
|
12
|
+
if represented.respond_to?(:current_page) &&
|
|
13
|
+
represented.respond_to?(:page_count) &&
|
|
14
|
+
represented.current_page < represented.page_count
|
|
15
|
+
{
|
|
16
|
+
href: context[:resource_url] + "?pageSize=#{represented.page_size}&pageNumber=#{represented.current_page + 1}",
|
|
17
|
+
title: "Next page"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
link :previous do | context |
|
|
24
|
+
if represented.respond_to?(:first_page?) && !represented.first_page?
|
|
25
|
+
{
|
|
26
|
+
href: context[:resource_url] + "?pageSize=#{represented.page_size}&pageNumber=#{represented.current_page - 1}",
|
|
27
|
+
title: "Previous page"
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -20,14 +20,16 @@ module PactBroker
|
|
|
20
20
|
getter: -> (context) { context[:decorator].notices(context[:options][:user_options]) }
|
|
21
21
|
|
|
22
22
|
def notices(user_options)
|
|
23
|
-
|
|
23
|
+
metadata = represented.wip ? { wip: true } : nil
|
|
24
|
+
pact_url = pact_version_url_with_metadata(represented, metadata, user_options[:base_url])
|
|
24
25
|
PactBroker::Pacts::BuildVerifiablePactNotices.call(represented, pact_url, user_options)
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
link :self do | user_options |
|
|
30
|
+
metadata = represented.wip ? { wip: true } : nil
|
|
29
31
|
{
|
|
30
|
-
href:
|
|
32
|
+
href: pact_version_url_with_metadata(represented, metadata, user_options[:base_url]),
|
|
31
33
|
name: represented.name
|
|
32
34
|
}
|
|
33
35
|
end
|