Skip to main content

Zero-configuration fetching of configuration resources

Project description

Geddit

Simple zero-configuration retrieval of resources by URL.

This module provides a single geddit function which takes a single parameter specifying the URL to fetch. It will return a bytes object with the contents of the resource at that URL or will raise an exception specific to the URL scheme.

This library is intended to be used in situations where scheme-specific configuration can be inferred from the environment. (For example, in Google Cloud-hosted environments there is usually a default identity which the services run as. This identity will be used to fetch resources specified via the gs or sm schemes.)

This library is not intended to replace general use libraries such as requests.

Examples

from geddit import geddit

# The default scheme is file://
geddit('file:///etc/issue')     # == b'Debian GNU/Linux 10 \\n \\l\n\n'
geddit('/etc/issue')            # == b'Debian GNU/Linux 10 \\n \\l\n\n'
geddit('./README.md')           # Raises: ValueError

# Fetching using HTTP over TLS
geddit('https://www.gov.uk/bank-holidays.json')[:20]  # == b'{"england-and-wales"'

# HTTP errors are reported
geddit('https://www.example.com/not-found')  # raises requests.exceptions.HTTPError

# Google Storage objects. Uses default application credentials.
geddit('gs://my-bucket/some-object')

# Google Secret Manager secrets. Uses default application credentials.
geddit('sm://my-project/some-secret')       # fetches latest version
geddit('sm://my-project/some-secret#3')     # fetches version 3

# Data URLs.
geddit('data:application/x-yaml;charset=utf-8;base64,eyJmb28iOjF9')  # == b'{"foo":1}'

Requirements

  • Python >= 3.8.

Installation

The latest release of this library on PyPI can be installed using pip:

$ pip3 install geddit

The library can also be installed directly from the git repository if you want the most up-to-date version.

$ pip3 install git+https://gitlab.developers.cam.ac.uk/uis/devops/lib/geddit.git

For developers, the tool can be installed from a cloned repo using pip:

$ cd /path/to/this/repo
$ pip3 install -e .

Publishing a new release

See the guidebook section on publishing to PyPI for more information.

License

This software is licensed under an MIT-like software license. See the LICENSE file for the full text of the license.

Scheme-specific notes

file

The file scheme is the default scheme. Only absolute paths can be specified.

https

There is no support for HTTP basic authentication as that involves putting the cleartext password into the URL.

Non-TLS ("http") URLs are not supported.

gs and sm

Only default application credentials are supported. To use specific credentials, set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the absolute path to some JSON-formatted credentials.

data

Data URLs are not good way of passing secrets since their values are transparent. They can be useful for transferring non-secret configuration or for use in development environments.

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

geddit-1.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

geddit-1.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file geddit-1.1.0.tar.gz.

File metadata

  • Download URL: geddit-1.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for geddit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 44a07eb35828e472e22e48adbf1618ca2da650950d8e915f45399915b49208d6
MD5 b17f8a7017ab30124327db11c6692dcf
BLAKE2b-256 1605288dc246117bf6d98225aa4044f028b4856013d1bcc6b0c5532fca9e31de

See more details on using hashes here.

File details

Details for the file geddit-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: geddit-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for geddit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4caebd72eb1ac1d51b672d000f57314ae88d8821fdc5f46ce75f399d83008d51
MD5 003614baa6fa674f8a8088e603890cb3
BLAKE2b-256 4e0c2318dbcf2fb29d741ac9f8497f90568050203e91ea002fae25a1f24fcd4a

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