Skip to main content
Swagger
All documentation pages

Configuration

Drift is flexible: you can configure the engine and its plugins via command-line parameters, environment variables, or configuration files (TOML, YAML, JSON, INI, JSON5, or RON).

Configuration Priority

If a value is defined in multiple places, Drift uses this precedence order:

  1. Command-line parameters (highest priority)

  2. Environment variables

  3. Configuration files (lowest priority)

Configuration Files

Drift supports these configuration file formats:

Search Order

Drift searches for configuration files in the following order (for any supported format above):

  1. OS Config Directory

    • Linux: $XDG_CONFIG_HOME or $HOME/.config/drift.config.{ext}

    • macOS: $HOME/Library/Application Support/drift.config.{ext}

    • Windows: %APPDATA%\drift.config.{ext}

  2. User Home: $HOME/.drift/drift.config.{ext}

  3. Application Home: The home_dir identified in the next section

Example Configuration File (TOML)

log_level = "info" # default the logging to INFO level
plugin_dir = "~/.drift/plugins" # override directory where the plugins are installed

[log_filters]
hyper_util = "info"
wasmtime_wasi = "info"

[plugin_config.json]
content_types = ["application/thrift"]

The Application Home Directory (home_dir)

The home_dir is the central location where Drift looks for executables, plugins, and configuration files. It is determined in the following order:

  1. The --drift-home-dir command-line parameter

  2. The DRIFT_HOME_DIR environment variable

  3. The directory where the Drift executable is run from

  4. The current working directory

Environment Variables

Any simple, non-collection configuration value can be specified as an environment variable using the prefix DRIFT_ followed by the setting name in SCREAMING_SNAKE_CASE.

  • Example: To set the logging level, use DRIFT_LOG_LEVEL=DEBUG.

PactFlow Authentication (Required)

Drift requires authentication to PactFlow or a Pact Broker to manage contracts and test workflows. Set these credentials as environment variables:

# PactFlow (recommended)
export PACTFLOW_BASE_URL="https://your-workspace.pactflow.io"
export PACTFLOW_TOKEN="your-api-token"

# Legacy Pact Broker
export PACT_BROKER_BASE_URL="https://your-broker.example.com"
export PACT_BROKER_TOKEN="your-token"

Where to get your token:

  • PactFlow: Navigate to Settings → API Tokens in your workspace

  • Pact Broker: Contact your broker administrator for API token details

Token types:

  • Read-only tokens: Suitable for local development and CI/CD pipelines that only read contracts

  • System account tokens: For CI/CD pipelines that publish contracts; requires appropriate permissions

See Authentication for more details on token types and PactFlow documentation for roles and permissions.

Core Configuration Values

Value Default Description
log_level INFO The logging level: TRACE, DEBUG, INFO, WARN, ERROR.
log_filters N/A Filter log entries based on target or spans.
home_dir See Section 3 Drift application home directory.
output_dir N/A Directory where output files (like reports) are written.
plugin_dir home_dir/plugins Directory where plugins are loaded from.
core_plugins N/A A list of plugins that are always loaded automatically.
servers N/A Server authentication configuration (see Section 7).
swaggerhub_hosts api.swaggerhub.com Hosts of the registry APIs whose documents Drift loads with a token from your PactFlow tenant. Setting this replaces the default list. See Remote Sources That Require Authentication.

Plugin Directory Logic

If not explicitly configured, the plugin_dir defaults to a folder named plugins within your home_dir. This is where standard plugins (OAS, JSON, Data, etc.) are expected to reside.

drift component installs plugins into the same directory. To install into a different directory, pass --plugin-dir or set the DRIFT_PLUGIN_DIR environment variable. To check which directories Drift resolved, run drift component info <name> --paths.

Server Authentication for Remote Sources

Drift allows you to manage credentials for remote URIs outside of your testcase files for improved security.

Using a Configuration File

Define server credentials in your config file. Drift uses a longest-match algorithm to find the correct credentials based on the source URL.

[servers.0]
url = "http://localhost:8000"
username = "lloyd"
secret = "chimps"

[servers.1]
url = "http://localhost:8000/secret"
username = "lloyd2"
secret = "monkeys"

Each server entry supports:

  • url (required): The base URL for the server

  • scheme: Authentication scheme - basic (default), bearer, or api-key

  • header: Header to use (defaults to authorization for most schemes, x-api-key for api-key)

  • username: Username for basic authentication

  • secret (required): Password (basic), token (bearer), or API key (api-key)

Remote Sources That Require Authentication

If Drift requests a remote drift.yaml source and the host refuses the request because it has no credentials, Drift requests credentials from your PactFlow tenant, using drift-auth, and fetches the document again. Public documents load as before.

Drift does this for documents hosted on the registry hosts in the swaggerhub_hosts setting. By default, these are:

  • api.swaggerhub.com

To use a different list, set swaggerhub_hosts. The list replaces the default, so include every host you need. Each name must match the whole host.

