lib-x17-cloudmeta
Cloud centre module for x17 ecosystem - A Python library for managing cloud infrastructure metadata and configuration hierarchies.
Overview
lib-x17-cloudmeta provides a structured approach to organizing and managing cloud infrastructure metadata across platforms, environments, packages, and services. It implements a hierarchical configuration system with support for metadata merging, reference resolution, and flexible namespace management.
Installation
pip install lib-x17-cloudmeta
For development:
pip install lib-x17-cloudmeta[dev]
Key Features
- Hierarchical Module System: Organize infrastructure into Platform → Environ → Package → Service hierarchies
- Metadata Management: Parse and manage TOML-based metadata files
- Configuration Overlay: Merge configurations across hierarchy levels with reference resolution
- Namespace Access: Intuitive dot-notation access to nested configuration values
- Type-Safe Module Kinds: Enum-based module type system with case-insensitive matching
Architecture
Base Components
File and Folder
Base classes for file system path management with automatic path resolution and validation.
from xcloudmeta.base.file import File
from xcloudmeta.base.folder import Folder
file = File("~/config.toml")
folder = Folder("/path/to/directory")
ModuleKind
Enum for module types: PLATFORM, ENVIRON, PACKAGE, SERVICE, UNDEFINED
from xcloudmeta.base.modulekind import ModuleKind
kind = ModuleKind.from_str("platform") # Case-insensitive
assert kind == ModuleKind.PLATFORM
assert kind == "platform" # String comparison supported
Component Layer
MetaFile
Manages TOML metadata files with automatic parsing and module kind association.
from xcloudmeta.component.metafile import MetaFile
meta = MetaFile(
path="pyproject.toml",
kind="package"
)
data = meta.data # Parsed TOML content
MakeFile
Represents makefile references within modules.
Module Layer
Module
Base class for all infrastructure modules with metadata and makefile support.
from xcloudmeta.module.module import Module
module = Module(
path="/path/to/module",
kind="package",
metafile="package.toml",
makefile="makefile"
)
Specialized Modules
Platform: Top-level platform configurationsEnviron: Environment-specific configurationsPackage: Package/library definitionsService: Service/application configurations
from xcloudmeta.module.platform import Platform
from xcloudmeta.module.environ import Environ
from xcloudmeta.module.package import Package
from xcloudmeta.module.service import Service
platform = Platform("/path/to/platform", metafile="platform.toml")
environ = Environ("/path/to/environ", metafile="environ.toml")
service = Service("/path/to/service", metafile="service.toml")
Centre Layer
Namespace
Enhanced SimpleNamespace with dot-notation access, serialization, and nested path support.
from xcloudmeta.centre.namespace import Namespace
# Create from dict
ns = Namespace.from_obj({
"database": {
"host": "localhost",
"port": 5432
}
})
# Access with dot notation
host = ns.get("database.host") # "localhost"
port = ns.get("database.port", default=3306)
# Set nested values
ns.set("database.user", "admin")
# Serialize
dict_data = ns.to_dict()
json_str = str(ns) # JSON formatted
Layout
Manages the file system layout for organizing modules.
from xcloudmeta.centre.layout import Layout
layout = Layout(root="/project/root")
# List all modules
platforms = layout.list_platforms()
environs = layout.list_environs()
packages = layout.list_packages()
services = layout.list_services()
Default directory structure:
root/
├── platform/
│ ├── plat1/
│ └── plat2/
├── environ/
│ ├── dev/
│ └── prod/
├── package/
│ └── pkg1/
└── service/
├── svc1/
└── svc2/
Overlay
Merges metadata from multiple modules with reference resolution.
from xcloudmeta.centre.overlay import Overlay
overlay = Overlay(
platform=platform,
environ=environ,
service=service
)
# Access merged configuration
compose = overlay.get_compose()
namespace = overlay.get_namespace()
# Get values with dot notation
value = overlay.get("service.name")
overlay.set("custom.key", "value")
Reference Resolution: Use {{ ref(path.to.value) }} in TOML files:
[platform]
region = "us-west-2"
[environ]
name = "prod"
bucket = "{{ ref(platform.region) }}-{{ ref(environ.name) }}-data"
# Result: "us-west-2-prod-data"
Centre
Main entry point for managing the entire infrastructure hierarchy.
from xcloudmeta.centre.centre import Centre
# Initialize with project root
centre = Centre(root="/project/root")
# Access modules
platform = centre.get_platform("aws")
environ = centre.get_environ("production")
service = centre.get_service("api-gateway")
# Create overlay
overlay = centre.overlay(
platform="aws",
environ="production",
service="api-gateway"
)
# Get merged configuration
config = overlay.get_namespace()
api_url = config.get("service.api.url")
Usage Examples
Basic Module Setup
from xcloudmeta.module.platform import Platform
from xcloudmeta.module.environ import Environ
from xcloudmeta.module.service import Service
# Define modules
platform = Platform("./platform/aws", metafile="platform.toml")
environ = Environ("./environ/prod", metafile="environ.toml")
service = Service("./service/api", metafile="service.toml")
print(platform.meta) # Parsed TOML data
print(environ.describe()) # Module description
Configuration Overlay
from xcloudmeta.centre.overlay import Overlay
# Merge configurations
overlay = Overlay(
platform=platform,
environ=environ,
service=service
)
# Access merged config
config = overlay.get_namespace()
db_host = config.get("database.host")
db_port = config.get("database.port")
Full Centre Management
from xcloudmeta.centre.centre import Centre
# Initialize centre
centre = Centre(root="./infrastructure")
# List available modules
print(f"Platforms: {[p.name for p in centre.platforms]}")
print(f"Environs: {[e.name for e in centre.environs]}")
print(f"Services: {[s.name for s in centre.services]}")
# Create overlay
overlay = centre.overlay(
platform="aws",
environ="production",
service="api-gateway"
)
# Access configuration
ns = overlay.get_namespace()
print(ns.to_dict())
Metadata File Format
Metadata files use TOML format:
platform/aws/platform.toml:
[platform]
name = "aws"
region = "us-west-2"
account_id = "123456789012"
environ/prod/environ.toml:
[environ]
name = "production"
domain = "{{ ref(platform.name) }}.example.com"
[database]
instance_type = "db.r5.large"
service/api/service.toml:
[service]
name = "api-gateway"
port = 8080
[resources]
cpu = "2"
memory = "4Gi"
Development
Running Tests
pytest
Code Quality
ruff check .
ruff format .
Requirements
- Python >= 3.11
- No external runtime dependencies (stdlib only)
License
MIT License - See LICENSE file for details
Author
Xing Xing (x.xing.work@gmail.com)
Project Structure
lib-x17-cloudmeta/
├── xcloudmeta/
│ ├── base/ # Base classes (File, Folder, ModuleKind)
│ ├── component/ # Component layer (MetaFile, MakeFile)
│ ├── module/ # Module layer (Platform, Environ, Package, Service)
│ └── centre/ # Centre layer (Centre, Overlay, Layout, Namespace)
├── pyproject.toml
├── README.md
└── environment.yml
Metadata
Release files for lib-x17-cloudmeta 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lib_x17_cloudmeta-1.0.0.tar.gz | 35.6 kB | Without provenance | Details for lib_x17_cloudmeta-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lib_x17_cloudmeta-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for lib_x17_cloudmeta-1.0.0-py3-none-any.whl |
Total release size: 75.8 kB
Release files / lib_x17_cloudmeta-1.0.0.tar.gz
| Download URL | lib_x17_cloudmeta-1.0.0.tar.gz |
|---|---|
| Size | 35.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd39afca274d5a17e6044655e1f22116ccfe9a75dfacd26b2140fd98f68f0849
|
|
BLAKE2b-256 checksum How to use checksums |
287edca2faaa09746f59923e9b002c76b745735d803177cdcb0a036b7190014c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / lib_x17_cloudmeta-1.0.0-py3-none-any.whl
| Download URL | lib_x17_cloudmeta-1.0.0-py3-none-any.whl |
|---|---|
| Size | 40.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c067dc68e03b28c1cffcfb6eb84c935eebc855f84d65d0cd84a5a844cb13b0ae
|
|
BLAKE2b-256 checksum How to use checksums |
dd558666460e48ffaafb07897b18b68490db480e95a61ce77981fb70f5da7634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for lib-x17-cloudmeta 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.