-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use a default temp folder for keys and certs #1
base: ssharc
Are you sure you want to change the base?
Conversation
@@ -8,3 +8,4 @@ | |||
CLIENT_PROXY_STORAGE_URL = "https://sshproxysa.blob.core.windows.net" | |||
CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS = 120 | |||
CLEANUP_TIME_INTERVAL_IN_SECONDS = 10 | |||
DEFAULT_KEY_TEMPDIR_NAME = "azclisshkeys" |
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.
Let's call it as DEFAULT_TEMPDIR.
We will store keys, relay information, etc in this folder.
ssh_utils.create_ssh_keyfile(private_key_file) | ||
if not os.path.isdir(temp_dir): | ||
new_temp_dir = tempfile.mkdtemp() | ||
os.rename(new_temp_dir, os.path.join(os.path.dirname(new_temp_dir), consts.DEFAULT_KEY_TEMPDIR_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.
why can't we create the temp directory with the desired name. What's the need for rename?
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.
Yeah, I agree that's a little weird. But the way this tempfile library works is that we can provide a prefix and/or a suffix for the name, but they are gonna add some random characters in the middle. So I just rename it instead so we don't have to deal with that.
src/ssh/azext_ssh/custom.py
Outdated
new_temp_dir = tempfile.mkdtemp() | ||
os.rename(new_temp_dir, os.path.join(os.path.dirname(new_temp_dir), consts.DEFAULT_KEY_TEMPDIR_NAME)) | ||
if not os.path.isfile(public_key_file) or not os.path.isfile(private_key_file): | ||
# file_utils.delete_file(public_key_file, f"Couldn't delete existing public key {public_key_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.
It's good idea to delete existing files as we enter if one of the file doesn't exist.
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.
ssh-keygen seems to be overwriting any existing key files with the same name, so I don't think it's necessary, but I agree that it is a good idea to do it anyways.
… established (there are still some considerations left)
* fix: --title --kind --custom-property parameters (#1) * feat: support yaml file in register command (#3) * fix: workspace parameter should not be required (#2) * style: fix lint issues (#6) * chore: update codeowner for apic-extension (#5) * feat: revert changes to min cli version (#4) * feat: resolve comments to CLI experience (#10) * feat: mark "apic api register" command as preview (#13) * feat: remove --terms-of-service parameter (#12) * feat: remove --workspace-name parameter (#11) * feat: support python 3.8 and 3.9 (#14) * feat: fix command descriptions (#17) * tests: add test cases for 'apic service' commands (#16) * feat: Use 03-01 spec from azure-rest-api-specs repo to regenerate CLI (#19) * fix: CLI errors (#20) * fix: import error when run CLI command * fix: no workspace name error when run import specification command * feat: mark some parameters as required (#21) * feat: mark --assignments parameter required for metadata commands * doc: update sample commands * feat: mark --source-resource-ids parameter as required for import-from-apim command * doc: update description for import-from-apim command * feat: bump version to 1.0.0b5 and update changelog (#18) * build: fix ci (#22) * style: fix style warnings * test:fix test cases * fix: service update command failure (#28) * doc: fix command samples (#30) * doc: update changelog per feedback (#29) * doc: remove extra spaces in register command help message (#34) * doc: update api definition and metadata command samples (Azure#36)
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
azdev style <YOUR_EXT>
locally? (pip install azdev
required)python scripts/ci/test_index.py -q
locally?For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update
src/index.json
automatically.The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify
src/index.json
.