Skip to content

Fixes Set-AzKeyVaultSecret to allow objects as Tags (Issue #8494) #8553

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

Merged
merged 6 commits into from
Feb 20, 2019

Conversation

lwajswaj
Copy link
Contributor

@lwajswaj lwajswaj commented Feb 16, 2019

Fixes issue #8494 by forcing all values in Tags hashtable to be strings.

Checklist

@lwajswaj lwajswaj changed the title Fixes issue 8494 Fixes Set-AzKeyVaultSecret to allow objects as Tags (Issue #8494) Feb 16, 2019
@maddieclayton maddieclayton self-assigned this Feb 19, 2019
@lwajswaj
Copy link
Contributor Author

Attempted to use methods exposed at "TagsHelper" but they didn't adjust properly as they are receiving Dictionary<string, string> to get a HashTable OR a hashtable to return a Dictionary<string,string>. Made more sense to just create a new extension method.

@maddieclayton
Copy link
Contributor

@lwajswaj I think what makes the most sense here is to convert the Hashtable to a Dictionary<string, string> using https://github.com/Azure/azure-powershell-common/blob/84adc2e8e833a22caa8ea714cd5c367e63da227c/src/ResourceManager/Version2016_09_01/Tags/TagsConversionHelper.cs#L47, then convert that dictionary back to a Hashtable using https://github.com/Azure/azure-powershell-common/blob/84adc2e8e833a22caa8ea714cd5c367e63da227c/src/ResourceManager/Version2016_09_01/Tags/TagsConversionHelper.cs#L82. This should do exactly what your code is doing, and will guarantee that KeyVault works the exact same as other cmdlets in our repo that convert between Hashtable and Dictionary<string, string>. I believe that this cmdlet fails where others do not because most services accept the Dictionary<string, string> rather than a Hashtable, so we are doing the CreateTagDictionary call which casts all tag keys and values to strings for all other cmdlet calls.

@lwajswaj
Copy link
Contributor Author

lwajswaj commented Feb 20, 2019

Hey @maddieclayton, I think updating "ConvertToDictionary" with the logic I just pushed (it's basically based on your recommendation) it's better as I see it's referenced 16 different times and each one of them is a possible issue if the passed hashtable doesn't contain all strings. In this way, we prevent other issues to occur.

@maddieclayton
Copy link
Contributor

In my opinion, rather than fixing the KeyVault specific implementation, we should change the cmdlet to use the general implementation: https://github.com/Azure/azure-powershell-common/blob/84adc2e8e833a22caa8ea714cd5c367e63da227c/src/ResourceManager/Version2016_09_01/Tags/TagsConversionHelper.cs. I believe this already does what you are fixing in the KeyVault implementation.

If this is too much work, I can take over the PR - just let me know

@lwajswaj
Copy link
Contributor Author

yeap, you are right. For this cmdlet to use general implementation, it's an easy fix. Just pushed the updates to do so

@maddieclayton
Copy link
Contributor

Just to make this a little more simple I edited the change down to just the error handling of the Tag hashtable - should be good to go once CI passes!

@maddieclayton maddieclayton changed the base branch from master to release-2019-02-26 February 20, 2019 08:44
@maddieclayton maddieclayton merged commit 1fede96 into Azure:release-2019-02-26 Feb 20, 2019
@maddieclayton
Copy link
Contributor

@lwajswaj Thanks for the contribution!!

@lwajswaj lwajswaj deleted the fix/issue_8494 branch May 6, 2019 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants