Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

drithird
Copy link

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.

Donald and others added 2 commits June 11, 2024 11:54
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']}"
Copy link
Owner

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):
Copy link
Owner

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:
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants