Skip to main content

Build Status

Introduction

etcdgo is a library to push/pull configurations inside etcd databases. Supported filetypes are the following:

  • JSON
  • Yaml
  • INI

Usage example:

import etcd3
import etcdgo

client = etcd3.Etcd3Client(host='127.0.0.1', port=4003)

# push a json configuration inside database
config = etcdgo.get_config(client, "json")
config.push("myconfig", "myfile.json")

# push a yaml configuration inside database
config = etcdgo.get_config(client, "yaml")
config.push("myconfig", "myfile.yaml")

# push a ini configuration inside database
config = etcdgo.get_config(client, "ini")
config.push("myconfig", "myfile.ini")

# pull data from etcd database
data = config.pull("myconfig")

To install the library:

pip install etcdgo

Push/pull via command line

etcdgo library contains a tool called etcdgo-cli which can be used to push/pull configurations inside an etcd database.

# push ini configuration
$ etcdgo-cli \
    --hostname 10.0.1.21 \
    --port 2379 \
    --basefile /configs \
    push pytest0 pytest.ini

# pull configuration
$ etcdgo-cli \
    --hostname 10.0.1.21 \
    --port 2379 \
    --basefile /configs \
    pull --output-type=ini pytest0
[pytest]
addopts = -vv -s
log_cli = True
log_level = DEBUG

etcdgo-cli will automatically recognize the file extension and push it as needed, but pull command needs to specify the output type, via --output-type option.

How data is stored

Before pushing configurations inside an etcd database, all files are converted into a dictionary and then flatten. The basefolder is given to the configuration object and it's the root of our configurations.

For example:

import etcd3
import etcdgo

client = etcd3.Etcd3Client(host='127.0.0.1', port=4003)
config = etcdgo.get_config(client, "ini", basefolder="/configs")
config.push("foods", "myconfig.ini")

Our myconfig.ini configuration:

[apple]
color = red
taste = sweet

[coffee]
color = black
taste = bitter

Once myconfig.ini is pushed into etcd, it will be flatten as following:

/configs/foods/apple/color = 'red'
/configs/foods/apple/taster = 'sweet'
/configs/foods/coffee/color = 'black'
/configs/foods/coffee/taste = 'bitter'

Yaml/JSON configurations are flatten with the same principle. In this case, lists are stored as strings.

For example:

import etcd3
import etcdgo

client = etcd3.Etcd3Client(host='127.0.0.1', port=4003)
config = etcdgo.get_config(client, "json", basefolder="/configs")
config.push("foods", "myconfig.json")

Our myconfig.json configuration:

{
    "fruits" : {
        "apple" : {
            "color": "red",
            "taste": "sweet"
        },
        "coffee" : {
            "color": "black",
            "taste": "bitter"
        },
    },
    "sets" : ["fruits", "vegetables" ]
}

Once myconfig.json is pushed into etcd, it will be flatten as following:

/configs/foods/fruits/apple/color = 'red'
/configs/foods/fruits/apple/taster = 'sweet'
/configs/foods/fruits/coffee/color = 'black'
/configs/foods/fruits/coffee/taste = 'bitter'
/configs/foods/sets = '["fruits", "vegetables"]'

Metadata

Release files for etcdgo 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for etcdgo 1.2.0
File Size Uploaded Provenance Actions
etcdgo-1.2.0.tar.gz 5.6 kB Without provenance Details for etcdgo-1.2.0.tar.gz

Release files / etcdgo-1.2.0.tar.gz

Download URL etcdgo-1.2.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0e3487695475480f36222979e8e4b4a9fe4263373e8bf77a36f01ae8c5caa2f0
BLAKE2b-256 checksum
How to use checksums
7b2323c0b0319a769fadbc79674b89941834fffa96cd9042467ccb4ea3bcda27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Security for etcdgo 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page