pact_broker-client 1.62.1 → 1.65.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b538507a19176ca7164ac025f35358738e9d49ab61a41a20d560fee5478cd2f
4
- data.tar.gz: 7e562c453ead13f3bceba18f99ff2ed1fd556e9b07de3088038759514ed95a35
3
+ metadata.gz: b5ce83ded78258ca61aefff4934a129bde296db9e546db32adb5db1f48ebcbc7
4
+ data.tar.gz: 1ee2e0c2d0b143c5cc97918c4b4cd2bf6d5d7e281450e1eb194f19295a7c1e21
5
5
  SHA512:
6
- metadata.gz: 18e472c85e88525ef6c3b7714953db64c14bdc55ba6a80f1eb985b50f5c16dcc3f3d743d900b4ed06d7125581e382e10ddf4b8c6df760582b41f5d5b84b28dd7
7
- data.tar.gz: 58bac0fbb0772d36cfe57e085ab465a3ff191f0bfb383428d30476a86b44e9ec0514dc77ee6d9f90cf9d4672c0377a8e46e0c324f825375a0aa63674ce0da613
6
+ metadata.gz: 19f2f40ef25b345cb64e8a392f580cc5eeee4468d6798eb9c008d5b3adf9d1c18f20dee9250d11d22829f368e3ae90ceef24ea28fec233198331e5f11c2dc5cc
7
+ data.tar.gz: d980e5fb92df5886697851caa30d419bfda19b3c05af8f2e08c23fb54742c960cf7f49d12638e32a739dc3c3590a8ad36e3a102825bc942bfc1a1a493dfeb1a5
@@ -9,19 +9,14 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- ruby_version: ["2.2", "2.7"]
12
+ ruby_version: ["2.7", "3.0", "3.1"]
13
13
  experimental: [false]
14
- include:
15
- - ruby_version: "3.0"
16
- experimental: true
17
14
  steps:
18
15
  - uses: actions/checkout@v2
19
16
  - uses: ruby/setup-ruby@v1
20
17
  with:
21
18
  ruby-version: ${{ matrix.ruby_version }}
22
19
  - 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
25
20
  - run: "bundle exec rake"
26
21
  pact:
27
22
  runs-on: "ubuntu-latest"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ <a name="v1.65.0"></a>
2
+ ### v1.65.0 (2022-06-24)
3
+
4
+ #### Features
5
+
6
+ * add support for automatically detecting the git commit and branch for Azure DevOps ([889f83f](/../../commit/889f83f))
7
+
8
+ <a name="v1.64.0"></a>
9
+ ### v1.64.0 (2022-05-27)
10
+
11
+ #### Features
12
+
13
+ * remove feature flag for publish-provider-contract ([146a2d8](/../../commit/146a2d8))
14
+ * add pactflow specific message for environment not found when recording a release/deployment ([6667cbb](/../../commit/6667cbb))
15
+
16
+ <a name="v1.63.0"></a>
17
+ ### v1.63.0 (2022-05-10)
18
+
19
+ #### Features
20
+
21
+ * add --verification-exit-code to publish-provider-contract command ([d35d908](/../../commit/d35d908))
22
+
1
23
  <a name="v1.62.1"></a>
2
24
  ### v1.62.1 (2022-05-10)
3
25
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.6-alpine3.12
1
+ FROM ruby:3.1-alpine
2
2
 
3
3
  RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing hub
4
4
  RUN apk add --update --no-cache git openssh bash
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pact Broker Client
2
2
 
