Spaces:
Sleeping
Sleeping
update: Make the secret retriever a cli.
Browse files- utility.py +20 -0
utility.py
CHANGED
@@ -1,4 +1,6 @@
|
|
|
|
1 |
import os
|
|
|
2 |
|
3 |
def retrieve_secrets(
|
4 |
file_path: str | os.PathLike,
|
@@ -20,3 +22,21 @@ def retrieve_secrets(
|
|
20 |
if token_type == access_type:
|
21 |
return token_value
|
22 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
import os
|
3 |
+
import argparse
|
4 |
|
5 |
def retrieve_secrets(
|
6 |
file_path: str | os.PathLike,
|
|
|
22 |
if token_type == access_type:
|
23 |
return token_value
|
24 |
return None
|
25 |
+
|
26 |
+
|
27 |
+
def main():
|
28 |
+
parser = argparse.ArgumentParser(description='Retrieve secrets from a file.')
|
29 |
+
parser.add_argument('--file-path', type=str, help='Path to the secrets file')
|
30 |
+
parser.add_argument('--secret-from', type=str, help='Source of the secret')
|
31 |
+
parser.add_argument('--access-type', type=str, default='default', help='Type of access')
|
32 |
+
|
33 |
+
args = parser.parse_args()
|
34 |
+
secret = retrieve_secrets(args.file_path, args.secret_from, args.access_type)
|
35 |
+
|
36 |
+
if secret:
|
37 |
+
print(secret)
|
38 |
+
else:
|
39 |
+
print("Secret not found.")
|
40 |
+
|
41 |
+
if __name__ == "__main__":
|
42 |
+
main()
|