Lightweight Spring Cloud Config client for Python
Project description
Spring Config Client for Python
A lightweight Python client for Spring Cloud Config Server. Load your centralized configuration into Python applications at startup.
Why This Exists
Spring Cloud Config Server is great for centralized configuration management, but Python clients were either outdated or overcomplicated. This library does one thing well: fetch configuration from your Spring Config Server and load it into your application's environment.
Installation
pip install spring-config-client-python
Quick Start
from spring_config_client import SpringConfigClient
import os
# Initialize and load config at application startup
client = SpringConfigClient(
server_url="https://config.example.com",
app_name="my-python-service",
profile="production",
username="config-admin", # optional, for basic auth
password="secret" # optional
)
# Fetch and load all configuration into os.environ
config = client.fetch_and_load()
# Access your configuration
db_host = os.environ.get('DB_HOST')
api_key = os.environ.get('API_KEY')
How It Works
- Fetches configuration from Spring Config Server using the standard API endpoint:
/{application}/{profile} - Merges multiple property sources with correct precedence (profile-specific overrides defaults)
- Interpolates property placeholders like
${DB_HOST}from existing environment variables - Loads everything into
os.environas-is (including dotted keys likespring.datasource.url)
Configuration Keys
Your Spring Config Server can return keys in any format:
- Environment variable style:
DATABASE_URL,API_KEY - Spring property style:
spring.datasource.url,logging.level.root - Mixed: Whatever you configure in your
.propertiesor.ymlfiles
All keys are loaded as-is into os.environ. No transformation, no magic.
Property Interpolation
The client supports Spring-style property placeholders:
# In your Spring Config Server
DATABASE_URL=postgresql://${DB_HOST}:${DB_PORT}/mydb
The client will resolve ${DB_HOST} and ${DB_PORT} from your existing environment variables.
Features
- ✅ Loads configuration at startup (no runtime refresh)
- ✅ Basic authentication support
- ✅ Property placeholder interpolation (
${VAR}) - ✅ Correct property source precedence
- ✅ Zero dependencies except
requests - ✅ Works with Spring Cloud Config Server 2025.0.0
What This Library Does NOT Do
- ❌ Runtime configuration refresh - load once at startup only
- ❌ Encryption/decryption - use Spring Config Server's encryption features
- ❌ Advanced retry logic - fails fast if server is unreachable
- ❌ Configuration validation - that's your application's responsibility
This is intentional. Keep it simple.
Example with Docker
FROM python:3.11-slim
ENV CONFIG_SERVER_URL=https://config.example.com
ENV CONFIG_APP_NAME=my-service
ENV CONFIG_PROFILE=production
COPY . /app
WORKDIR /app
RUN pip install spring-config-client-python
CMD python app.py
# app.py
import os
from spring_config_client import SpringConfigClient
# Load config from environment
client = SpringConfigClient(
server_url=os.environ['CONFIG_SERVER_URL'],
app_name=os.environ['CONFIG_APP_NAME'],
profile=os.environ['CONFIG_PROFILE']
)
client.fetch_and_load()
# Your application code here
Error Handling
The client fails fast if the config server is unreachable. This is by design - your service shouldn't start without proper configuration.
try:
client.fetch_and_load()
except requests.RequestException as e:
print(f"Failed to load configuration: {e}")
sys.exit(1)
Requirements
- Python 3.9+
- Spring Cloud Config Server 2025.0.0 (or compatible versions)
License
MIT
Contributing
Found a bug? Have a feature request? Open an issue on GitHub.
Keep it simple. This library does one thing well and that's enough.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spring_config_client_python-0.1.3.tar.gz.
File metadata
- Download URL: spring_config_client_python-0.1.3.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f01d5dda8ab8acf91143760caf1453d84439d455a174aa65cc75814f9519a2
|
|
| MD5 |
90f41c656263ed640469bef14db2de37
|
|
| BLAKE2b-256 |
8551fb85d84e68fa337670b90d3e44934f2bd8e378834f1ef21da3f2417d2359
|
Provenance
The following attestation bundles were made for spring_config_client_python-0.1.3.tar.gz:
Publisher:
python-publish.yml on tcivie/spring-config-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spring_config_client_python-0.1.3.tar.gz -
Subject digest:
e1f01d5dda8ab8acf91143760caf1453d84439d455a174aa65cc75814f9519a2 - Sigstore transparency entry: 600996223
- Sigstore integration time:
-
Permalink:
tcivie/spring-config-client-python@52f3eb48442ca39a182fd768613cc068c53ef199 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/tcivie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@52f3eb48442ca39a182fd768613cc068c53ef199 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spring_config_client_python-0.1.3-py3-none-any.whl.
File metadata
- Download URL: spring_config_client_python-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39100c41a9da675e15c6dd19bb2caaf4bcaa05a05e511d60296570e7a206387f
|
|
| MD5 |
dfb4f7f7ca2b3b1829bca869153cfae3
|
|
| BLAKE2b-256 |
3f597a3bc861da954d08a41655d8c32819a404b827d7145506c8e91de2417fe7
|
Provenance
The following attestation bundles were made for spring_config_client_python-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on tcivie/spring-config-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spring_config_client_python-0.1.3-py3-none-any.whl -
Subject digest:
39100c41a9da675e15c6dd19bb2caaf4bcaa05a05e511d60296570e7a206387f - Sigstore transparency entry: 600996226
- Sigstore integration time:
-
Permalink:
tcivie/spring-config-client-python@52f3eb48442ca39a182fd768613cc068c53ef199 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/tcivie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@52f3eb48442ca39a182fd768613cc068c53ef199 -
Trigger Event:
release
-
Statement type: