-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fixes Set-AzKeyVaultSecret to allow objects as Tags (Issue #8494) #8553
Conversation
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. |
@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. |
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. |
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 |
yeap, you are right. For this cmdlet to use general implementation, it's an easy fix. Just pushed the updates to do so |
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! |
@lwajswaj Thanks for the contribution!! |
Fixes issue #8494 by forcing all values in Tags hashtable to be strings.
Checklist
CONTRIBUTING.md
platyPS
module