Skip to content

Commit 1595b3a

Browse files
author
Leandro Wajswajn Pereyra
committed
Removed custom extension and improved ConvertToDictionary hashtable management
1 parent ba1c76b commit 1595b3a

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

src/KeyVault/KeyVault/Commands/SetAzureKeyVaultSecret.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1717
using System;
1818
using System.Collections;
19+
using System.Collections.Generic;
1920
using System.Management.Automation;
2021
using System.Security;
2122

@@ -141,7 +142,7 @@ public override void ExecuteCmdlet()
141142

142143
if (this.Tag != null)
143144
{
144-
attributes.Tags = this.Tag.ConvertToStringHashtable();
145+
attributes.Tags = this.Tag.ConvertToDictionary().ConvertToHashtable();
145146
}
146147

147148
var secret = DataServiceClient.SetSecret(VaultName, Name, SecretValue, attributes);

src/KeyVault/KeyVault/Models/TagsHelper.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ namespace Microsoft.Azure.Commands.KeyVault.Models
2222
{
2323
public static class TagsHelper
2424
{
25-
public static Hashtable ConvertToStringHashtable(this Hashtable tags) {
26-
Hashtable tagsHashtable = new Hashtable();
27-
28-
foreach (string Key in tags.Keys) {
29-
tagsHashtable.Add(Key, tags[Key].ToString());
30-
}
31-
32-
return tagsHashtable;
33-
}
34-
3525
public static Dictionary<string, string> ConvertToDictionary(this Hashtable tags)
3626
{
3727
Dictionary<string, string> tagsDictionary = new Dictionary<string, string>();
@@ -41,9 +31,7 @@ public static Dictionary<string, string> ConvertToDictionary(this Hashtable tags
4131
if (string.IsNullOrWhiteSpace(key))
4232
throw new ArgumentException("Invalid tag name");
4333

44-
if (tag.Value != null && !(tag.Value is string))
45-
throw new ArgumentException("Tag has invalid value");
46-
string value = (tag.Value == null) ? string.Empty : (string)tag.Value;
34+
string value = (tag.Value == null) ? string.Empty : tag.Value.ToString();
4735
tagsDictionary[key] = value;
4836
}
4937

0 commit comments

Comments
 (0)