From 84f378a41b85d38c2b4e475d8814b6bf4058ccf9 Mon Sep 17 00:00:00 2001 From: Teo Voinea Date: Thu, 18 Aug 2022 15:08:23 +0000 Subject: [PATCH] Provide a default for settings --- .../ApiService/onefuzzlib/VmExtensionWrapper.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ApiService/ApiService/onefuzzlib/VmExtensionWrapper.cs b/src/ApiService/ApiService/onefuzzlib/VmExtensionWrapper.cs index c82f3548e2..16f74132dd 100644 --- a/src/ApiService/ApiService/onefuzzlib/VmExtensionWrapper.cs +++ b/src/ApiService/ApiService/onefuzzlib/VmExtensionWrapper.cs @@ -22,7 +22,9 @@ public class VMExtensionWrapper { Publisher.EnsureNotNull("Publisher required for VirtualMachineExtension"); TypeHandlerVersion.EnsureNotNull("TypeHandlerVersion required for VirtualMachineExtension"); AutoUpgradeMinorVersion.EnsureNotNull("AutoUpgradeMinorVersion required for VirtualMachineExtension"); - Settings.EnsureNotNull("Settings required for VirtualMachineExtension"); + + var settings = Settings ?? new BinaryData(new Dictionary()); + var protectedSettings = ProtectedSettings ?? new BinaryData(new Dictionary()); return (Name!, new VirtualMachineExtensionData(Location.Value) { TypePropertiesType = TypePropertiesType, @@ -31,8 +33,8 @@ public class VMExtensionWrapper { AutoUpgradeMinorVersion = AutoUpgradeMinorVersion, EnableAutomaticUpgrade = EnableAutomaticUpgrade, ForceUpdateTag = ForceUpdateTag, - Settings = Settings, - ProtectedSettings = ProtectedSettings + Settings = settings, + ProtectedSettings = protectedSettings }); } @@ -42,6 +44,10 @@ public VirtualMachineScaleSetExtensionData GetAsVirtualMachineScaleSetExtension( Publisher.EnsureNotNull("Publisher required for VirtualMachineScaleSetExtension"); TypeHandlerVersion.EnsureNotNull("TypeHandlerVersion required for VirtualMachineScaleSetExtension"); AutoUpgradeMinorVersion.EnsureNotNull("AutoUpgradeMinorVersion required for VirtualMachineScaleSetExtension"); + + var settings = Settings ?? new BinaryData(new Dictionary()); + var protectedSettings = ProtectedSettings ?? new BinaryData(new Dictionary()); + return new VirtualMachineScaleSetExtensionData() { Name = Name, TypePropertiesType = TypePropertiesType, @@ -50,8 +56,8 @@ public VirtualMachineScaleSetExtensionData GetAsVirtualMachineScaleSetExtension( AutoUpgradeMinorVersion = AutoUpgradeMinorVersion, EnableAutomaticUpgrade = EnableAutomaticUpgrade, ForceUpdateTag = ForceUpdateTag, - Settings = Settings, - ProtectedSettings = ProtectedSettings + Settings = settings, + ProtectedSettings = protectedSettings }; } }