Skip to main content

SOPS Python wrapper library

Project description

SOPSy

SOPSy is a simple Python wrapper arround SOPS.

Installation

pip install sopsy

Usage

Retrieve a secret value

from sopsy import Sops

sops = Sops("secrets.yml")

my_secret_key = sops.get("my_secret_key")
# or
secrets = sops.decrypt()
my_secret_key = secrets.get("my_secret_key")

print(my_secret_key)

Encrypt a file

import json
from pathlib import Path
from sopsy import Sops

plaintext_content = json.dumps({"hello": "world"})
Path("secrets.json").write_text(plaintext_content)


s = Sops("secrets.json", in_place=True)
# you either need a `.sops.yml` configuration file with `creation_rules` set
# or append some arguments to the `Sops.global_args` attribute:
# s.global_args.extend([
#     "--age", "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw"
# ])
s.encrypt()

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

sopsy-0.2.3.tar.gz (30.6 kB view hashes)

Uploaded Source

Built Distribution

sopsy-0.2.3-py3-none-any.whl (28.3 kB view hashes)

Uploaded Python 3

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