3
- A client for the [Pact Broker](https://docs.pact.io/pact_broker/). Publishes and retrieves pacts, verification results, pacticipants, pacticipant versions and tags. The functionality is available via a CLI, or via Ruby Rake tasks. You can also use the [Pact CLI Docker image](https://hub.docker.com/r/pactfoundation/pact-cli).
3
+ A client for the [Pact Broker](https://docs.pact.io/pact_broker/) and [Pactflow](https://pactflow.io/?utm_source=ossdocs&utm_campaign=pact_broker_client_readme). Publishes and retrieves pacts, pacticipants, pacticipant versions, environments, deployments and releases. Supports publishing provider contracts for Pactflow. The functionality is available via a CLI, or via Ruby Rake tasks. You can also use the [Pact CLI Docker image](https://hub.docker.com/r/pactfoundation/pact-cli).
4
4
 
5
5
  ![Build status](https://github.com/pact-foundation/pact_broker-client/workflows/Test/badge.svg)
6
6
 
@@ -32,6 +32,8 @@ To connect to a Pact Broker that uses custom SSL cerificates, set the environmen
32
32
 
33
33
  ## Usage - CLI
34
34
 
35
+ All commands prefixed with `pact-broker` can be used with the OSS Pact Broker and Pactflow. Commands prefixed with `pactflow` can only be used with Pactflow.
36
+
35
37
  The Pact Broker base URL can be specified either using the environment variable `$PACT_BROKER_BASE_URL` or the `-b` or `--broker-base-url` parameters.
36
38
 
37
39
  Pact Broker authentication can be performed either using basic auth or a bearer token.
@@ -58,13 +60,17 @@ Options:
58
60
  # Repository branch of the consumer version
59
61
  [--auto-detect-version-properties], [--no-auto-detect-version-properties]
60
62
  # Automatically detect the repository branch from known CI
61
- environment variables or git CLI.
63
+ environment variables or git CLI. Supports Buildkite, Circle
64
+ CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor,
65
+ GitLab, CodeShip, Bitbucket and Azure DevOps.
62
66
  -t, [--tag=TAG]
63
67
  # Tag name for consumer version. Can be specified multiple
64
68
  times.
65
69
  -g, [--tag-with-git-branch], [--no-tag-with-git-branch]
66
70
  # Tag consumer version with the name of the current git branch.
67
- Default: false
71
+ Supports Buildkite, Circle CI, Travis CI, GitHub Actions,
72
+ Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and
73
+ Azure DevOps. Default: false
68
74
  [--build-url=BUILD_URL]
69
75
  # The build URL that created the pact
70
76
  [--merge], [--no-merge]
@@ -460,7 +466,13 @@ Options:
460
466
  [--dry-run], [--no-dry-run]
461
467
  # When dry-run is enabled, always exit process with a success
462
468
  code. Can also be enabled by setting the environment variable
463
- PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true.
469
+ PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true. This mode is useful when
470
+ setting up your CI/CD pipeline for the first time, or in a
471
+ 'break glass' situation where you need to knowingly deploy what
472
+ Pact considers a breaking change. For the second scenario, it
473
+ is recommended to use the environment variable and just set it
474
+ for the build required to deploy that particular version, so
475
+ you don't accidentally leave the dry run mode enabled.
464
476
  -b, --broker-base-url=BROKER_BASE_URL
465
477
  # The base URL of the Pact Broker
466
478
  -u, [--broker-username=BROKER_USERNAME]
@@ -860,6 +872,64 @@ Options:
860
872
 
861
873
  Generate a UUID for use when calling create-or-update-webhook
862
874
 
875
+ ### Provider contracts (Pactflow only)
876
+
877
+ #### publish-provider-contract
878
+
879
+ ```
880
+ Usage:
881
+ pactflow publish-provider-contract CONTRACT_FILE ... --provider=PROVIDER -a, --provider-app-version=PROVIDER_APP_VERSION -b, --broker-base-url=BROKER_BASE_URL
882
+
883
+ Options:
884
+ --provider=PROVIDER
885
+ # The provider name
886
+ -a, --provider-app-version=PROVIDER_APP_VERSION
887
+ # The provider application version
888
+ -h, [--branch=BRANCH]
889
+ # Repository branch of the provider version
890
+ -t, [--tag=TAG]
891
+ # Tag name for provider version. Can be specified multiple
892
+ times.
893
+ [--specification=SPECIFICATION]
894
+ # The contract specification
895
+ # Default: oas
896
+ [--content-type=CONTENT_TYPE]
897
+ # The content type. eg. application/yml
898
+ [--verification-success], [--no-verification-success]
899
+ # Whether or not the self verification passed successfully.
900
+ [--verification-exit-code=N]
901
+ # The exit code of the verification process. Can be used instead
902
+ of --verification-success|--no-verification-success for a
903
+ simpler build script.
904
+ [--verification-results=VERIFICATION_RESULTS]
905
+ # The path to the file containing the output from the
906
+ verification process
907
+ [--verification-results-content-type=VERIFICATION_RESULTS_CONTENT_TYPE]
908
+ # The content type of the verification output eg. text/plain,
909
+ application/yaml
910
+ [--verification-results-format=VERIFICATION_RESULTS_FORMAT]
911
+ # The format of the verification output eg. junit, text
912
+ [--verifier=VERIFIER]
913
+ # The tool used to verify the provider contract
914
+ [--verifier-version=VERIFIER_VERSION]
915
+ # The version of the tool used to verify the provider contract
916
+ -o, [--output=OUTPUT]
917
+ # json or text
918
+ # Default: text
919
+ -b, --broker-base-url=BROKER_BASE_URL
920
+ # The base URL of the Pact Broker
921
+ -u, [--broker-username=BROKER_USERNAME]
922
+ # Pact Broker basic auth username
923
+ -p, [--broker-password=BROKER_PASSWORD]
924
+ # Pact Broker basic auth password
925
+ -k, [--broker-token=BROKER_TOKEN]
926
+ # Pact Broker bearer token
927
+ -v, [--verbose], [--no-verbose]
928
+ # Verbose output. Default: false
929
+ ```
930
+
931
+ Publish provider contract to Pactflow
932
+
863
933
  <!-- end-autogenerated-docs -->
864
934
 
865
935
  ## Usage - Ruby
@@ -20,7 +20,7 @@ module PactBroker
20
20
  method_option :retry_interval, banner: "SECONDS", type: :numeric, default: 10, required: false, desc: "The time between retries in seconds. Use in conjuction with --retry-while-unknown"
21
21
  # Allow limit to be set manually until https://github.com/pact-foundation/pact_broker-client/issues/53 is fixed
22
22
  method_option :limit, hide: true
23
- method_option :dry_run, type: :boolean, default: false, desc: "When dry-run is enabled, always exit process with a success code. Can also be enabled by setting the environment variable PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true."
23
+ method_option :dry_run, type: :boolean, default: false, desc: "When dry-run is enabled, always exit process with a success code. Can also be enabled by setting the environment variable PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true. This mode is useful when setting up your CI/CD pipeline for the first time, or in a 'break glass' situation where you need to knowingly deploy what Pact considers a breaking change. For the second scenario, it is recommended to use the environment variable and just set it for the build required to deploy that particular version, so you don't accidentally leave the dry run mode enabled."
24
24
  shared_authentication_options
25
25
 
26
26
  def can_i_deploy(*ignored_but_necessary)
@@ -14,9 +14,9 @@ module PactBroker
14
14
  desc 'publish PACT_DIRS_OR_FILES ...', "Publish pacts to a Pact Broker."
15
15
  method_option :consumer_app_version, required: true, aliases: "-a", desc: "The consumer application version"
16
16
  method_option :branch, aliases: "-h", desc: "Repository branch of the consumer version"
17
- method_option :auto_detect_version_properties, hidden: true, type: :boolean, default: false, desc: "Automatically detect the repository branch from known CI environment variables or git CLI."
17
+ method_option :auto_detect_version_properties, type: :boolean, default: false, desc: "Automatically detect the repository branch from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps."
18
18
  method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for consumer version. Can be specified multiple times."
19
- method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag consumer version with the name of the current git branch. Default: false"
19
+ method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag consumer version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. Default: false"
20
20
  method_option :build_url, desc: "The build URL that created the pact"
21
21
  method_option :merge, type: :boolean, default: false, require: false, desc: "If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes."
22
22
  output_option_json_or_text
@@ -64,7 +64,11 @@ module PactBroker
64
64
  if environment_exists?
65
65
  "Environment '#{environment_name}' is not an available option for recording a deployment of #{pacticipant_name}."
66
66
  else
67
- "No environment found with name '#{environment_name}'."
67
+ if is_pactflow?
68
+ "Environment '#{environment_name}' is not an available option for recording a deployment of #{pacticipant_name}. The environment may not exist, or you may not have the required permissions or team associations to view it."
69
+ else
70
+ "No environment found with name '#{environment_name}'."
71
+ end
68
72
  end
69
73
  end
70
74
 
@@ -13,7 +13,7 @@ CI_COMMIT_REF_NAME https://docs.gitlab.com/ee/ci/variables/predefined_variables.
13
13
  CI_BRANCH CI_COMMIT_ID https://documentation.codeship.com/pro/builds-and-configuration/environment-variables/
14
14
  bamboo.repository.git.branch https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html
15
15
  BITBUCKET_BRANCH BITBUCKET_COMMIT https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html
16
-
16
+ BUILD_SOURCEBRANCHNAME BUILD_SOURCEVERSION Azure
17
17
  =end
18
18
 
19
19
  # Keep in sync with pact-provider-verifier/lib/pact/provider_verifier/git.rb
@@ -25,8 +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{GITHUB_HEAD_REF 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}
28
+ BRANCH_ENV_VAR_NAMES = %w{GITHUB_HEAD_REF GITHUB_REF BUILDKITE_BRANCH CIRCLE_BRANCH TRAVIS_BRANCH GIT_BRANCH GIT_LOCAL_BRANCH APPVEYOR_REPO_BRANCH CI_COMMIT_REF_NAME BITBUCKET_BRANCH BUILD_SOURCEBRANCHNAME}.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 BUILD_SOURCEVERSION}
30
30
  BUILD_URL_ENV_VAR_NAMES = %w{BUILDKITE_BUILD_URL CIRCLE_BUILD_URL TRAVIS_BUILD_WEB_URL BUILD_URL }
31
31
 
32
32
  def self.commit
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.62.1'
3
+ VERSION = '1.65.0'
4
4
  end
5
5
  end
@@ -8,33 +8,55 @@ module Pactflow
8
8
 
9
9
  def self.included(thor)
10
10
  thor.class_eval do
11
+ desc 'publish-provider-contract CONTRACT_FILE ...', "Publish provider contract to Pactflow"
12
+ method_option :provider, required: true, desc: "The provider name"
13
+ method_option :provider_app_version, required: true, aliases: "-a", desc: "The provider application version"
14
+ method_option :branch, aliases: "-h", desc: "Repository branch of the provider version"
15
+ #method_option :auto_detect_version_properties, hidden: true, type: :boolean, default: false, desc: "Automatically detect the repository branch from known CI environment variables or git CLI."
16
+ method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for provider version. Can be specified multiple times."
17
+ #method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag consumer version with the name of the current git branch. Default: false"
18
+ method_option :specification, default: "oas", desc: "The contract specification"
19
+ method_option :content_type, desc: "The content type. eg. application/yml"
20
+ method_option :verification_success, type: :boolean, desc: "Whether or not the self verification passed successfully."
21
+ method_option :verification_exit_code, type: :numeric, desc: "The exit code of the verification process. Can be used instead of --verification-success|--no-verification-success for a simpler build script."
22
+ method_option :verification_results, desc: "The path to the file containing the output from the verification process"
23
+ method_option :verification_results_content_type, desc: "The content type of the verification output eg. text/plain, application/yaml"
24
+ method_option :verification_results_format, desc: "The format of the verification output eg. junit, text"
25
+ method_option :verifier, desc: "The tool used to verify the provider contract"
26
+ method_option :verifier_version, desc: "The version of the tool used to verify the provider contract"
27
+ #method_option :build_url, desc: "The build URL that created the pact"
11
28
 
12
- if ENV.fetch("PACTFLOW_FEATURES", "").include?("publish-provider-contract")
29
+ output_option_json_or_text
30
+ shared_authentication_options
13
31
 
14
- desc 'publish-provider-contract CONTRACT_FILE ...', "Publish provider contract to Pactflow"
15
- method_option :provider, required: true, desc: "The provider name"
16
- method_option :provider_app_version, required: true, aliases: "-a", desc: "The provider application version"
17
- method_option :branch, aliases: "-h", desc: "Repository branch of the provider version"
18
- #method_option :auto_detect_version_properties, hidden: true, type: :boolean, default: false, desc: "Automatically detect the repository branch from known CI environment variables or git CLI."
19
- method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for provider version. Can be specified multiple times."
20
- #method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag consumer version with the name of the current git branch. Default: false"
21
- method_option :specification, default: "oas", desc: "The contract specification"
22
- method_option :content_type, desc: "The content type. eg. application/yml"
23
- method_option :verification_success, type: :boolean
24
- method_option :verification_results, desc: "The path to the file containing the output from the verification process"
25
- method_option :verification_results_content_type, desc: "The content type of the verification output eg. text/plain, application/yaml"
26
- method_option :verification_results_format, desc: "The format of the verification output eg. junit, text"
27
- method_option :verifier, desc: "The tool used to verify the provider contract"
28
- method_option :verifier_version, desc: "The version of the tool used to verify the provider contract"
29
- #method_option :build_url, desc: "The build URL that created the pact"
32
+ def publish_provider_contract(provider_contract_path)
33
+ require "pactflow/client/provider_contracts/publish"
30
34
 
31
- output_option_json_or_text
32
- shared_authentication_options
35
+ validate_publish_provider_contract_options(provider_contract_path)
36
+ result = ::Pactflow::Client::ProviderContracts::Publish.call(
37
+ publish_provider_contract_command_params(provider_contract_path),
38
+ command_options,
39
+ pact_broker_client_options
40
+ )
41
+ $stdout.puts result.message
42
+ exit(1) unless result.success
43
+ end
44
+
45
+ no_commands do
46
+ def command_options
47
+ { verbose: options.verbose, output: options.output }
48
+ end
33
49
 
34
- def publish_provider_contract(provider_contract_path)
35
- require "pactflow/client/provider_contracts/publish"
50
+ def validate_publish_provider_contract_options(provider_contract_path)
51
+ if !options.verification_success.nil? && options.verification_exit_code
52
+ raise Thor::Error, "Cannot use both --verification-success|--no-verification-success and --verification-exit-code"
53
+ end
54
+ end
55
+
56
+ def publish_provider_contract_command_params(provider_contract_path)
57
+ success = !options.verification_success.nil? ? options.verification_success : ( options.verification_exit_code && options.verification_exit_code == 0 )
36
58
 
37
- params = params = {
59
+ {
38
60
  provider_name: options.provider.strip,
39
61
  provider_version_number: options.provider_app_version.strip,
40
62
  branch_name: options.branch && options.branch.strip,
@@ -45,7 +67,7 @@ module Pactflow
45
67
  specification: options.specification
46
68
  },
47
69
  verification_results: {
48
- success: options.verification_success,
70
+ success: success,
49
71
  content: options.verification_results ? File.read(options.verification_results) : nil,
50
72
  content_type: options.verification_results_content_type,
51
73
  format: options.verification_results_format,
@@ -53,11 +75,6 @@ module Pactflow
53
75
  verifier_version: options.verifier_version
54
76
  }
55
77
  }
56
-
57
- command_options = { verbose: options.verbose, output: options.output }
58
- result = ::Pactflow::Client::ProviderContracts::Publish.call(params, command_options, pact_broker_client_options)
59
- $stdout.puts result.message
60
- exit(1) unless result.success
61
78
  end
62
79
  end
63
80
  end
@@ -23,7 +23,7 @@ module Pactflow
23
23
  def do_call
24
24
  create_branch_version_and_tags
25
25
  create_contract
26
- PactBroker::Client::CommandResult.new(true, green("Successfully published provider contract for #{provider_name} version #{provider_version_number}"))
26
+ PactBroker::Client::CommandResult.new(true, green("Successfully published provider contract for #{provider_name} version #{provider_version_number} to Pactflow"))
27
27
  end
28
28
 
29
29
  def create_branch_version_and_tags
@@ -58,10 +58,10 @@ module Pactflow
58
58
  }.compact
59
59
 
60
60
  body_params = {
61
- content: encode_content(contract[:content]),
62
- contractType: contract[:specification],
63
- contentType: contract[:content_type],
64
- }.compact
61
+ content: encode_content(contract[:content]),
62
+ contractType: contract[:specification],
63
+ contentType: contract[:content_type],
64
+ }.compact
65
65
 
66
66
  if verification_results_params.any?
67
67
  body_params[:verificationResults] = verification_results_params
@@ -1,5 +1,21 @@
1
- export PACT_BROKER_BASE_URL="http://localhost:9292"
2
- export PACTFLOW_FEATURES=publish-provider-contract
1
+ export PACT_BROKER_BASE_URL=${PACT_BROKER_BASE_URL:-"http://localhost:9292"}
2
+ bundle exec bin/pactflow publish-provider-contract \
3
+ script/oas.yml \
4
+ --provider Foo \
5
+ --provider-app-version 1013b5650d61214e19f10558f97fb5a3bb082d44 \
6
+ --branch main \
7
+ --tag dev \
8
+ --specification oas \
9
+ --content-type application/yml \
10
+ --verification-exit-code 0 \
11
+ --verification-results script/verification-results.txt \
12
+ --verification-results-content-type text/plain \
13
+ --verification-results-format text \
14
+ --verifier my-custom-tool \
15
+ --verifier-version "1.0" \
16
+ --verbose
17
+
18
+
3
19
  # bundle exec bin/pactflow publish-provider-contract \
4
20
  # script/oas.yml \
5
21
  # --provider Foo \
@@ -7,21 +23,5 @@ export PACTFLOW_FEATURES=publish-provider-contract
7
23
  # --branch main \
