thoth.shared.utils¶
Utility modules for Thoth.
Functions
Return the global SecretManagerClient singleton, creating it if needed. |
Classes
|
Client for reading secrets from Google Cloud Secret Manager. |
- class thoth.shared.utils.SecretManagerClient(project_id: str | None = None)[source]¶
Bases:
objectClient for reading secrets from Google Cloud Secret Manager.
Provides lazy-initialization of the Secret Manager API client and fallback to environment variables when the API is unavailable or when running locally. Used for GitLab tokens, GCP credentials, etc.
- __init__(project_id: str | None = None)[source]¶
Initialize the Secret Manager client (API not called until first use).
- Parameters:
project_id – GCP project ID for Secret Manager. If None, uses the GCP_PROJECT_ID environment variable.
- Returns:
None.
- get_secret(secret_id: str, version: str = 'latest') → str | None[source]¶
Get a secret value from Secret Manager.
- Parameters:
secret_id – The ID of the secret to retrieve
version – The version of the secret (default: “latest”)
- Returns:
The secret value as a string, or None if not found
- thoth.shared.utils.get_secret_manager() → SecretManagerClient[source]¶
Return the global SecretManagerClient singleton, creating it if needed.
Uses a module-level variable so that all callers share the same client and lazy-initialization happens only once.
- Returns:
The global SecretManagerClient instance.
Modules