faucet-common-gcs
Shared Google Cloud Storage credentials and client construction for the GCS source and sink connectors. Part of the faucet-stream ecosystem.
This is a small internal/shared crate: it holds the one credential enum and the async client builders that both faucet-source-gcs and faucet-sink-gcs need, so the two crates accept exactly the same credentials: shape and build their GCS clients the same way. It is built on the official google-cloud-storage SDK and google-cloud-auth.
What it provides
GcsCredentials
A tagged enum that serializes as the project-wide { type, config } auth wire shape — adjacent tagging (#[serde(tag = "type", content = "config")]) with snake_case discriminators — so YAML/JSON configs read consistently across every faucet connector. Derives Serialize + Deserialize + JsonSchema + Clone + Default.
| Variant | YAML | Notes |
|---|---|---|
application_default (default) |
{ type: application_default } |
Application Default Credentials — honours GOOGLE_APPLICATION_CREDENTIALS, gcloud auth application-default login user creds, and the GCE/GKE metadata server, in that order. |
service_account_json_file |
{ type: service_account_json_file, config: { path: /run/secrets/sa.json } } |
Reads a service-account JSON key file from disk. |
service_account_json_inline |
{ type: service_account_json_inline, config: { json: "${env:GCP_SA_JSON}" } } |
Service-account JSON key as an inline string. Pairs with ${env:…} / ${secret:…} interpolation in CLI configs. |
anonymous |
{ type: anonymous } |
Unauthenticated. Use only with emulators (e.g. fake-gcs-server) that don't validate bearer tokens — never in production. |
Client builders
All three are async and map every failure to FaucetError::Auth with a message that includes the underlying SDK / I/O error.
pub async ;
pub async ;
pub async ;
build_credentialsresolves aGcsCredentialsspec into agoogle-cloud-authcredential handle (the shared step both client builders call first).build_storagereturns the data-planeStorageclient used by source reads and sink writes (read_object,write_object).build_storage_controlreturns the control-planeStorageControlclient used by source object listings (list_objects).storage_hostis an integration-test escape hatch — passNonein production. Tests targetfake-gcs-serverwithSome("http://127.0.0.1:4443"), which sets the client endpoint.
Who depends on this
You usually don't depend on this crate directly. End users configure GCS through faucet-source-gcs / faucet-sink-gcs (both re-export GcsCredentials), or through the faucet CLI via the source-gcs / sink-gcs features. Depend on faucet-common-gcs only if you are a third-party connector author building your own GCS source/sink for the faucet ecosystem and want to stay interchangeable with the first-party connectors' credential shape and client construction.
Installation
Usage
use ;
async
In a faucet config, the same enum is what the GCS source/sink accept under credentials::
credentials:
type: service_account_json_inline
config:
json: "${env:GCP_SA_JSON}"
Troubleshooting / FAQ
| Symptom | Likely cause / fix |
|---|---|
FaucetError::Auth: GCS auth (ADC): … |
Application Default Credentials could not be resolved. Set GOOGLE_APPLICATION_CREDENTIALS, run gcloud auth application-default login, or run on a GCE/GKE node with a metadata server. |
GCS auth: could not read service-account key from '…' |
The path for service_account_json_file is wrong or unreadable by the process. Check the path and file permissions. |
GCS auth: … is not valid JSON |
The service-account key (file or inline) isn't valid JSON. For service_account_json_inline, confirm the env var / secret holds the full JSON, not a path. |
| Requests fail against an emulator | The SDK tries to fetch ADC tokens by default. Use type: anonymous with emulators like fake-gcs-server, and pass the emulator endpoint via storage_host. |
Why two clients? GCS splits object I/O (Storage, data plane) from bucket/object metadata operations like listing (StorageControl, control plane). The source needs both; the sink needs only Storage.
See also
faucet-source-gcsandfaucet-sink-gcs— the connectors that consume these types.- faucet-stream documentation — connector reference and cookbook.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.