swaggerhub_hosts = [
  "api.swaggerhub.com",
  "swaggerhub.example.com"
]

You can also set this with the DRIFT_SWAGGERHUB_HOSTS environment variable, using a comma-separated list:

export DRIFT_SWAGGERHUB_HOSTS="api.swaggerhub.com,swaggerhub.example.com"

For more about signing in to PactFlow, see Authentication.

Download Source

By default, Drift downloads releases and components from https://download.pactflow.io/drift. This applies to drift component bootstrap, drift component install, drift component update, drift check-version, and the check for a newer version that Drift makes before it runs a command.

To download from a mirror instead, such as a repository in Artifactory or Nexus, set downloads.base_url:

[downloads]
base_url = "https://artifactory.example.com/artifactory/drift"

You can also set this with the DRIFT_DOWNLOADS__BASE_URL environment variable. Note the double underscore.

Mirror Credentials

Drift takes credentials for a mirror from the servers configuration described in Server Authentication for Remote Sources. The server whose url is a prefix of the download URL supplies the credentials. If several servers match, Drift uses the most specific one. For example, to use an Artifactory API key:

[downloads]
base_url = "https://artifactory.example.com/artifactory/drift"

[servers.0]
url = "https://artifactory.example.com/"
scheme = "api-key"
header = "X-JFrog-Art-Api"
secret = "..."

Set the secret with an environment variable, such as DRIFT_SERVERS_0_SECRET, rather than writing it into a configuration file.

Drift sends credentials only to URLs with the same scheme, host and port as the server’s url, so it does not pass them on when the mirror redirects a download to other storage. Drift never logs the credentials or records them in the installation’s record of where each component came from. Drift also uses the same credentials for drift component install --url when the URL is on the mirror.

Mirroring a Release

A mirror must be an unchanged copy of the published release layout, so that only the base URL differs:

<base_url>/
  version.txt                   the newest release, which "latest" resolves to
  latest/
    components.json             a copy of the newest release's components.json
  <version>/
    linux-x86_64.tgz            the platform bundles
    linux-aarch64.tgz
    macos-x86_64.tgz
    macos-aarch64.tgz
    windows-x86_64.tgz
    components.json             every component, with a checksum for every archive
    components/
      *.tgz                     the optional components

To mirror a release:

  1. Copy the files for the release from https://download.pactflow.io/drift/<version>/ without changing them.

  2. To make it the release that drift component update and the newer version check offer, update version.txt.

  3. Copy the release’s components.json to latest/components.json. The drift component list and drift component info commands read this file to show what is available.

The checksums in components.json are calculated when the release is published, so they stay valid on a copy. drift component install and drift component update verify every download against them.

Copy components.json with every release. Releases published before component management have none, so if the file is missing, drift component update installs the platform bundle without a checksum and warns that the bundle is unverified.

A mirror needs only the platforms and components you use. Requests for anything else fail.

Proxies and Certificates

Proxies

Drift uses the standard proxy environment variables:

Variable Used for
HTTPS_PROXY / https_proxy Proxy for HTTPS requests, such as http://proxy.example.com:8080.
HTTP_PROXY / http_proxy Proxy for plain HTTP requests.
ALL_PROXY / all_proxy Proxy for requests that the variables above do not cover.
NO_PROXY / no_proxy Comma-separated hosts, domains (.example.com) and IP ranges to connect to directly.

You can include proxy credentials in the proxy URL, such as http://user:password@proxy.example.com:8080. Percent-encode any special characters in them.

The proxy applies to all of Drift’s HTTP requests, including the requests drift-verify makes to the provider you are verifying. Add the provider’s host to NO_PROXY if Drift should reach it directly. Plain text HTTP/2 connections (h2c, used for gRPC without TLS) always connect directly.

If you don’t set any of these variables, Drift uses the proxy configured in the operating system on macOS (System Settings) and Windows (Internet Options). Drift does not support automatic proxy configuration (PAC) scripts. If you use a PAC script, set HTTPS_PROXY to the proxy that the script selects.

Certificates

Drift verifies HTTPS connections against the operating system’s trusted certificates: the Keychain on macOS, the certificate store on Windows, and the system CA bundle on Linux. A proxy that intercepts TLS works without any configuration when its CA certificate is installed in the system’s trust store.

If the CA certificate is distributed as a file, set ca_bundle to the path of a PEM file that contains one or more certificates. Drift trusts them in addition to the system’s certificates:

ca_bundle = "/etc/ssl/certs/corporate-ca.pem"

You can also set this with the DRIFT_CA_BUNDLE environment variable. If Drift cannot read the file, or the file contains no certificates, Drift fails with an error. Drift currently uses ca_bundle when it downloads releases and components. See Download Source.

On Linux, Drift also honors the SSL_CERT_FILE and SSL_CERT_DIR environment variables, but they replace the system’s certificates instead of adding to them. They have no effect on macOS or Windows. Drift has no option to turn off certificate verification.

Was this page helpful?