Skip to content

Commit

Permalink
add a flag to credstash get to return metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kiran committed Feb 8, 2022
1 parent df06772 commit 7c2f4c3
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions credstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,26 @@ def getSecretAction(args, region, kms_region, **session_params):
output_args = {}
sys.stdout.write(output_func(secrets, **output_args))
else:
sys.stdout.write(getSecretAndMetadata(
args.credential,
version=args.version,
region=region,
kms_region=kms_region,
table=args.table,
context=args.context,
**session_params
))
if args.include_metadata:
sys.stdout.write(repr(getSecretAndMetadata(
args.credential,
version=args.version,
region=region,
kms_region=kms_region,
table=args.table,
context=args.context,
**session_params
)))
else:
sys.stdout.write(getSecret(
args.credential,
version=args.version,
region=region,
kms_region=kms_region,
table=args.table,
context=args.context,
**session_params
))
if not args.noline:
sys.stdout.write("\n")
except ItemNotFound as e:
Expand Down Expand Up @@ -977,6 +988,9 @@ def get_parser():
([] if NO_YAML else ["yaml"]),
help="Output format. json(default) " +
("" if NO_YAML else "yaml ") + " csv or dotenv.")
parsers[action].add_argument("-m", "--include-metadata", action="store_true",
help="Return secret metadata (version and comment)"
"along with the secret itself.")
parsers[action].set_defaults(action=action)

action = 'getall'
Expand Down

0 comments on commit 7c2f4c3

Please sign in to comment.