peppermint-sparkles

command module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2017 License: MIT Imports: 3 Imported by: 0

README

About

confgr is a simple configuration service backed by an embedded key/value bolt datastore to provide a configuration service with optional encryption for applications. Each configuration is stored against an application name and environment. If no environment is specified, the default is default.

For encrypted configurations, it uses PGP encryption with a base64 encoded UUID. The encryption token is not stored anywhere within the confgr application or datastore. The token is generated at the time of encryption (if not provided) and displayed once the configuration has been stored. If the token is lost, it can not be recovered nor can the data. Please store the tokens is a safe place and ensure redundancy to prevent any lost configuration data. It is also not advised to reuse the same token for multiple environments and / or configurations.


Building

The simplest way to build uses make and Docker for building. By default, running make alone will build the binary and generate the Docker image with a build timestamp at the end. If the build will be the production build to be run, it should be tagged appropriately.

# assumes the image confgr:v1.0.0-1477364779 exists
> docker tag confgr:v1.0.0-1477364779 confgr:latest

To build only the binary, running the make build results in build/bin/confgr though this will only run on an alpine linux environment. To build for a specific OS (e.g. macOS), run the following:

> GOOS=darwin make build

Running

confgr can be run in server or client mode.

Server

As a container
# assumes the image confgr:latest exists
> docker run -d --name confgr -p 9001:8080 confgr server
As a stand-alone binary
> ./confgr server

Client

If running as a client, it requires a server to exist and the environment variable CONFGR_ADDR to be set.

# assumes server container is running on localhost
> export CONFGR_ADDR=localhost:9001
setting a new configuration
> ./confgr set -app foo -env test -encrypt -config '{"test_key": "test_value"}'
# sample output
token: 			 472501d4-83a2-461e-b89c-886ddff63d30
token as base64: NDcyNTAxZDQtODNhMi00NjFlLWI4OWMtODg2ZGRmZjYzZDMw
stored config:
{"app":"foo","environment":"test","config":"LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgp3eDRFQndNSVEyQkFVakgwdTZaZ3lMOTJXK0ZKZ2kyc0RlUlp1a1Y0Y2xUUzRBSGsrYnMyL3cvcHZEODBHb1hECk9WQjVST0ZNVytCRDREUGhXYXZndGVJL2Jxd3E0RGprbjhPWVgvV3JMOVgrY1N6OXBVUW9sZUR4NHpYTythMGEKV1o2bTRIUGhVMGZnaWVUandDOCtJUVd4T3U2OXd4eUZLVnV5NGhJUThGbmg1Q2dBCj00UzlXCi0tLS0tRU5EIFBHUCBNRVNTQUdFLS0tLS0="}
getting an existing configuration
# encrypted
> ./confgr get -app foo -env test
# sample output
{
   "app": "foo",
   "environment": "test",
   "config": "LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgp3eDRFQndNSVEyQkFVakgwdTZaZ3lMOTJXK0ZKZ2kyc0RlUlp1a1Y0Y2xUUzRBSGsrYnMyL3cvcHZEODBHb1hECk9WQjVST0ZNVytCRDREUGhXYXZndGVJL2Jxd3E0RGprbjhPWVgvV3JMOVgrY1N6OXBVUW9sZUR4NHpYTythMGEKV1o2bTRIUGhVMGZnaWVUandDOCtJUVd4T3U2OXd4eUZLVnV5NGhJUThGbmg1Q2dBCj00UzlXCi0tLS0tRU5EIFBHUCBNRVNTQUdFLS0tLS0="
}

# decrypted
> ./confgr get -app foo -env test -decrypt -token NDcyNTAxZDQtODNhMi00NjFlLWI4OWMtODg2ZGRmZjYzZDMw
# sample output
{
   "app": "foo",
   "environment": "test",
   "config": "LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgp3eDRFQndNSVEyQkFVakgwdTZaZ3lMOTJXK0ZKZ2kyc0RlUlp1a1Y0Y2xUUzRBSGsrYnMyL3cvcHZEODBHb1hECk9WQjVST0ZNVytCRDREUGhXYXZndGVJL2Jxd3E0RGprbjhPWVgvV3JMOVgrY1N6OXBVUW9sZUR4NHpYTythMGEKV1o2bTRIUGhVMGZnaWVUandDOCtJUVd4T3U2OXd4eUZLVnV5NGhJUThGbmg1Q2dBCj00UzlXCi0tLS0tRU5EIFBHUCBNRVNTQUdFLS0tLS0="
}

decrypted config:
{"test_key": "test_value"}
listing out configurations
> ./confgr list
# sample output
{
   "foo": [
   	  "dev",
      "test"
   ]
}
removing configurations
# assuming app 'foo' has configurations 'dev' and 'test'
> ./confgr remove -app foo -env dev
> ./confgr list
{
   "foo": [
      "test"
   ]
}

Currently there is no way to remove an entire application without removing each individual environment. The only reason for this limitation, at this time, is to prevent accidental deletion of all environments for a given app.

Documentation

Overview

Copyright 2017 Elliott Polk. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Directories

Path Synopsis
/ Copyright 2017 Elliott Polk.
/ Copyright 2017 Elliott Polk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL