Skip to content

Commit

Permalink
add a readme for onioncli
Browse files Browse the repository at this point in the history
  • Loading branch information
fzerorubigd committed Jun 22, 2019
1 parent f2cf2f7 commit 5b1e62e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
79 changes: 79 additions & 0 deletions cli/onioncli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Onion CLI

Onion cli is a simple tool to move configuration from a layer to another layer.

Currently it can read/write data from file and etcd keys. also it support for encrypt/decrypt data using PGP.

## Installation

```
go get -u github.com/fzerorubigd/onion/cli/onioncli
```

if you want to encrypt/decrypt data using PGP, you need to create a private/public key pair using gpg (or any other tool)
for example this is a fast way to create a `TEST` key pair (not protected with password) :

```bash
export EMAIL="joe@foo.bar"
export NAME="app"
export GNUPGHOME="$(mktemp -d)"
cat >foo <<EOF
%echo Generating a basic OpenPGP key
Key-Type: default
Subkey-Type: default
Name-Real: ${NAME}
Name-Comment: app configuration key, no passphrase
Name-Email: ${EMAIL}
Expire-Date: 0
%no-protection
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF
gpg --batch --generate-key foo
gpg --export --armor "${EMAIL}" > .pubring.gpg
gpg --export-secret-keys --armor "${EMAIL}" > .secring.gpg

```

This should create two file, `.pubring.gpg` and `.secring.gpg` contains your testing (respectively) public and private keys.

## Usage

for testing, create a plain `config.yaml`
```bash
cat > config.yaml <<EOF
---
example: string
number: 100
EOF

```

Read the file and encrypt it using PGP and print the result in stdout :

```bash
onioncli -s config.yaml -d- --pk=.pubring.gpg
```

Read the file and put data in `/app/data` key in etcd (make sure you have an etcd instance running) :

```bash
onioncli -s config.yaml -d etcd://127.0.0.1:2379/app/data --pk=.pubring.gpg
```

if the `--pk` passed to the cli, then cli encrypt the data before putting it into the destination.

Read the data from etcd and show it in stdout :

```bash
onioncli -s etcd://127.0.0.1:2379/app/data -d-
```

If you want to see the actual data (not the base64/PGP encrypted data) you should provide the secret key with `--sk` flag :
```bash
onioncli -s etcd://127.0.0.1:2379/app/data -d- --sk=.secring.gpg
```

in `-s` and `-d` you can use `-` for stdin and stdout.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ require (
golang.org/x/sys v0.0.0-20190621203818-d432491b9138 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/appengine v1.4.0 // indirect
google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601 // indirect
google.golang.org/grpc v1.21.1 // indirect
gopkg.in/yaml.v2 v2.2.2
Expand Down

0 comments on commit 5b1e62e

Please sign in to comment.