[Keyvault] az keyvault secret download: Add --overwrite flag#31659
[Keyvault] az keyvault secret download: Add --overwrite flag#31659
az keyvault secret download: Add --overwrite flag#31659Conversation
️✔️AzureCLI-FullTest
|
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| keyvault secret download | cmd keyvault secret download added parameter overwrite |
|
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>
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an --overwrite flag to the az keyvault secret download command, allowing users to overwrite an existing file instead of failing. It updates the command implementation, CLI parameter definitions, and adds corresponding tests.
- Added
overwriteparameter and conditional logic indownload_secret - Defined the
--overwriteargument in parameter configuration - Expanded tests to cover download without and with the overwrite flag
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test_keyvault_commands.py | Refactored download tests and added overwrite tests |
| custom.py | Updated download_secret to accept and handle flag |
| _params.py | Added --overwrite argument to the download command |
|
You need to change Our CI is broken now. Please wait #31652 to be merged and update the code. |
az keyvault secret download : Add overwrite flagaz keyvault secret download : Add --overwrite flag
az keyvault secret download : Add --overwrite flagaz keyvault secret download : Add --overwrite flag
az keyvault secret download : Add --overwrite flagaz keyvault secret download: Add --overwrite flag
| """ Download a secret from a KeyVault. """ | ||
| if os.path.isfile(file_path) or os.path.isdir(file_path): | ||
| raise CLIError("File or directory named '{}' already exists.".format(file_path)) | ||
| if not overwrite and (os.path.isfile(file_path) or os.path.isdir(file_path)): |
There was a problem hiding this comment.
Edge case: if the given path is a directory, we're not able to overwrite it.
Co-authored-by: Yishi Wang <yishiwang@microsoft.com>
Related command
keyvault
Description
az keyvault secret downloadcommand previously failed when provided with an existing file for the file path parameter.az keyvault secret downloadcommand to overwrite the existing file with the downloaded secret.Testing Guide
az keyvault secret download --vault-name {kv} -n download-{enc} --file "{dest_path}" --overwrite: overwrite existing path file with the contents of the downloaded secretThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.