Skip to content

Instantly share code, notes, and snippets.

@escattone
Created August 9, 2018 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save escattone/575614a70e48bfc41c9f2c10c416f864 to your computer and use it in GitHub Desktop.
Save escattone/575614a70e48bfc41c9f2c10c416f864 to your computer and use it in GitHub Desktop.
#!/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()
@escattone
Copy link
Author

Before running spy.py, create a virtualenv, activate it, and pip install oyaml click.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment