Skip to content

Commit

Permalink
docs: update CLI usage in README
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 6, 2023
1 parent a9f87a8 commit 5dcb2a1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 19 deletions.
80 changes: 64 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ Options:
-e, [--version=VERSION]
# The pacticipant version. Must be entered after the
--pacticipant that it relates to.
[--ignore=IGNORE]
[--ignore=PACTICIPANT]
# 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. The
Expand All @@ -458,10 +458,6 @@ Options:
# The tag that represents the branch or environment of the
integrated applications for which you want to check the
verification result status.
[--ignore=IGNORE]
# 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.
-o, [--output=OUTPUT]
# json or table
# Default: table
Expand Down Expand Up @@ -505,8 +501,8 @@ Description:
support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, please see
https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/

Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The "test"
and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The
"test" and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
https://docs.pact.io/pact_broker/client_cli/readme#environments for more information.

$ pact-broker create-environment --name "uat" --display-name "UAT" --no-production
Expand All @@ -516,17 +512,17 @@ Description:

$ pact-broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat

Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy with
the versions of each integrated application that are already in that environment.
Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy
with the versions of each integrated application that are already in that environment.

$ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT

Example: can I deploy version 173153ae0 of application Foo to the test environment?

$ pact-broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test

Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the latest version
from the main branch of another application" it functions as a "can I merge" check.
Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the
latest version from the main branch of another application" it functions as a "can I merge" check.

$ pact-broker can-i-deploy --pacticipant Foo 173153ae0 \ --pacticipant Bar --latest main

Expand All @@ -536,6 +532,56 @@ If the verification process takes a long time and there are results missing when
command to poll and wait for the missing results to arrive. The arguments to specify are `--retry-while-unknown TIMES` and `--retry-interval SECONDS`, set to
appropriate values for your pipeline.

#### can-i-merge

```
Usage:
pact-broker can-i-merge -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
Options:
-a, --pacticipant=PACTICIPANT
# The pacticipant name. Use once for each pacticipant being
checked.
-e, [--version=VERSION]
# The pacticipant version. Must be entered after the
--pacticipant that it relates to.
-o, [--output=OUTPUT]
# json or table
# Default: table
[--retry-while-unknown=TIMES]
# The number of times to retry while there is an unknown
verification result (ie. the provider verification is likely
still running)
# Default: 0
[--retry-interval=SECONDS]
# The time between retries in seconds. Use in conjuction with
--retry-while-unknown
# Default: 10
[--dry-run], [--no-dry-run]
# 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_MERGE_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.
-b, --broker-base-url=BROKER_BASE_URL
# The base URL of the Pact Broker
-u, [--broker-username=BROKER_USERNAME]
# Pact Broker basic auth username
-p, [--broker-password=BROKER_PASSWORD]
# Pact Broker basic auth password
-k, [--broker-token=BROKER_TOKEN]
# Pact Broker bearer token
-v, [--verbose], [--no-verbose]
# Verbose output. Default: false
```

Description:
Checks if the specified pacticipant version is compatible with the configured main branch of each of the pacticipants with which it is integrated.

### Pacticipants

#### create-or-update-pacticipant
Expand Down Expand Up @@ -679,8 +725,8 @@ Options:
```

Description:
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the consumer,
provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the
consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.

Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
option. Please use the --broker-username or environment variable for the Pact Broker username.
Expand Down Expand Up @@ -744,9 +790,9 @@ Options:
```

Description:
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and add the
consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid must
also be provided. You can generate a valid UUID by using the `generate-uuid` command.
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and
add the consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid
must also be provided. You can generate a valid UUID by using the `generate-uuid` command.

Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
option. Please use the --broker-username or environment variable for the Pact Broker username.
Expand Down Expand Up @@ -930,6 +976,8 @@ Options:
# The tool used to verify the provider contract
[--verifier-version=VERIFIER_VERSION]
# The version of the tool used to verify the provider contract
[--build-url=BUILD_URL]
# The build URL that created the provider contract
-o, [--output=OUTPUT]
# json or text
# Default: text
Expand Down
3 changes: 1 addition & 2 deletions lib/pact_broker/client/cli/matrix_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ def self.included(thor)

method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
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. The environment variable PACT_BROKER_CAN_I_DEPLOY_IGNORE may also be used to specify a pacticipant name to ignore, with commas to separate multiple pacticipant names if necessary."
method_option :ignore, required: false, banner: "PACTICIPANT", 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. The environment variable PACT_BROKER_CAN_I_DEPLOY_IGNORE may also be used to specify a pacticipant name to ignore, with commas to separate multiple pacticipant names if necessary."
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."
method_option :branch, required: false, desc: "The branch of the version for which you want to check the verification results.", default: nil
method_option :main_branch, required: false, type: :boolean, desc: "Use the latest version of the configured main branch of the pacticipant as the version for which you want to check the verification results", default: false
method_option :to_environment, required: false, banner: "ENVIRONMENT", desc: "The environment into which the pacticipant(s) are to be deployed", default: nil
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
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."
method_option :output, aliases: "-o", desc: "json or table", default: "table"
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)"
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"
Expand Down
2 changes: 1 addition & 1 deletion script/update-cli-usage-in-readme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[PactBroker::Client::CLI::Broker, "Environments", %w[create-environment update-environment describe-environment delete-environment list-environments]],
[PactBroker::Client::CLI::Broker, "Deployments", %w[record-deployment record-undeployment]],
[PactBroker::Client::CLI::Broker, "Releases", %w[record-release record-support-ended]],
[PactBroker::Client::CLI::Broker, "Matrix", %w[can-i-deploy]],
[PactBroker::Client::CLI::Broker, "Matrix", %w[can-i-deploy can-i-merge]],
[PactBroker::Client::CLI::Broker, "Pacticipants", %w[create-or-update-pacticipant describe-pacticipant list-pacticipants]],
[PactBroker::Client::CLI::Broker, "Webhooks", %w[create-webhook create-or-update-webhook test-webhook]],
[PactBroker::Client::CLI::Broker, "Tags", %w[create-version-tag]],
Expand Down

0 comments on commit 5dcb2a1

Please sign in to comment.