Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verifier CLI: configure provider from environment variables #419

Closed
mjpieters opened this issue May 15, 2024 · 3 comments · Fixed by #422
Closed

Verifier CLI: configure provider from environment variables #419

mjpieters opened this issue May 15, 2024 · 3 comments · Fixed by #422

Comments

@mjpieters
Copy link
Contributor

Currently, the verifier CLI takes the provider configuration from CLI switches:

Provider options:
  -h, --hostname <hostname>
          Provider hostname (defaults to localhost)
  -p, --port <port>
          Provider port (defaults to protocol default 80/443)
      --transport <transport>
          Provider protocol transport to use (http, https, grpc, etc.) [default: http]
      --transports <transports>
          Allows multiple protocol transports to be configured (http, https, grpc, etc.) with their associated port numbers separated by a colon. For example, use --transports http:8080 grpc:5555 to configure both.
  -n, --provider-name <provider-name>
          Provider name (defaults to provider)
      --base-path <base-path>
          Base path to add to all requests
      --request-timeout <request-timeout>
          Sets the HTTP request timeout in milliseconds for requests to the target API and for state change requests.
  -H, --header <custom-header>
          Add a custom header to be included in the calls to the provider. Values must be in the form KEY=VALUE, where KEY and VALUE contain ASCII characters (32-127) only. Can be repeated.
      --disable-ssl-verification
          Disables validation of SSL certificates

We have a docker-compose setup with the (instrumented) provider running in a container, and want to use the pactfoundation/pact-ref-verifier docker container to run the verification. Ideally, the pact broker configuration for this setup would come from environment variables, so I can just specify these in the docker-compose service.

E.g. the docker-compose could look like this:

services:
  # An instrumented version of the application API for Pact verification
  pact_provider:
     # service configuration ...
     # service accepts connections on port 5000 

  pact_verifier:
    image: pactfoundation/pact-ref-verifier:latest
    depends_on:
      pact_provider:
        condition: service_healthy
    environment:
      # these are hypothetical environment names, to configure how to access the pact broker
      PACT_PROVIDER_HOSTNAME: pact_provider
      PACT_PROVIDER_PORT: 5000
      PACT_PROVIDER_NAME: SomeProviderName
      PACT_PROVIDER_STATE_CHANGE_URL: http://pact_provider:5000/_pact/provider_states
      PACT_PROVIDER_STATE_CHANGE_TEARDOWN: yes

The advantage is that this configuration now lives right next to the provider configuration that dictates these settings.

@YOU54F
Copy link
Member

YOU54F commented May 15, 2024

That is easily do-able

https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_verifier_cli/src/args.rs#L151

here the envs are read in for the token, password or username

would you be up for a PR.

@mjpieters
Copy link
Contributor Author

mjpieters commented May 16, 2024

Yup, I can put up a PR for this. I'll model them on the Ruby verifier.

@YOU54F
Copy link
Member

YOU54F commented May 16, 2024

awesome! thank you very much

mjpieters added a commit to mjpieters/pact-reference that referenced this issue May 16, 2024
This covers options most often used in CI environments, and should make
configuration of the verifier easier using just environment variables.

Fixes pact-foundation#419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants