Skip to content

Commit cd9b53c

Browse files
committed
Merge pull request #647 from dscsolutions/dsc_release
DSC extension refactored code for ARM & ASM
2 parents 23d5c79 + 5d4f8e9 commit cd9b53c

File tree

42 files changed

+1648
-1967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1648
-1967
lines changed

setup/azurecmdfiles.wxi

Lines changed: 272 additions & 0 deletions
Large diffs are not rendered by default.

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@
103103
<SpecificVersion>False</SpecificVersion>
104104
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
105105
</Reference>
106+
<Reference Include="Microsoft.WindowsAzure.Storage">
107+
<HintPath>..\..\packages\WindowsAzure.Storage.4.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
108+
</Reference>
106109
<Reference Include="Newtonsoft.Json">
107110
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
108111
<Private>True</Private>
109112
</Reference>
110113
<Reference Include="System" />
111114
<Reference Include="System.Core" />
115+
<Reference Include="System.IO.Compression.FileSystem" />
112116
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
113117
<Reference Include="System.Net" />
114118
<Reference Include="System.Net.Http" />
@@ -145,6 +149,14 @@
145149
<Compile Include="AzurePowerShell.cs" />
146150
<Compile Include="ComputeCloudException.cs" />
147151
<Compile Include="Constants.cs" />
152+
<Compile Include="Extensions\DSC\DscExtensionCmdletConstants.cs" />
153+
<Compile Include="Extensions\DSC\DscExtensionPrivateSettings.cs" />
154+
<Compile Include="Extensions\DSC\DscExtensionPublicSettings.cs" />
155+
<Compile Include="Extensions\DSC\DscExtensionSettingsSerializer.cs" />
156+
<Compile Include="Extensions\DSC\Exceptions\GetDscResourceException.cs" />
157+
<Compile Include="Extensions\DSC\Publish\ConfigurationParseResult.cs" />
158+
<Compile Include="Extensions\DSC\Publish\ConfigurationParsingHelper.cs" />
159+
<Compile Include="Extensions\DSC\Publish\DscExtensionPublishCmdletCommonBase.cs" />
148160
<Compile Include="SecureStringExtensions.cs" />
149161
<Compile Include="ConversionUtilities.cs" />
150162
<Compile Include="DebugStreamTraceListener.cs" />
@@ -182,13 +194,15 @@
182194
<EmbeddedResource Include="Properties\Resources.resx">
183195
<Generator>PublicResXFileCodeGenerator</Generator>
184196
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
197+
<SubType>Designer</SubType>
185198
</EmbeddedResource>
186199
</ItemGroup>
187200
<ItemGroup>
188201
<None Include="packages.config">
189202
<SubType>Designer</SubType>
190203
</None>
191204
</ItemGroup>
205+
<ItemGroup />
192206
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
193207
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
194208
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
5+
{
6+
public static class DscExtensionCmdletConstants
7+
{
8+
//common extension constants
9+
internal static readonly string ExtensionPublishedNamespace = "Microsoft.Powershell";
10+
internal static readonly string ExtensionPublishedName = "DSC";
11+
internal const string DefaultContainerName = "windows-powershell-dsc";
12+
13+
internal const int MinMajorPowerShellVersion = 4;
14+
internal const string ZipFileExtension = ".zip";
15+
internal const string Ps1FileExtension = ".ps1";
16+
internal const string Psm1FileExtension = ".psm1";
17+
18+
19+
internal static readonly HashSet<String> UploadArchiveAllowedFileExtensions =
20+
new HashSet<String>(StringComparer.OrdinalIgnoreCase) { Ps1FileExtension, Psm1FileExtension, ZipFileExtension };
21+
internal static readonly HashSet<String> CreateArchiveAllowedFileExtensions =
22+
new HashSet<String>(StringComparer.OrdinalIgnoreCase) { Ps1FileExtension, Psm1FileExtension };
23+
}
24+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
15+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
1616
{
17-
1817
using System.Collections;
1918

2019
/// <summary>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using System.Collections;
1717
using System.Collections.Generic;
1818

19-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
19+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
2020
{
2121
/// <summary>
2222
/// Represents public settings. Serialized representation of this object stored as a plain text string on the VM.
@@ -40,21 +40,21 @@ internal class Version1
4040
/// <returns></returns>
4141
public DscExtensionPublicSettings ToCurrentVersion()
4242
{
43-
List<Property> properties = new List<Property>();
44-
foreach (DictionaryEntry p in this.Properties)
43+
var properties = new List<Property>();
44+
foreach (DictionaryEntry p in Properties)
4545
{
46-
properties.Add(new Property()
46+
properties.Add(new Property
4747
{
4848
Name = p.Key.ToString(),
4949
TypeName = p.Value.GetType().ToString(),
5050
Value = p.Value
5151
});
5252
}
53-
return new DscExtensionPublicSettings()
53+
return new DscExtensionPublicSettings
5454
{
55-
SasToken = this.SasToken,
56-
ModulesUrl = this.ModulesUrl,
57-
ConfigurationFunction = this.ConfigurationFunction,
55+
SasToken = SasToken,
56+
ModulesUrl = ModulesUrl,
57+
ConfigurationFunction = ConfigurationFunction,
5858
Properties = properties.ToArray(),
5959
ProtocolVersion = new Version(1, 0, 0, 0)
6060
};

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/DscSettingsSerializer.cs renamed to src/Common/Commands.Common/Extensions/DSC/DscExtensionSettingsSerializer.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
15+
using Newtonsoft.Json;
1616
using System;
1717
using System.Collections;
1818
using System.Collections.Generic;
1919
using System.Globalization;
2020
using System.Management.Automation;
2121
using System.Runtime.InteropServices;
2222
using System.Security;
23-
using Newtonsoft.Json;
2423

25-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
24+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
2625
{
27-
public class DscSettingsSerializer
26+
public class DscExtensionSettingsSerializer
2827
{
2928
/// <summary>
30-
/// Serialize DscPublicSettings to string.
29+
/// Serialize DscExtensionPublicSettings to string.
3130
/// </summary>
32-
/// <param name="publicSettings"></param>
31+
/// <param name="extensionPublicSettings"></param>
3332
/// <returns></returns>
34-
public static string SerializePublicSettings(DscExtensionPublicSettings publicSettings)
33+
public static string SerializePublicSettings(DscExtensionPublicSettings extensionPublicSettings)
3534
{
36-
return JsonConvert.SerializeObject(publicSettings);
35+
return JsonConvert.SerializeObject(extensionPublicSettings);
3736
}
3837

3938
/// <summary>
@@ -48,10 +47,10 @@ public static string SerializePrivateSettings(DscExtensionPrivateSettings privat
4847

4948
public static DscExtensionPublicSettings DeserializePublicSettings(string publicSettingsString)
5049
{
51-
DscExtensionPublicSettings publicSettings;
50+
DscExtensionPublicSettings extensionPublicSettings;
5251
try
5352
{
54-
publicSettings = string.IsNullOrEmpty(publicSettingsString)
53+
extensionPublicSettings = string.IsNullOrEmpty(publicSettingsString)
5554
? null
5655
: JsonConvert.DeserializeObject<DscExtensionPublicSettings>(publicSettingsString);
5756
}
@@ -62,14 +61,14 @@ public static DscExtensionPublicSettings DeserializePublicSettings(string public
6261
{
6362
DscExtensionPublicSettings.Version1 publicSettingsV1 =
6463
JsonConvert.DeserializeObject<DscExtensionPublicSettings.Version1>(publicSettingsString);
65-
publicSettings = publicSettingsV1.ToCurrentVersion();
64+
extensionPublicSettings = publicSettingsV1.ToCurrentVersion();
6665
}
6766
catch (JsonException)
6867
{
6968
throw;
7069
}
7170
}
72-
return publicSettings;
71+
return extensionPublicSettings;
7372
}
7473

7574
/// <summary>

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/GetDscResourceException.cs renamed to src/Common/Commands.Common/Extensions/DSC/Exceptions/GetDscResourceException.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
using System;
1616
using System.Globalization;
1717

18-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
18+
19+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC.Exceptions
1920
{
2021
[Serializable]
2122
public class GetDscResourceException : UnauthorizedAccessException

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/ConfigurationParseResult.cs renamed to src/Common/Commands.Common/Extensions/DSC/Publish/ConfigurationParseResult.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.Collections.Generic;
1716
using System.Management.Automation.Language;
1817

19-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
18+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC.Publish
2019
{
2120
public class ConfigurationParseResult
2221
{
2322
public string Path { get; set; }
2423
public ParseError[] Errors { get; set; }
25-
public List<String> RequiredModules { get; set; }
24+
public Dictionary<string,string> RequiredModules { get; set; }
2625

2726
}
2827
}

0 commit comments

Comments
 (0)