Adding a prompt to regenerate new SSH Keys#9846
Conversation
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| sftp cert | cmd sftp cert added parameter yes |
||
| sftp connect | cmd sftp connect added parameter yes |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
There was a problem hiding this comment.
Pull request overview
This PR updates the sftp Azure CLI extension to prompt users before overwriting an existing SSH key pair during key generation for az sftp cert and az sftp connect, and introduces --yes/-y to bypass that prompt.
Changes:
- Bump
sftpextension version to1.0.0b3and document the behavior change inHISTORY.rst. - Add overwrite-confirmation logic to key generation and wire
--yes/-ythrough command parameters/help. - Add unit tests covering the new prompt/overwrite decision logic.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/sftp/setup.py | Bumps extension version to 1.0.0b3. |
| src/sftp/HISTORY.rst | Documents the overwrite prompt and --yes/-y behavior. |
| src/sftp/azext_sftp/file_utils.py | Implements overwrite prompt logic and integrates it into key generation flow. |
| src/sftp/azext_sftp/custom.py | Plumbs the yes flag into key generation calls for sftp cert / sftp connect. |
| src/sftp/azext_sftp/_params.py | Adds --yes/-y parameters to both commands. |
| src/sftp/azext_sftp/_help.py | Updates help text and examples describing the overwrite prompt and --yes/-y. |
| src/sftp/azext_sftp/tests/latest/test_file_utils.py | Adds unit tests for overwrite prompt and regeneration behavior. |
| "Selecting 'n' will use the existing key pair. Overwrite?") | ||
| try: | ||
| overwrite = prompt_y_n(message, default='y') |
| # Remove existing files so ssh-keygen does not prompt again to overwrite. | ||
| for stale in (private_key_file, public_key_file): | ||
| if os.path.isfile(stale): | ||
| delete_file(stale, f"Failed to remove existing key file {stale}. ", warning=True) |
|
Hey @necusjz is there something missing from my side? |
better to rerun the test case and generate/push recordings. |
cant we just run the pipelines again? Or do i need to do it manually? |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
Hey @necusjz I've validated the tests locally on top of the above. Is there anything else that should be taken care of? |
|
[Release] Update index.json for extension [ sftp-1.0.0b3 ] : https://dev.azure.com/msazure/One/_build/results?buildId=163241362&view=results |
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.