pact_broker-client 1.54.0 → 1.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +3 -1
- data/CHANGELOG.md +30 -0
- data/README.md +12 -2
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +222 -0
- data/lib/pact_broker/client/cli/matrix_commands.rb +3 -2
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/cli/webhook_commands.rb +17 -4
- data/lib/pact_broker/client/deployments/record_release.rb +5 -1
- data/lib/pact_broker/client/deployments/record_undeployment.rb +1 -1
- data/lib/pact_broker/client/environments/environment_command.rb +7 -2
- data/lib/pact_broker/client/git.rb +15 -4
- data/lib/pact_broker/client/hal/entity.rb +2 -2
- data/lib/pact_broker/client/hal/http_client.rb +4 -0
- data/lib/pact_broker/client/hal/link.rb +7 -2
- data/lib/pact_broker/client/publish_pacts.rb +5 -1
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/webhooks/create.rb +4 -0
- data/script/can-i-deploy.sh +5 -0
- data/script/record-deployments-and-releases.sh +3 -3
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +55 -0
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +6 -0
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +12 -1
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +1 -1
- data/spec/lib/pact_broker/client/git_spec.rb +46 -0
- data/spec/lib/pact_broker/client/hal/link_spec.rb +15 -0
- data/spec/pacts/pact_broker_client-pact_broker.json +234 -0
- data/spec/service_providers/webhooks_create_spec.rb +58 -0
- data/tasks/pact.rake +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d9a557ff00e502c4facd3905d6f30b5ab67c7c8c9e7810578dd9225f8ea3d68
|
4
|
+
data.tar.gz: e235879e8788aecb1fe818dee33ff67d510752b6fc72e2f6d3a5dc017fce3b75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea33ab913c9166b74d88d3df17cef602d3f4155fb1d3d354267bcd2be5a8e4b784ac7fa20136f5c56e244d8f074adc6e66a3324de94bb6f894ea48cc75c56d04
|
7
|
+
data.tar.gz: ca291e99e8702dfebaaab039067519b4dd141e1d57c58fe7313117ed6e1d882aeaa43a23704524836c12e1e17ae21df433263089323d4b956975b06a8d36002a
|
data/.github/workflows/test.yml
CHANGED
@@ -20,6 +20,8 @@ jobs:
|
|
20
20
|
with:
|
21
21
|
ruby-version: ${{ matrix.ruby_version }}
|
22
22
|
- run: "bundle install"
|
23
|
+
- if: failure()
|
24
|
+
run: cat /opt/hostedtoolcache/Ruby/2.2.10/x64/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/approvals-0.0.25/gem_make.out && exit 1
|
23
25
|
- run: "bundle exec rake"
|
24
26
|
pact:
|
25
27
|
runs-on: "ubuntu-latest"
|
@@ -37,7 +39,7 @@ jobs:
|
|
37
39
|
- run: |
|
38
40
|
rm -rf spec/pacts/*
|
39
41
|
bundle exec rspec spec/service_providers/
|
40
|
-
bundle exec rake pact:publish:pactflow
|
42
|
+
VERBOSE=true bundle exec rake pact:publish:pactflow
|
41
43
|
env:
|
42
44
|
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_PACT_OSS_TOKEN }}
|
43
45
|
PACT_BROKER_FEATURES: ${{ matrix.feature }}
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
<a name="v1.58.0"></a>
|
2
|
+
### v1.58.0 (2021-11-13)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* remove feature toggle for creating contract_requiring_verification_published webhooks ([6eff6d1](/../../commit/6eff6d1))
|
7
|
+
|
8
|
+
<a name="v1.57.0"></a>
|
9
|
+
### v1.57.0 (2021-11-05)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* support the --branch option in the version selectors for can-i-deploy ([dba8ec4](/../../commit/dba8ec4))
|
14
|
+
* show more helpful error message if pb:environments not available for pactflow ([1bf38e3](/../../commit/1bf38e3))
|
15
|
+
* print out notices if returned from publish pacts request ([86caf7e](/../../commit/86caf7e))
|
16
|
+
|
17
|
+
<a name="v1.56.0"></a>
|
18
|
+
### v1.56.0 (2021-10-06)
|
19
|
+
|
20
|
+
#### Features
|
21
|
+
|
22
|
+
* add pacticipant label options to webhook create/update commands (#96) ([710293f](/../../commit/710293f))
|
23
|
+
|
24
|
+
<a name="v1.55.0"></a>
|
25
|
+
### v1.55.0 (2021-10-03)
|
26
|
+
|
27
|
+
#### Features
|
28
|
+
|
29
|
+
* support Github Actions environment variables for --tag-with-git-branch ([2b8dac5](/../../commit/2b8dac5))
|
30
|
+
|
1
31
|
<a name="v1.54.0"></a>
|
2
32
|
### v1.54.0 (2021-10-01)
|
3
33
|
|
data/README.md
CHANGED
@@ -607,8 +607,12 @@ Options:
|
|
607
607
|
# Webhook basic auth username and password eg. username:password
|
608
608
|
[--consumer=CONSUMER]
|
609
609
|
# Consumer name
|
610
|
+
[--consumer-label=CONSUMER_LABEL]
|
611
|
+
# Consumer label
|
610
612
|
[--provider=PROVIDER]
|
611
613
|
# Provider name
|
614
|
+
[--provider-label=PROVIDER_LABEL]
|
615
|
+
# Provider label
|
612
616
|
[--description=DESCRIPTION]
|
613
617
|
# Webhook description
|
614
618
|
[--contract-content-changed], [--no-contract-content-changed]
|
@@ -663,8 +667,12 @@ Options:
|
|
663
667
|
# Webhook basic auth username and password eg. username:password
|
664
668
|
[--consumer=CONSUMER]
|
665
669
|
# Consumer name
|
670
|
+
[--consumer-label=CONSUMER_LABEL]
|
671
|
+
# Consumer label
|
666
672
|
[--provider=PROVIDER]
|
667
673
|
# Provider name
|
674
|
+
[--provider-label=PROVIDER_LABEL]
|
675
|
+
# Provider label
|
668
676
|
[--description=DESCRIPTION]
|
669
677
|
# Webhook description
|
670
678
|
[--contract-content-changed], [--no-contract-content-changed]
|
@@ -829,11 +837,13 @@ require 'pact_broker/client/tasks'
|
|
829
837
|
|
830
838
|
PactBroker::Client::PublicationTask.new do | task |
|
831
839
|
require 'my_consumer/version'
|
832
|
-
task.consumer_version =
|
840
|
+
task.consumer_version = ENV["GIT_COMMIT"]
|
833
841
|
task.pattern = 'custom/path/to/pacts/*.json' # optional, default value is 'spec/pacts/*.json'
|
834
842
|
task.pact_broker_base_url = "http://pact-broker"
|
835
|
-
task.
|
843
|
+
task.branch = ENV["GIT_BRANCH"] # Optional but STRONGLY RECOMMENDED.
|
844
|
+
task.tag_with_git_branch = true|false # Superseeded by the `branch` property
|
836
845
|
task.tags = ["dev"] # optional
|
846
|
+
task.build_url = ENV["CI_BUILD_URL"]
|
837
847
|
task.pact_broker_basic_auth = { username: 'basic_auth_user', password: 'basic_auth_pass'} # optional
|
838
848
|
task.pact_broker_token = "1234abcd" # Bearer token
|
839
849
|
task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists. Not recommended, as it makes a mulch of the workflow on the broker.
|
@@ -64,10 +64,14 @@
|
|
64
64
|
|
65
65
|
* [A request to create a webhook with a JSON body for a consumer and provider](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_and_provider_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
66
66
|
|
67
|
+
* [A request to create a webhook with a JSON body for a consumer specified by a label](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_specified_by_a_label)
|
68
|
+
|
67
69
|
* [A request to create a webhook with a JSON body for a consumer that does not exist](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_that_does_not_exist)
|
68
70
|
|
69
71
|
* [A request to create a webhook with a JSON body for a provider](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_provider_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
70
72
|
|
73
|
+
* [A request to create a webhook with a JSON body for a provider specified by a label](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_provider_specified_by_a_label)
|
74
|
+
|
71
75
|
* [A request to create a webhook with a non-JSON body for a consumer and provider](#a_request_to_create_a_webhook_with_a_non-JSON_body_for_a_consumer_and_provider_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
72
76
|
|
73
77
|
* [A request to create a webhook with every possible event type](#a_request_to_create_a_webhook_with_every_possible_event_type_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
@@ -1089,6 +1093,16 @@ Pact Broker will respond with:
|
|
1089
1093
|
},
|
1090
1094
|
"body": {
|
1091
1095
|
"description": "a webhook",
|
1096
|
+
"request": {
|
1097
|
+
"body": {
|
1098
|
+
"some": "body"
|
1099
|
+
}
|
1100
|
+
},
|
1101
|
+
"events": [
|
1102
|
+
{
|
1103
|
+
"name": "contract_content_changed"
|
1104
|
+
}
|
1105
|
+
],
|
1092
1106
|
"_links": {
|
1093
1107
|
"self": {
|
1094
1108
|
"href": "http://localhost:1234/some-url",
|
@@ -1222,6 +1236,16 @@ Pact Broker will respond with:
|
|
1222
1236
|
},
|
1223
1237
|
"body": {
|
1224
1238
|
"description": "a webhook",
|
1239
|
+
"request": {
|
1240
|
+
"body": {
|
1241
|
+
"some": "body"
|
1242
|
+
}
|
1243
|
+
},
|
1244
|
+
"events": [
|
1245
|
+
{
|
1246
|
+
"name": "contract_content_changed"
|
1247
|
+
}
|
1248
|
+
],
|
1225
1249
|
"_links": {
|
1226
1250
|
"self": {
|
1227
1251
|
"href": "http://localhost:1234/some-url",
|
@@ -1276,6 +1300,16 @@ Pact Broker will respond with:
|
|
1276
1300
|
},
|
1277
1301
|
"body": {
|
1278
1302
|
"description": "a webhook",
|
1303
|
+
"request": {
|
1304
|
+
"body": {
|
1305
|
+
"some": "body"
|
1306
|
+
}
|
1307
|
+
},
|
1308
|
+
"events": [
|
1309
|
+
{
|
1310
|
+
"name": "contract_content_changed"
|
1311
|
+
}
|
1312
|
+
],
|
1279
1313
|
"_links": {
|
1280
1314
|
"self": {
|
1281
1315
|
"href": "http://localhost:1234/some-url",
|
@@ -1327,6 +1361,80 @@ Pact Broker will respond with:
|
|
1327
1361
|
},
|
1328
1362
|
"body": {
|
1329
1363
|
"description": "a webhook",
|
1364
|
+
"request": {
|
1365
|
+
"body": {
|
1366
|
+
"some": "body"
|
1367
|
+
}
|
1368
|
+
},
|
1369
|
+
"events": [
|
1370
|
+
{
|
1371
|
+
"name": "contract_content_changed"
|
1372
|
+
}
|
1373
|
+
],
|
1374
|
+
"_links": {
|
1375
|
+
"self": {
|
1376
|
+
"href": "http://localhost:1234/some-url",
|
1377
|
+
"title": "A title"
|
1378
|
+
}
|
1379
|
+
}
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
```
|
1383
|
+
<a name="a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_specified_by_a_label"></a>
|
1384
|
+
Upon receiving **a request to create a webhook with a JSON body for a consumer specified by a label** from Pact Broker Client, with
|
1385
|
+
```json
|
1386
|
+
{
|
1387
|
+
"method": "post",
|
1388
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
1389
|
+
"headers": {
|
1390
|
+
"Content-Type": "application/json",
|
1391
|
+
"Accept": "application/hal+json"
|
1392
|
+
},
|
1393
|
+
"body": {
|
1394
|
+
"description": "a webhook",
|
1395
|
+
"events": [
|
1396
|
+
{
|
1397
|
+
"name": "contract_content_changed"
|
1398
|
+
}
|
1399
|
+
],
|
1400
|
+
"request": {
|
1401
|
+
"url": "https://webhook",
|
1402
|
+
"method": "POST",
|
1403
|
+
"headers": {
|
1404
|
+
"Foo": "bar",
|
1405
|
+
"Bar": "foo"
|
1406
|
+
},
|
1407
|
+
"body": {
|
1408
|
+
"some": "body"
|
1409
|
+
},
|
1410
|
+
"username": "username",
|
1411
|
+
"password": "password"
|
1412
|
+
},
|
1413
|
+
"consumer": {
|
1414
|
+
"label": "consumer_label"
|
1415
|
+
}
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
```
|
1419
|
+
Pact Broker will respond with:
|
1420
|
+
```json
|
1421
|
+
{
|
1422
|
+
"status": 201,
|
1423
|
+
"headers": {
|
1424
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1425
|
+
},
|
1426
|
+
"body": {
|
1427
|
+
"description": "a webhook",
|
1428
|
+
"request": {
|
1429
|
+
"body": {
|
1430
|
+
"some": "body"
|
1431
|
+
}
|
1432
|
+
},
|
1433
|
+
"events": [
|
1434
|
+
{
|
1435
|
+
"name": "contract_content_changed"
|
1436
|
+
}
|
1437
|
+
],
|
1330
1438
|
"_links": {
|
1331
1439
|
"self": {
|
1332
1440
|
"href": "http://localhost:1234/some-url",
|
@@ -1433,6 +1541,80 @@ Pact Broker will respond with:
|
|
1433
1541
|
},
|
1434
1542
|
"body": {
|
1435
1543
|
"description": "a webhook",
|
1544
|
+
"request": {
|
1545
|
+
"body": {
|
1546
|
+
"some": "body"
|
1547
|
+
}
|
1548
|
+
},
|
1549
|
+
"events": [
|
1550
|
+
{
|
1551
|
+
"name": "contract_content_changed"
|
1552
|
+
}
|
1553
|
+
],
|
1554
|
+
"_links": {
|
1555
|
+
"self": {
|
1556
|
+
"href": "http://localhost:1234/some-url",
|
1557
|
+
"title": "A title"
|
1558
|
+
}
|
1559
|
+
}
|
1560
|
+
}
|
1561
|
+
}
|
1562
|
+
```
|
1563
|
+
<a name="a_request_to_create_a_webhook_with_a_JSON_body_for_a_provider_specified_by_a_label"></a>
|
1564
|
+
Upon receiving **a request to create a webhook with a JSON body for a provider specified by a label** from Pact Broker Client, with
|
1565
|
+
```json
|
1566
|
+
{
|
1567
|
+
"method": "post",
|
1568
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
1569
|
+
"headers": {
|
1570
|
+
"Content-Type": "application/json",
|
1571
|
+
"Accept": "application/hal+json"
|
1572
|
+
},
|
1573
|
+
"body": {
|
1574
|
+
"description": "a webhook",
|
1575
|
+
"events": [
|
1576
|
+
{
|
1577
|
+
"name": "contract_content_changed"
|
1578
|
+
}
|
1579
|
+
],
|
1580
|
+
"request": {
|
1581
|
+
"url": "https://webhook",
|
1582
|
+
"method": "POST",
|
1583
|
+
"headers": {
|
1584
|
+
"Foo": "bar",
|
1585
|
+
"Bar": "foo"
|
1586
|
+
},
|
1587
|
+
"body": {
|
1588
|
+
"some": "body"
|
1589
|
+
},
|
1590
|
+
"username": "username",
|
1591
|
+
"password": "password"
|
1592
|
+
},
|
1593
|
+
"provider": {
|
1594
|
+
"label": "provider_label"
|
1595
|
+
}
|
1596
|
+
}
|
1597
|
+
}
|
1598
|
+
```
|
1599
|
+
Pact Broker will respond with:
|
1600
|
+
```json
|
1601
|
+
{
|
1602
|
+
"status": 201,
|
1603
|
+
"headers": {
|
1604
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1605
|
+
},
|
1606
|
+
"body": {
|
1607
|
+
"description": "a webhook",
|
1608
|
+
"request": {
|
1609
|
+
"body": {
|
1610
|
+
"some": "body"
|
1611
|
+
}
|
1612
|
+
},
|
1613
|
+
"events": [
|
1614
|
+
{
|
1615
|
+
"name": "contract_content_changed"
|
1616
|
+
}
|
1617
|
+
],
|
1436
1618
|
"_links": {
|
1437
1619
|
"self": {
|
1438
1620
|
"href": "http://localhost:1234/some-url",
|
@@ -1482,6 +1664,14 @@ Pact Broker will respond with:
|
|
1482
1664
|
},
|
1483
1665
|
"body": {
|
1484
1666
|
"description": "a webhook",
|
1667
|
+
"request": {
|
1668
|
+
"body": "<xml></xml>"
|
1669
|
+
},
|
1670
|
+
"events": [
|
1671
|
+
{
|
1672
|
+
"name": "contract_content_changed"
|
1673
|
+
}
|
1674
|
+
],
|
1485
1675
|
"_links": {
|
1486
1676
|
"self": {
|
1487
1677
|
"href": "http://localhost:1234/some-url",
|
@@ -1545,6 +1735,28 @@ Pact Broker will respond with:
|
|
1545
1735
|
},
|
1546
1736
|
"body": {
|
1547
1737
|
"description": "a webhook",
|
1738
|
+
"request": {
|
1739
|
+
"body": {
|
1740
|
+
"some": "body"
|
1741
|
+
}
|
1742
|
+
},
|
1743
|
+
"events": [
|
1744
|
+
{
|
1745
|
+
"name": "contract_content_changed"
|
1746
|
+
},
|
1747
|
+
{
|
1748
|
+
"name": "contract_published"
|
1749
|
+
},
|
1750
|
+
{
|
1751
|
+
"name": "provider_verification_published"
|
1752
|
+
},
|
1753
|
+
{
|
1754
|
+
"name": "provider_verification_succeeded"
|
1755
|
+
},
|
1756
|
+
{
|
1757
|
+
"name": "provider_verification_failed"
|
1758
|
+
}
|
1759
|
+
],
|
1548
1760
|
"_links": {
|
1549
1761
|
"self": {
|
1550
1762
|
"href": "http://localhost:1234/some-url",
|
@@ -2550,6 +2762,16 @@ Pact Broker will respond with:
|
|
2550
2762
|
},
|
2551
2763
|
"body": {
|
2552
2764
|
"description": "a webhook",
|
2765
|
+
"request": {
|
2766
|
+
"body": {
|
2767
|
+
"some": "body"
|
2768
|
+
}
|
2769
|
+
},
|
2770
|
+
"events": [
|
2771
|
+
{
|
2772
|
+
"name": "contract_content_changed"
|
2773
|
+
}
|
2774
|
+
],
|
2553
2775
|
"_links": {
|
2554
2776
|
"self": {
|
2555
2777
|
"href": "http://localhost:1234/some-url",
|
@@ -13,6 +13,7 @@ module PactBroker
|
|
13
13
|
method_option :ignore, required: false, desc: "The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option."
|
14
14
|
method_option :latest, required: false, aliases: "-l", banner: "[TAG]", desc: "Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag."
|
15
15
|
method_option :to_environment, required: false, banner: "ENVIRONMENT", desc: "The environment into which the pacticipant(s) are to be deployed", default: nil
|
16
|
+
method_option :branch, required: false, desc: "The branch of the version for which you want to check the verification results", default: nil
|
16
17
|
method_option :to, required: false, banner: "TAG", desc: "The tag that represents the branch or environment of the integrated applications for which you want to check the verification result status.", default: nil
|
17
18
|
method_option :output, aliases: "-o", desc: "json or table", default: "table"
|
18
19
|
method_option :retry_while_unknown, banner: "TIMES", type: :numeric, default: 0, required: false, desc: "The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)"
|
@@ -77,8 +78,8 @@ module PactBroker
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def validate_can_i_deploy_selectors selectors
|
80
|
-
pacticipants_without_versions = selectors.select{ |s| s[:version].nil? && s[:latest].nil? && s[:tag].nil? }.collect{ |s| s[:pacticipant] }
|
81
|
-
raise ::Thor::RequiredArgumentMissingError, "The version must be specified using `--version VERSION`, `--latest`, `--latest TAG`, or `--all TAG` for pacticipant #{pacticipants_without_versions.join(", ")}" if pacticipants_without_versions.any?
|
81
|
+
pacticipants_without_versions = selectors.select{ |s| s[:version].nil? && s[:latest].nil? && s[:tag].nil? && s[:branch].nil? }.collect{ |s| s[:pacticipant] }
|
82
|
+
raise ::Thor::RequiredArgumentMissingError, "The version must be specified using `--version VERSION`, `--branch BRANCH` `--latest`, `--latest TAG`, or `--all TAG` for pacticipant #{pacticipants_without_versions.join(", ")}" if pacticipants_without_versions.any?
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
@@ -31,6 +31,10 @@ module PactBroker
|
|
31
31
|
when "--latest", "-l"
|
32
32
|
selectors << { pacticipant: nil } if selectors.empty?
|
33
33
|
selectors.last[:tag] = word
|
34
|
+
when "--branch"
|
35
|
+
selectors << { pacticipant: nil } if selectors.empty?
|
36
|
+
selectors.last[:branch] = word
|
37
|
+
selectors.last[:latest] = true
|
34
38
|
when "--all"
|
35
39
|
selectors << { pacticipant: nil } if selectors.empty?
|
36
40
|
selectors.last[:tag] = word
|
@@ -15,16 +15,16 @@ module PactBroker
|
|
15
15
|
method_option :data, aliases: "-d", desc: "Webhook payload (file or string)"
|
16
16
|
method_option :user, aliases: "-u", desc: "Webhook basic auth username and password eg. username:password"
|
17
17
|
method_option :consumer, desc: "Consumer name"
|
18
|
+
method_option :consumer_label, desc: "Consumer label, mutually exclusive with consumer name"
|
18
19
|
method_option :provider, desc: "Provider name"
|
20
|
+
method_option :provider_label, desc: "Provider label, mutually exclusive with provider name"
|
19
21
|
method_option :description, desc: "Webhook description"
|
20
22
|
method_option :contract_content_changed, type: :boolean, desc: "Trigger this webhook when the pact content changes"
|
21
23
|
method_option :contract_published, type: :boolean, desc: "Trigger this webhook when a pact is published"
|
22
24
|
method_option :provider_verification_published, type: :boolean, desc: "Trigger this webhook when a provider verification result is published"
|
23
25
|
method_option :provider_verification_failed, type: :boolean, desc: "Trigger this webhook when a failed provider verification result is published"
|
24
26
|
method_option :provider_verification_succeeded, type: :boolean, desc: "Trigger this webhook when a successful provider verification result is published"
|
25
|
-
|
26
|
-
method_option :contract_requiring_verification_published, type: :boolean, desc: "Trigger this webhook when a contract is published that requires verification"
|
27
|
-
end
|
27
|
+
method_option :contract_requiring_verification_published, type: :boolean, desc: "Trigger this webhook when a contract is published that requires verification"
|
28
28
|
method_option :team_uuid, banner: "UUID", desc: "UUID of the Pactflow team to which the webhook should be assigned (Pactflow only)"
|
29
29
|
shared_authentication_options
|
30
30
|
end
|
@@ -70,6 +70,7 @@ module PactBroker
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def parse_webhook_options(webhook_url)
|
73
|
+
validate_mutual_exclusiveness_of_participant_name_and_label_options
|
73
74
|
events = parse_webhook_events
|
74
75
|
|
75
76
|
# TODO update for contract_requiring_verification_published when released
|
@@ -102,7 +103,9 @@ module PactBroker
|
|
102
103
|
password: password,
|
103
104
|
body: body,
|
104
105
|
consumer: options.consumer,
|
106
|
+
consumer_label: options.consumer_label,
|
105
107
|
provider: options.provider,
|
108
|
+
provider_label: options.provider_label,
|
106
109
|
events: events,
|
107
110
|
team_uuid: options.team_uuid
|
108
111
|
}
|
@@ -118,10 +121,20 @@ module PactBroker
|
|
118
121
|
rescue PactBroker::Client::Error => e
|
119
122
|
raise WebhookCreationError, "#{e.class} - #{e.message}"
|
120
123
|
end
|
124
|
+
|
125
|
+
def validate_mutual_exclusiveness_of_participant_name_and_label_options
|
126
|
+
if options.consumer && options.consumer_label
|
127
|
+
raise WebhookCreationError.new("Consumer name (--consumer) and label (--consumer_label) options are mutually exclusive")
|
128
|
+
end
|
129
|
+
|
130
|
+
if options.provider && options.provider_label
|
131
|
+
raise WebhookCreationError.new("Provider name (--provider) and label (--provider_label) options are mutually exclusive")
|
132
|
+
end
|
133
|
+
end
|
121
134
|
end
|
122
135
|
end
|
123
136
|
end
|
124
137
|
end
|
125
138
|
end
|
126
139
|
end
|
127
|
-
end
|
140
|
+
end
|
@@ -30,7 +30,11 @@ module PactBroker
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def not_supported_message
|
33
|
-
|
33
|
+
if is_pactflow?
|
34
|
+
"This version of Pactflow does not support recording #{action}s, or you do not have the required permission to read environments. Please upgrade to the latest version if using Pactflow On-Premises, and ensure the user has the environment read permission."
|
35
|
+
else
|
36
|
+
"This version of the Pact Broker does not support recording #{action}s. Please upgrade to version 2.80.0 or later."
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
def environment_exists?
|
@@ -108,7 +108,7 @@ module PactBroker
|
|
108
108
|
potential_application_instances = currently_deployed_version_entities_for_pacticipant.collect{|e| e.applicationInstance || e.target }
|
109
109
|
|
110
110
|
if application_instance
|
111
|
-
omit_text = potential_application_instances.include?(nil) ? "omit the application instance
|
111
|
+
omit_text = potential_application_instances.include?(nil) ? "omit the application instance" : nil
|
112
112
|
specify_text = potential_application_instances.compact.any? ? "specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}" : nil
|
113
113
|
"#{pacticipant_name} is not currently deployed to application instance '#{application_instance}' in #{environment_name} environment. Please #{[omit_text, specify_text].compact.join(" or ")}."
|
114
114
|
else
|
@@ -5,6 +5,7 @@ module PactBroker
|
|
5
5
|
module Environments
|
6
6
|
class EnvironmentCommand < PactBroker::Client::BaseCommand
|
7
7
|
NOT_SUPPORTED_MESSAGE = "This version of the Pact Broker does not support environments. Please upgrade to version 2.80.0 or later."
|
8
|
+
PACTFLOW_NOT_SUPPORTED_MESSAGE = "This version of Pactflow does not support environments or you do not have the required permission to read them. Please upgrade to the latest version if using Pactflow On-Premises and ensure the user has the environment read permission."
|
8
9
|
|
9
10
|
private
|
10
11
|
|
@@ -39,7 +40,7 @@ module PactBroker
|
|
39
40
|
@existing_environment_params ||= existing_environment_resource!
|
40
41
|
.response
|
41
42
|
.body
|
42
|
-
.except("uuid", "_links", "createdAt", "updatedAt")
|
43
|
+
.except("uuid", "_links", "_embedded", "createdAt", "updatedAt")
|
43
44
|
end
|
44
45
|
|
45
46
|
def contacts
|
@@ -57,7 +58,11 @@ module PactBroker
|
|
57
58
|
|
58
59
|
def check_if_command_supported
|
59
60
|
unless index_resource.can?("pb:environments")
|
60
|
-
|
61
|
+
if is_pactflow?
|
62
|
+
raise PactBroker::Client::Error.new(PACTFLOW_NOT_SUPPORTED_MESSAGE)
|
63
|
+
else
|
64
|
+
raise PactBroker::Client::Error.new(NOT_SUPPORTED_MESSAGE)
|
65
|
+
end
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
@@ -25,9 +25,8 @@ module PactBroker
|
|
25
25
|
using PactBroker::Client::HashRefinements
|
26
26
|
|
27
27
|
COMMAND = 'git rev-parse --abbrev-ref HEAD'.freeze
|
28
|
-
BRANCH_ENV_VAR_NAMES = %w{BUILDKITE_BRANCH CIRCLE_BRANCH TRAVIS_BRANCH GIT_BRANCH GIT_LOCAL_BRANCH APPVEYOR_REPO_BRANCH CI_COMMIT_REF_NAME BITBUCKET_BRANCH}.freeze
|
29
|
-
COMMIT_ENV_VAR_NAMES = %w{BUILDKITE_COMMIT CIRCLE_SHA1 TRAVIS_COMMIT GIT_COMMIT APPVEYOR_REPO_COMMIT CI_COMMIT_ID BITBUCKET_COMMIT}
|
30
|
-
|
28
|
+
BRANCH_ENV_VAR_NAMES = %w{GITHUB_REF BUILDKITE_BRANCH CIRCLE_BRANCH TRAVIS_BRANCH GIT_BRANCH GIT_LOCAL_BRANCH APPVEYOR_REPO_BRANCH CI_COMMIT_REF_NAME BITBUCKET_BRANCH}.freeze
|
29
|
+
COMMIT_ENV_VAR_NAMES = %w{GITHUB_SHA BUILDKITE_COMMIT CIRCLE_SHA1 TRAVIS_COMMIT GIT_COMMIT APPVEYOR_REPO_COMMIT CI_COMMIT_ID BITBUCKET_COMMIT}
|
31
30
|
BUILD_URL_ENV_VAR_NAMES = %w{BUILDKITE_BUILD_URL CIRCLE_BUILD_URL TRAVIS_BUILD_WEB_URL BUILD_URL }
|
32
31
|
|
33
32
|
def self.commit
|
@@ -38,6 +37,10 @@ module PactBroker
|
|
38
37
|
find_branch_from_known_env_vars || find_branch_from_env_var_ending_with_branch || branch_from_git_command(options[:raise_error])
|
39
38
|
end
|
40
39
|
|
40
|
+
def self.build_url
|
41
|
+
github_build_url || BUILD_URL_ENV_VAR_NAMES.collect{ | name | value_from_env_var(name) }.compact.first
|
42
|
+
end
|
43
|
+
|
41
44
|
# private
|
42
45
|
|
43
46
|
def self.find_commit_from_env_vars
|
@@ -45,7 +48,8 @@ module PactBroker
|
|
45
48
|
end
|
46
49
|
|
47
50
|
def self.find_branch_from_known_env_vars
|
48
|
-
BRANCH_ENV_VAR_NAMES.collect { |env_var_name| value_from_env_var(env_var_name) }.compact.first
|
51
|
+
val = BRANCH_ENV_VAR_NAMES.collect { |env_var_name| value_from_env_var(env_var_name) }.compact.first
|
52
|
+
val.gsub(%r{^refs/heads/}, "") if val
|
49
53
|
end
|
50
54
|
|
51
55
|
def self.find_branch_from_env_var_ending_with_branch
|
@@ -104,6 +108,13 @@ module PactBroker
|
|
104
108
|
return []
|
105
109
|
end
|
106
110
|
end
|
111
|
+
|
112
|
+
def self.github_build_url
|
113
|
+
parts = %w{GITHUB_SERVER_URL GITHUB_REPOSITORY GITHUB_RUN_ID}.collect{ | name | value_from_env_var(name) }
|
114
|
+
if parts.all?
|
115
|
+
[parts[0], parts[1], "actions", "runs", parts[2]].join("/")
|
116
|
+
end
|
117
|
+
end
|
107
118
|
end
|
108
119
|
end
|
109
120
|
end
|
@@ -141,9 +141,9 @@ module PactBroker
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def method_missing(method_name, *args, &block)
|
144
|
-
if @data.key?(method_name.to_s)
|
144
|
+
if @data.respond_to?(:key?) && @data.key?(method_name.to_s)
|
145
145
|
@data[method_name.to_s]
|
146
|
-
elsif @links.key?(method_name)
|
146
|
+
elsif @links.respond_to?(:key?) && @links.key?(method_name)
|
147
147
|
Link.new(@links[method_name], @client).run(*args)
|
148
148
|
else
|
149
149
|
nil
|
@@ -86,11 +86,16 @@ module PactBroker
|
|
86
86
|
private
|
87
87
|
|
88
88
|
def wrap_response(href, http_response)
|
89
|
-
require
|
89
|
+
require "pact_broker/client/hal/entity" # avoid circular reference
|
90
90
|
if http_response.success?
|
91
91
|
Entity.new(href, http_response.body, @http_client, http_response)
|
92
92
|
else
|
93
|
-
|
93
|
+
body = begin
|
94
|
+
http_response.header("Content-Type") && http_response.header("Content-Type").include?("json") ? http_response.body : http_response.raw_body
|
95
|
+
rescue
|
96
|
+
http_response.raw_body
|
97
|
+
end
|
98
|
+
ErrorEntity.new(href, body, @http_client, http_response)
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -86,7 +86,11 @@ module PactBroker
|
|
86
86
|
"Successfully published pacts"
|
87
87
|
end
|
88
88
|
else
|
89
|
-
|
89
|
+
if response_entity.notices
|
90
|
+
PactBroker::Client::ColorizeNotices.call(response_entity.notices.collect{ |n| OpenStruct.new(n) } )
|
91
|
+
else
|
92
|
+
::Term::ANSIColor.red(response_entity.response.raw_body)
|
93
|
+
end
|
90
94
|
end
|
91
95
|
end.join("\n")
|
92
96
|
end
|