Skip to content

Commit 94d11f1

Browse files
committed
Resolve some comments
1 parent 4371311 commit 94d11f1

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

src/ResourceManager/Compute/Commands.Compute/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Compute/Commands.Compute/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ The file needs to be a PowerShell script (.ps1 or .psm1) or a ZIP archive (.zip)
483483
<value>Storage account endpoint is not defined or can not be retrieved automatically..</value>
484484
</data>
485485
<data name="DiagnosticsExtensionIaaSConfigElementNotDefined" xml:space="preserve">
486-
<value>No WadCfg, WadCfgBlob or xmlCfg element is defined in the configuration file.</value>
486+
<value>No WadCfg, WadCfgBlob or xmlCfg element defined in the configuration file.</value>
487487
</data>
488488
<data name="DiagnosticsExtensionInvalidConfigFileFormat" xml:space="preserve">
489489
<value>Invalid diagnostics configuration file. It should be in Invalid diagnostics configuration file. It should be in either xml or json format.either xml or json format.</value>

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/Diagnostics/BaseAzureServiceDiagnosticsExtension.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,38 +129,37 @@ protected override void ValidateConfiguration()
129129
doc.Load(DiagnosticsConfigurationPath);
130130

131131
// Make sure the configuration element exist
132-
var config = doc.SelectSingleNode("//ns:WadCfg", ns) ?? doc.SelectSingleNode("//ns:WadCfgBlob", ns);
133-
if (config == null)
132+
var configElement = doc.SelectSingleNode("//ns:WadCfg", ns) ?? doc.SelectSingleNode("//ns:WadCfgBlob", ns);
133+
if (configElement == null)
134134
{
135135
throw new ArgumentException(Resources.DiagnosticsExtensionPaaSConfigElementNotDefined);
136136
}
137137

138138
// The element <StorageAccount> is not meant to be set by the user in the public config.
139139
// Make sure it matches the storage account in the private config.
140-
var node = doc.SelectSingleNode("//ns:StorageAccount", ns);
141-
if(node != null)
140+
var storageAccountElement = doc.SelectSingleNode("//ns:StorageAccount", ns);
141+
if(storageAccountElement != null)
142142
{
143143
// The StorageAccount is empty, we must set it
144-
if (string.IsNullOrEmpty(node.InnerText))
144+
if (string.IsNullOrEmpty(storageAccountElement.InnerText))
145145
{
146-
var insertIndex = PublicConfiguration.IndexOf("</StorageAccount>");
147-
PublicConfiguration = PublicConfiguration.Insert(insertIndex, StorageAccountName);
146+
storageAccountElement.InnerText = StorageAccountName;
147+
PublicConfiguration = doc.OuterXml;
148148
}
149-
else if (!string.IsNullOrEmpty(node.InnerText) && string.Compare(node.InnerText, StorageAccountName, true) != 0)
149+
else if (!string.IsNullOrEmpty(storageAccountElement.InnerText) && string.Compare(storageAccountElement.InnerText, StorageAccountName, true) != 0)
150150
{
151151
throw new ArgumentException(Resources.DiagnosticsExtensionNoMatchStorageAccount);
152152
}
153153
}
154154
else
155155
{
156-
// the StorageAccount is not there. we must set it
157-
string storageAccountElem = "\n<StorageAccount>" + StorageAccountName + "</StorageAccount>\n";
158-
159-
// insert it after </WadCfg> or </WadCfgBlob>
160-
int wadCfgEndIndex = PublicConfiguration.IndexOf("</WadCfg>");
161-
int wadCfgBlobEndIndex = PublicConfiguration.IndexOf("</WadCfgBlob>");
162-
int insertIndex = wadCfgEndIndex >= 0 ? wadCfgEndIndex + "</WadCfg>".Length : wadCfgBlobEndIndex + "</WadCfgBlob>".Length;
163-
PublicConfiguration = PublicConfiguration.Insert(insertIndex, storageAccountElem);
156+
// The StorageAccount is not there. we must set it
157+
storageAccountElement = doc.CreateElement("StorageAccount", XmlNamespace);
158+
storageAccountElement.InnerText = StorageAccountName;
159+
160+
// Insert it after <WadCfg> or <WadCfgBlob>
161+
configElement.ParentNode.AppendChild(storageAccountElement);
162+
PublicConfiguration = doc.OuterXml;
164163
}
165164

166165
// Make sure the storage account name in PrivateConfig matches.

src/ServiceManagement/Compute/Commands.ServiceManagement/Properties/Resources.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/Compute/Commands.ServiceManagement/Properties/Resources.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@
784784
<value>WadCfg start element in the config is not matching the end element.</value>
785785
</data>
786786
<data name="DiagnosticsExtensionIaaSConfigElementNotDefined" xml:space="preserve">
787-
<value>No WadCfg, WadCfgBlob or xmlCfg element is defined in the configuration file.</value>
787+
<value>No WadCfg, WadCfgBlob or xmlCfg element defined in the configuration file.</value>
788788
</data>
789789
<data name="DiagnosticsExtensionInvalidConfigFileFormat" xml:space="preserve">
790790
<value>Invalid diagnostics configuration file. It should be in either xml or json format.</value>
791791
</data>
792792
<data name="DiagnosticsExtensionPaaSConfigElementNotDefined" xml:space="preserve">
793-
<value>No WadCfg or WadCfgBlob element is defined in the configuration file.</value>
793+
<value>No WadCfg or WadCfgBlob element defined in the configuration file.</value>
794794
</data>
795795
</root>

0 commit comments

Comments
 (0)