Skip to main content

SOPS extension for pydantic-settings

Project description

pydantic-settings-sops

CI conda-forge pypi-version python-version

SOPS extension for pydantic-settings.

This package allows you to read SOPS files into a pydantic-settings object.

You can install this package via

pip install pydantic-settings-sops
# or
pixi add pydantic-settings-sops

Example

To use pydantic-settings-sops, adjust your settings sources by defining a custom settings_customise_sources. For more information on pydantic-settings, please visit the official documentation.

from pydantic_settings import (
    BaseSettings,
    PydanticBaseSettingsSource,
    SettingsConfigDict,
)
from pydantic_settings_sops import SOPSConfigSettingsSource

class SettingsExample(BaseSettings):
    model_config = SettingsConfigDict(
        yaml_file="secrets.yaml"
    )

    foobar: str

    @classmethod
    def settings_customise_sources(
        cls,
        settings_cls: BaseSettings,
        init_settings: PydanticBaseSettingsSource,
        env_settings: PydanticBaseSettingsSource,
        dotenv_settings: PydanticBaseSettingsSource,
        file_secret_settings: PydanticBaseSettingsSource,
    ) -> tuple[PydanticBaseSettingsSource, ...]:
        return (init_settings, SOPSConfigSettingsSource(settings_cls))

Installation

This project is managed by pixi. You can install the package in development mode using:

git clone https://github.com/pavelzw/pydantic-settings-sops
cd pydantic-settings-sops

pixi run pre-commit-install
pixi run postinstall
pixi run test

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

pydantic_settings_sops-0.1.0.tar.gz (55.7 kB view details)

Uploaded Source

Built Distribution

pydantic_settings_sops-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_settings_sops-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pydantic_settings_sops-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3978e0cc0e8398e451ee85660e0fc871abbbe7e2d5c9cd7a07f3479dd56d64f
MD5 67d8bcedb45b2107510a2d7a9a8a9028
BLAKE2b-256 a49479a777e3879929e62a77028bbc36ce1eababf55c75fbe4e33d75ec519cdd

See more details on using hashes here.

File details

Details for the file pydantic_settings_sops-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_settings_sops-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69b16dda25fd07d48140a3aa10245ce3e2aba4ab49312c24127318aaf4d25877
MD5 28384c505f7caaf6439926845bfa1b45
BLAKE2b-256 6d7f3515e465f11560513d6031ec789bb88214b1f7b0414fc276110e2aec6093

See more details on using hashes here.

Supported by

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