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.1.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pydantic_settings_sops-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a85b3782c2e05ebb3bdf86df53fdaf69506da0f8c8e0925dea5f4e867b5d1587
MD5 274e2d1bf438522b67423b52248477df
BLAKE2b-256 8e27b0d9a5d878fc35b7c713c90343fc15e479937c2acac02478daf0562265d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantic_settings_sops-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd9de9c8556cf85136d64af9bf633ab8b2253ea63004878d101889930a368e51
MD5 7ae9423c863cac8cf211dcd96e7fd36b
BLAKE2b-256 b83d47da66d10f7b6f4a7e92760a0b66269da4d7982e7781ed8345533c185a9b

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