Skip to main content

Reads credentials from a yaml file

Project description

getsecret

Reads credentials from a file .getsecret.yaml

Install

pip install getsecret

Using

Create a file .getsecret.yaml. It should be in YAML format. An example follows:

username: foobar
password: supersecret

Now you can access those variables in your code as follows:

from getsecret import getsecret
username = getsecret('username')
password = getsecet('password')

Now the values of username and password are the ones specified in .getsecret.yaml (foobar and supersecret, respectively).

The file .getsecret.yaml can be located in the working directory (./.getsecret.yaml), or at the user's home directory (~/.getsecret.yaml)

If you pass an additional parameter, it will be used as the default if the key is not found in .getsecret.yaml. For example, the following will look for the username key in .getsecret.yaml, and will default to root if it is not found:

from getsecret import getsecret
username = getsecret('username', 'root')

Author

Geza Kovacs

License

MIT

Related

getsecret npm package for javascript on browser/nodejs

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

getsecret-0.0.6.tar.gz (1.9 kB view hashes)

Uploaded Source

Built Distribution

getsecret-0.0.6-py3-none-any.whl (2.2 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