mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
docs(skill): wire Python Secret Manager to the emulator explicitly (#71)
The Python client ignores SECRET_MANAGER_EMULATOR_HOST and still targets secretmanager.googleapis.com, so the skill's claim that client libraries skip credentials when these variables are set was wrong for it. Add a recipe with the REST transport, an explicit endpoint and anonymous credentials, and link it from the README and the Docker reference. Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
ac52515471
commit
94fdf7762c
5 files changed
+35
-4
No files matched your search
@@ -549,6 +549,10 @@ Variables exported (per enabled service):
|
||||
| `SECRET_MANAGER_EMULATOR_HOST` | Secret Manager |
|
||||
| `IAM_EMULATOR_HOST` | IAM |
|
||||
|
||||
SDK support for these variables varies by service and language. Python Secret Manager ignores
|
||||
`SECRET_MANAGER_EMULATOR_HOST`; set an explicit emulator endpoint and anonymous credentials.
|
||||
See the [Python Secret Manager recipe](skills/floci/references/gcp.md#python-secret-manager).
|
||||
|
||||
### `floci az env`
|
||||
|
||||
Prints Azure connection variables for the running Floci Azure instance.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
||||
"name": "floci",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Run, wire up and troubleshoot Floci, the free local emulators for AWS, GCP, Azure and OCI: floci-cli lifecycle, safe wiring of aws, gcloud, az, oci and the SDKs, docker run and Docker Compose files, several instances side by side, and lookups in the published docs.",
|
||||
"author": {
|
||||
"name": "Floci",
|
||||
|
||||
@@ -35,11 +35,13 @@ services:
|
||||
app:
|
||||
build: .
|
||||
environment:
|
||||
# Client libraries skip credentials when these are set. Storage needs the scheme.
|
||||
# SDK support varies by service. Storage needs the scheme.
|
||||
STORAGE_EMULATOR_HOST: http://floci-gcp:4588
|
||||
PUBSUB_EMULATOR_HOST: floci-gcp:4588
|
||||
FIRESTORE_EMULATOR_HOST: floci-gcp:4588
|
||||
DATASTORE_EMULATOR_HOST: floci-gcp:4588
|
||||
# Python Secret Manager needs explicit endpoint + anonymous credentials; see gcp.md.
|
||||
# This variable alone does not configure that SDK.
|
||||
SECRET_MANAGER_EMULATOR_HOST: floci-gcp:4588
|
||||
GOOGLE_CLOUD_PROJECT: floci-local
|
||||
depends_on:
|
||||
|
||||
@@ -143,7 +143,9 @@ Ask before running `docker compose down -v`: `-v` deletes the data volume. Plain
|
||||
- **GCP**: `STORAGE_EMULATOR_HOST=http://floci-gcp:4588` (with scheme) and
|
||||
`PUBSUB_EMULATOR_HOST`, `FIRESTORE_EMULATOR_HOST`, `DATASTORE_EMULATOR_HOST`,
|
||||
`SECRET_MANAGER_EMULATOR_HOST` set to `floci-gcp:4588` (no scheme). Set both
|
||||
`FLOCI_GCP_HOSTNAME` and `FLOCI_GCP_BASE_URL` on the emulator.
|
||||
`FLOCI_GCP_HOSTNAME` and `FLOCI_GCP_BASE_URL` on the emulator. SDK support varies:
|
||||
Python Secret Manager ignores its emulator variable; use the explicit REST endpoint
|
||||
`http://floci-gcp:4588` with anonymous credentials (see [gcp.md](gcp.md)).
|
||||
- **Azure**: a connection string with the service name in each endpoint (see `azure.yml`).
|
||||
The control plane (`az`, ARM, Terraform) needs TLS on and the CA trusted: from the host run
|
||||
`floci az setup --container <container name>`; inside another container, read
|
||||
|
||||
@@ -19,7 +19,9 @@ silently, so check the output):
|
||||
| `SECRET_MANAGER_EMULATOR_HOST` | Secret Manager |
|
||||
| `IAM_EMULATOR_HOST` | IAM |
|
||||
|
||||
Client libraries skip credentials when these are set.
|
||||
Emulator-variable support depends on the service and SDK. Do not assume an exported
|
||||
variable redirects a client or disables credential lookup. Python Secret Manager ignores
|
||||
`SECRET_MANAGER_EMULATOR_HOST`: configure its endpoint and credentials explicitly, as below.
|
||||
Pass `project="floci-local"` (or any id) explicitly to clients. Firebase Auth uses
|
||||
`FIREBASE_AUTH_EMULATOR_HOST=localhost:4588`, which `floci gcp env` does not export: set it
|
||||
yourself when the app uses the Firebase Admin SDK.
|
||||
@@ -29,6 +31,27 @@ etc.) need the endpoint set on the client: `http://localhost:4588` for REST, `lo
|
||||
plaintext for gRPC, with no credentials (`NoCredentialsProvider` in Java,
|
||||
`AnonymousCredentials` in Python, `ClientOptions(api_endpoint=...)`).
|
||||
|
||||
### Python Secret Manager
|
||||
|
||||
Use the REST transport with an explicit endpoint and anonymous credentials. On the host,
|
||||
use `http://localhost:4588`; from the Compose app service use `http://floci-gcp:4588`.
|
||||
Setting `SECRET_MANAGER_EMULATOR_HOST` alone does not configure this client.
|
||||
|
||||
```python
|
||||
from google.auth.credentials import AnonymousCredentials
|
||||
from google.cloud import secretmanager_v1
|
||||
|
||||
client = secretmanager_v1.SecretManagerServiceClient(
|
||||
transport="rest",
|
||||
credentials=AnonymousCredentials(),
|
||||
client_options={"api_endpoint": "http://localhost:4588"},
|
||||
)
|
||||
```
|
||||
|
||||
Before making requests, check `client.transport._host` in a local test. It must be your
|
||||
emulator endpoint. For gRPC, provide an explicit plaintext channel instead of the default
|
||||
TLS channel. See the [Python client source](https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/client.py).
|
||||
|
||||
## Wiring for gcloud (important)
|
||||
|
||||
**gcloud does not honor `*_EMULATOR_HOST`.** Without the overrides below, `gcloud` commands go
|
||||
|
||||
Reference in new issue
Block a user