Skip to content
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

Bug fix for Get-AzKeyVaultSecret -IncludeVersions #14823

Merged
merged 2 commits into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/KeyVault/KeyVault/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fixed a bug for `Get-AzKeyVaultSecret -IncludeVersions` when current version is disabled [#14740]
* Displayed error code and message when updating purged secret [#14800]

## Version 3.4.2
11 changes: 3 additions & 8 deletions src/KeyVault/KeyVault/Commands/GetAzureKeyVaultSecret.cs
Original file line number Diff line number Diff line change
@@ -222,12 +222,7 @@ public override void ExecuteCmdlet()
}
else if (IncludeVersions)
{
secret = DataServiceClient.GetSecret(VaultName, Name, string.Empty);
if (secret != null)
{
WriteObject(new PSKeyVaultSecretIdentityItem(secret));
GetAndWriteSecretVersions(VaultName, Name, secret.Version);
}
GetAndWriteSecretVersions(VaultName, Name);
}
else if (InRemovedState)
{
@@ -271,14 +266,14 @@ private void GetAndWriteSecrets(string vaultName, string name) =>
},
(options) => KVSubResourceWildcardFilter(name, DataServiceClient.GetSecrets(options)));

private void GetAndWriteSecretVersions(string vaultName, string name, string currentSecretVersion) =>
private void GetAndWriteSecretVersions(string vaultName, string name) =>
GetAndWriteObjects(new KeyVaultObjectFilterOptions
{
VaultName = vaultName,
Name = name,
NextLink = null
},
(options) => DataServiceClient.GetSecretVersions(options).Where(s => s.Version != currentSecretVersion));
(options) => DataServiceClient.GetSecretVersions(options));

private void WriteSecret(PSKeyVaultSecret secret)
{