Skip to main content

Validation library for Upsun Configuration

Project description

upsunvalidator

Contribute, request a feature, or check out our resources

Check out Jeck.ai       Blog       Report a bug       Request a feature

Open issues    Open PRs    License


A Python-based validator library for Upsun configuration files. This library enforces strict schema validation to catch configuration errors before deployment by validating YAML files against the official Upsun JSON schema.


Features       Installation       Usage       Testing       License       Contribute      

Features

  • Validates configuration structure using strict JSON schema enforcement
  • Prevents invalid top-level properties (blocks Docker Compose style configs)
  • Enforces correct data types for all properties (strings vs integers)
  • Validates application runtimes, services, and their versions
  • Validates application and service configurations
  • Validates route patterns and configurations
  • Provides detailed error messages with specific validation failures
  • Provides recommendations when possible
  • Includes comprehensive test suite with passing and failing examples
  • Provides access to example configuration templates for various frameworks

Installation

Requirements:

[!IMPORTANT]
upsunvalidator requires Python 3.12 or newer (tested with Python 3.13).

pip install upsunvalidator

You can then check the installed version with:

Upgrade

pip install --upgrade upsunvalidator

Usage

Using in your code

from upsunvalidator import validate, validate_string

# Validate project in current directory
success, message = validate()
print(message)

# Validate project in specific directory
success, message = validate("/path/to/project")
print(message)

# Validate a configuration string directly
config_content = """
applications:
  app:
    type: php:8.2
    relationships:
      database: 'db:mysql'
      
services:
  db:
    type: mariadb:10.11
  
routes:
  "https://{default}/":
    type: upstream
    upstream: "app:http"
"""
success, message = validate_string(config_content)
print(message)

# Example of invalid config with schema violation
invalid_config = """
applications:
  app:
    type: php:8.2
    
# Invalid properties at root level will be caught
version: '3.8'
networks:
  frontend:
    driver: bridge
"""
success, message = validate_string(invalid_config)
print(message)  # Will show error about additional properties not allowed

# Example of data type validation
invalid_type_config = """
applications:
  app:
    type: php:8.2
    resources:
      base_memory: '128'  # String instead of required integer
"""
success, message = validate_string(invalid_type_config)
print(message)  # Will show error about type mismatch

Using the template library

from upsunvalidator import get_available_template_names, get_template_config, get_template_config_with_info

# Get list of available template names
template_names = get_available_template_names()
print(template_names)  # ['akeneo', 'directus', 'django4', 'drupal11', 'express', ...]

# Get a specific template's config.yaml content
wordpress_config = get_template_config('wordpress-vanilla')
print(wordpress_config)  # YAML content as string

# Get templates with descriptions for easier selection
templates_info = get_template_config_with_info()
for name, (description, _) in templates_info.items():
    print(f"{name}: {description}")

# Get and use a specific template
laravel_config = get_template_config('laravel')
if laravel_config:
    # Validate the template
    from upsunvalidator import validate_string
    success, message = validate_string(laravel_config)
    print(message)

Testing

The project includes a comprehensive test suite:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install .
pytest

License

MIT License

Contribute

We're very interested in adding to the passing configs. If you have working configuration files for Upsun, please share!

  1. Create an issue
  2. Fork the repository
  3. Create your feature branch (git checkout -b feature/amazing-feature)
  4. Add you configuration to the upsunvalidator/tests/valid using the pattern upsunvalidator/tests/valid/YOUR_EXAMPLE_OR_FRAMEWORK_NAME/.upsun/config.yaml
  5. Commit your changes (git commit -am 'Add some amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

See CONTRIBUTING.md for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upsunvalidator-0.3.1.tar.gz (87.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upsunvalidator-0.3.1-py3-none-any.whl (166.7 kB view details)

Uploaded Python 3

File details

Details for the file upsunvalidator-0.3.1.tar.gz.

File metadata

  • Download URL: upsunvalidator-0.3.1.tar.gz
  • Upload date:
  • Size: 87.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for upsunvalidator-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2df08de5590bd2da212fbb2ca28b55bfe78340f2cb5b22ba3d3ad7165f4515dc
MD5 cab0a6df1413f6f1757f7182b00e762c
BLAKE2b-256 466de9bab52cd3df68bfae191fd6ba05e59caa2177061a7d9c74d2e6f28889d3

See more details on using hashes here.

File details

Details for the file upsunvalidator-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: upsunvalidator-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 166.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for upsunvalidator-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca8144cb3deeb94addc525b6fdfa3efa4c2eaa1d602bb70b665832d4e81463e2
MD5 0a0e0799c1249300ce8cfc45cb026450
BLAKE2b-256 88df1290dcddcb9ba5e1fec035e2d143f7d27e8cbd72eb203b644e78eeb25390

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page