Created
August 9, 2018 19:03
-
-
Save escattone/575614a70e48bfc41c9f2c10c416f864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import base64 | |
import click | |
import oyaml as yaml | |
@click.command() | |
@click.option('--decode/--encode', default=True, | |
help='base64 decode or encode') | |
@click.option('--out', | |
help='write the output to this filename instead of stdout') | |
@click.argument('filename') | |
def spy(decode, out, filename): | |
with open(filename) as f: | |
data = yaml.load(f) | |
secrets = data['data'] | |
for name, val in secrets.items(): | |
secrets[name] = (base64.b64decode if decode else base64.b64encode)(val) | |
if out: | |
with open(out, 'w') as f: | |
yaml.dump(data, f, default_flow_style=False) | |
else: | |
click.echo(yaml.dump(data, default_flow_style=False)) | |
if __name__ == '__main__': | |
spy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before running
spy.py
, create a virtualenv, activate it, andpip install oyaml click
.