8
24
  # --tag dev \
9
25
  # --specification oas \
10
- # --content-type application/yml \
11
- # --no-verification-success \
12
- # --verification-results script/verification-results.txt \
13
- # --verification-results-content-type text/plain \
14
- # --verification-results-format text \
15
- # --verifier my-custom-tool \
16
- # --verifier-version "1.0" \
17
- # --verbose
18
-
26
+ # --content-type application/yml
19
27
 
20
- bundle exec bin/pactflow publish-provider-contract \
21
- script/oas.yml \
22
- --provider Foo \
23
- --provider-app-version 1013b5650d61214e19f10558f97fb5a3bb082d44 \
24
- --branch main \
25
- --tag dev \
26
- --specification oas \
27
- --content-type application/yml
@@ -1,12 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "stringio"
3
3
  require "pact_broker/client/cli/broker"
4
+ require "pactflow/client/cli/pactflow"
4
5
 
5
6
  ENV["THOR_COLUMNS"] = "160"
6
7
  START_MARKER = "<!-- start-autogenerated-docs -->"
7
8
  END_MARKER = "<!-- end-autogenerated-docs -->"
8
9
  TERMINAL_WIDTH = 80
9
10
 
11
+ PACT_BROKER_COMMAND_GROUPS = [
12
+ [PactBroker::Client::CLI::Broker, "Pacts", %w[publish list-latest-pact-versions] ],
13
+ [PactBroker::Client::CLI::Broker, "Environments", %w[create-environment update-environment describe-environment delete-environment list-environments]],
14
+ [PactBroker::Client::CLI::Broker, "Deployments", %w[record-deployment record-undeployment]],
15
+ [PactBroker::Client::CLI::Broker, "Releases", %w[record-release record-support-ended]],
16
+ [PactBroker::Client::CLI::Broker, "Matrix", %w[can-i-deploy]],
17
+ [PactBroker::Client::CLI::Broker, "Pacticipants", %w[create-or-update-pacticipant describe-pacticipant list-pacticipants]],
18
+ [PactBroker::Client::CLI::Broker, "Webhooks", %w[create-webhook create-or-update-webhook test-webhook]],
19
+ [PactBroker::Client::CLI::Broker, "Tags", %w[create-version-tag]],
20
+ [PactBroker::Client::CLI::Broker, "Versions", %w[describe-version create-or-update-version]],
21
+ [PactBroker::Client::CLI::Broker, "Miscellaneous", %w[generate-uuid]]
22
+ ]
23
+
24
+ PACTFLOW_COMMAND_GROUPS = [
25
+ [Pactflow::Client::CLI::Pactflow, "Provider contracts (Pactflow only)", %w[publish-provider-contract]]
26
+ ]
27
+
10
28
  def print_wrapped(message, options = {})
11
29
  out = StringIO.new
12
30
  indent = options[:indent] || 0
@@ -44,29 +62,16 @@ def format_banner(banner)
44
62
  banner_lines
45
63
  end
46
64
 
47
- def generate_thor_docs
65
+ def generate_thor_docs(command_groups)
48
66
  begin
49
67
  out = StringIO.new
50
68
  $stdout = out
51
69
 
52
- command_groups = [
53
- ["Pacts", %w[publish list-latest-pact-versions] ],
54
- ["Environments", %w[create-environment update-environment describe-environment delete-environment list-environments]],
55
- ["Deployments", %w[record-deployment record-undeployment]],
56
- ["Releases", %w[record-release record-support-ended]],
57
- ["Matrix", %w[can-i-deploy]],
58
- ["Pacticipants", %w[create-or-update-pacticipant describe-pacticipant list-pacticipants]],
59
- ["Webhooks", %w[create-webhook create-or-update-webhook test-webhook]],
60
- ["Tags", %w[create-version-tag]],
61
- ["Versions", %w[describe-version create-or-update-version]],
62
- ["Miscellaneous", %w[generate-uuid]]
63
- ]
64
-
65
- command_groups.collect do | group, commands |
70
+ command_groups.collect do | cli, group, commands |
66
71
  puts "### #{group}\n\n"
67
72
  commands.each do | command |
68
73
  puts "#### #{command}\n\n"
69
- PactBroker::Client::CLI::Broker.start(["help", command])
74
+ cli.start(["help", command])
70
75
  puts "\n"
71
76
  end
72
77
  end
@@ -110,7 +115,7 @@ end
110
115
  @current_state = :start
111
116
  @old_state = nil
112
117
 
113
- def reformat_docs(generated_thor_docs)
118
+ def reformat_docs(generated_thor_docs, command)
114
119
  generated_thor_docs.split("\n").collect do | line |
115
120
  @old_state = @current_state
116
121
 
@@ -142,7 +147,7 @@ def reformat_docs(generated_thor_docs)
142
147
  .collect { | line | line.gsub(/\s+$/, "") }
143
148
  .join("\n")
144
149
  .gsub("/go/", "/")
145
- .gsub(File.basename(__FILE__), "pact-broker")
150
+ .gsub(File.basename(__FILE__), command)
146
151
  end
147
152
 
148
153
  def update_readme(usage_docs)
@@ -153,4 +158,7 @@ def update_readme(usage_docs)
153
158
  File.open("README.md", "w") { |file| file << new_readme_text }
154
159
  end
155
160
 
156
- update_readme(reformat_docs(generate_thor_docs))
161
+ pact_broker_docs = reformat_docs(generate_thor_docs(PACT_BROKER_COMMAND_GROUPS), "pact-broker")
162
+ pactflow_docs = reformat_docs(generate_thor_docs(PACTFLOW_COMMAND_GROUPS), "pactflow")
163
+
164
+ update_readme(pact_broker_docs + "\n\n" + pactflow_docs)
@@ -164,6 +164,15 @@ module PactBroker
164
164
  expect(subject.success).to be false
165
165
  expect(subject.message).to include "No environment found with name 'test'. Available options: prod"
166
166
  end
167
+
168
+ context "when the server is Pactflow" do
169
+ let(:index_headers) { { "Content-Type" => "application/hal+json", "X-Pactflow-Sha" => "123" } }
170
+
171
+ it "returns a customised message" do
172
+ expect(subject.message).to include "Environment 'test' is not an available option for recording a deployment of Foo"
173
+ expect(subject.message).to include "permissions"
174
+ end
175
+ end
167
176
  end
168
177
 
169
178
  context "when the environment does exist" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.62.1
4
+ version: 1.65.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-10 00:00:00.000000000 Z
11
+ date: 2022-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -438,7 +438,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
438
438
  - !ruby/object:Gem::Version
439
439
  version: '0'
440
440
  requirements: []
441
- rubygems_version: 3.3.13
441
+ rubygems_version: 3.3.16
442
442
  signing_key:
443
443
  specification_version: 4
444
444
  summary: See description