-
Notifications
You must be signed in to change notification settings - Fork 55
Adjusted key_setup() to fix my issue #110 #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…is inline with the quick start setup
Fixed an oversite where I was preappending key to the directory path
if key_path: | ||
key_path = f"{key_path}/{os.environ['KEY_NAME']}.key" | ||
key_path = f"{key_path}/{os.environ['KEY_NAME']}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the .key postfix is probably a good idea in the long run, but is a breaking change for anyone defining the KEY_NAME without .key.
@@ -274,11 +274,18 @@ def key_setup(self): | |||
# check if keys exist in KEY_PATH else create | |||
assert "KEY_NAME" in os.environ, f"missing KEY_NAME env variable" | |||
key_path = os.getenv("KEY_PATH", "") | |||
|
|||
if not os.path.exists(key_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of adding a check here for the path, but raising an exception instead of creating the path.
The reason behind this is that with the ephemeral workers like docker / kubernetes, we would have a different private key each a new instance started instead of forcing the developer to ensure that a persistent volume is used to store the private key. For additional context, when a private key changes any existing and unexpired tokens will not work with a newly refreshed private key.
else: | ||
key_path = f"{os.environ['KEY_NAME']}" | ||
|
||
if not os.path.exists(key_path): | ||
with open(key_path, "w") as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the directory exists, there is is no need to make an empty file.
I adjusted the key_setup function so that it now checks to see if both the directory and file are created before proceeding with the rest of the code in the event that no key exists.
Let me know if you have any questions.