Skip to content

Commit 6d78a52

Browse files
authored
Merge pull request #5087 from devigned/feature/aks
AzureRmKubernetes cmdlets for managed Kubernetes
2 parents 521c689 + 7cd89fb commit 6d78a52

File tree

109 files changed

+709216
-47
lines changed

Some content is hidden

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

109 files changed

+709216
-47
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,5 @@ groupMapping*.json
217217
/tools/AutomationTestFramework/TestHelpers/TestHelpers.zip
218218
Results
219219
Package
220+
.DS_Store
221+
.idea

Azure.PowerShell.Netcore.sln

Lines changed: 221 additions & 5 deletions
Large diffs are not rendered by default.

src/Common/Commands.Common.Authentication.Abstractions/Common.Authentication.Abstractions.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Authentication.Abstractions</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Authentication.Abstractions</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup>
2625
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.2.12" />
2726
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
2827
<PackageReference Include="System.Reflection" Version="4.3.0" />

src/Common/Commands.Common.Authentication/Common.Authentication.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Authentication</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Authentication</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup>
2625
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
2726
<PackageReference Include="System.Reflection" Version="4.3.0" />
2827
<PackageReference Include="System.Security.SecureString" Version="4.3.0" />

src/Common/Commands.Common.Authorization/Common.Authorization.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Authorization</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Authorization</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup>
2625
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
2726
<PackageReference Include="System.Reflection" Version="4.3.0" />
2827
<PackageReference Include="System.Security.SecureString" Version="4.3.0" />

src/Common/Commands.Common.Graph.RBAC/Common.Rbac.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Graph.RBAC</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Graph.RBAC</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup >
2625
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
2726
<PackageReference Include="System.Reflection" Version="4.3.0" />
2827
<PackageReference Include="System.Security.SecureString" Version="4.3.0" />

src/Common/Commands.Common.Network/Common.Network.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Network</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Network</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup >
2625
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
2726
<PackageReference Include="System.Reflection" Version="4.3.0" />
2827
<PackageReference Include="System.Security.SecureString" Version="4.3.0" />

src/Common/Commands.Common.Storage/Common.Storage.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.WindowsAzure.Commands.Common.Storage</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.WindowsAzure.Commands.Common.Storage</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup>
2625
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.2.12" />
2726
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="6.5.0-preview" />
2827
<PackageReference Include="WindowsAzure.Storage" Version="8.1.1" />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
11+
<PackageReference Include="xunit" Version="2.3.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
13+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\ResourceManager\Common\Commands.ScenarioTests.ResourceManager.Common\Common.ResourceManager.ScenarioTests.Netcore.csproj" />
18+
<ProjectReference Include="..\Commands.Common\Common.Netcore.csproj" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
3+
using System;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using Xunit;
7+
8+
namespace Commands.Common.Tests
9+
{
10+
public class ProbeTests
11+
{
12+
private readonly string _pwsh;
13+
14+
public ProbeTests()
15+
{
16+
_pwsh = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "powershell" : "pwsh";
17+
}
18+
19+
[Fact]
20+
[Trait(Category.AcceptanceType, Category.CheckIn)]
21+
public void FalseWhenProgramDoesNotExistTest()
22+
{
23+
Assert.False(GeneralUtilities.Probe("foo"));
24+
}
25+
26+
[Fact]
27+
[Trait(Category.AcceptanceType, Category.CheckIn)]
28+
public void TrueWhenProgramDoesExistTest()
29+
{
30+
Assert.True(GeneralUtilities.Probe(_pwsh, " -c 'echo hello world!'"));
31+
}
32+
33+
[Fact]
34+
[Trait(Category.AcceptanceType, Category.CheckIn)]
35+
public void FailIfStdOutDoesNotMatchTest()
36+
{
37+
Assert.False(
38+
GeneralUtilities.Probe(
39+
_pwsh, " -c 'echo foo'",
40+
criterion: (processExitInfo) =>
41+
{
42+
return processExitInfo.StdOut.Any(x => x.Contains("bar"));
43+
}));
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void TrueIfStdOutDoesMatchTest()
49+
{
50+
Assert.True(
51+
GeneralUtilities.Probe(
52+
_pwsh, " -c 'echo foo'",
53+
criterion: (processExitInfo) =>
54+
{
55+
return processExitInfo.StdOut.Any(x => x.Contains("foo"));
56+
}));
57+
}
58+
59+
[Fact]
60+
[Trait(Category.AcceptanceType, Category.CheckIn)]
61+
public void FailIfProcessTakesTooLongToRespondTest()
62+
{
63+
Assert.False(GeneralUtilities.Probe(_pwsh, "-c \"sleep 4\""));
64+
}
65+
}
66+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.WindowsAzure.Commands.Common</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.WindowsAzure.Commands.Common</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -23,7 +22,7 @@
2322
<DelaySign>false</DelaySign>
2423
</PropertyGroup>
2524

26-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
25+
<ItemGroup >
2726
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
2827
<PackageReference Include="System.Net.WebHeaderCollection" Version="4.3.0" />
2928
<PackageReference Include="System.Management.Automation" Version="6.0.0-rc" />

src/Common/Commands.Common/Utilities/GeneralUtilities.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,74 @@ public static void ClearCurrentStorageAccount(bool clearSMContext = false)
486486
}
487487
#endif
488488
}
489+
490+
/// <summary>
491+
/// Execute a process and check for a clean exit to determine if the process exists.
492+
/// </summary>
493+
/// <param name="programName">Name of the program to start.</param>
494+
/// <param name="args">Command line argumentes provided to the program.</param>
495+
/// <param name="waitTime">Time to wait for the process to close.</param>
496+
/// <param name="criterion">Function to evaluate the process response to determine success. The default implementation returns true if the exit code equals 0.</param>
497+
/// <returns></returns>
498+
public static bool Probe(string programName, string args = "", int waitTime = 3000, Func<ProcessExitInfo, bool> criterion = null)
499+
{
500+
try
501+
{
502+
var process = new Process
503+
{
504+
StartInfo = new ProcessStartInfo
505+
{
506+
FileName = programName,
507+
Arguments = args,
508+
RedirectStandardOutput = true,
509+
RedirectStandardError = true,
510+
UseShellExecute = false
511+
}
512+
};
513+
var stdout = new List<string>();
514+
var stderr = new List<string>();
515+
process.OutputDataReceived += (s, e) => stdout.Add(e.Data);
516+
process.ErrorDataReceived += (s, e) => stderr.Add(e.Data);
517+
process.Start();
518+
process.BeginErrorReadLine();
519+
process.BeginOutputReadLine();
520+
process.WaitForExit(waitTime);
521+
var exitInfo = new ProcessExitInfo { ExitCode = process.ExitCode, StdOut = stdout, StdErr = stderr };
522+
var exitCode = process.ExitCode;
523+
return criterion == null ? exitInfo.ExitCode == 0 : criterion(exitInfo);
524+
}
525+
catch (InvalidOperationException)
526+
{
527+
// The excutable failed to execute prior wait time expiring.
528+
return false;
529+
}
530+
catch (SystemException)
531+
{
532+
// The excutable doesn't exist on path. Rather than handling Win32 exception, chose to handle a less platform specific sys exception.
533+
return false;
534+
}
535+
}
536+
537+
/// <summary>
538+
/// Process exit information
539+
/// </summary>
540+
public class ProcessExitInfo
541+
{
542+
/// <summary>
543+
/// Exit code of a process
544+
/// </summary>
545+
public int ExitCode { get; set; }
546+
547+
/// <summary>
548+
/// List of all lines from STDOUT
549+
/// </summary>
550+
public IList<string> StdOut { get; set; }
551+
552+
/// <summary>
553+
/// List of all lines from STDERR
554+
/// </summary>
555+
public IList<string> StdErr { get; set; }
556+
}
489557

490558
public static string DownloadFile(string uri)
491559
{

src/ResourceManager/Common/Commands.Common.Authentication.ResourceManager/Common.ResourceManager.Authentication.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Authentication.ResourceManager</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Authentication.ResourceManager</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup >
2625
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.2.12" />
2726
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.8" />
2827
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />

src/ResourceManager/Common/Commands.Common.Strategies/Common.Strategies.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.Common.Strategies</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup>
2625
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" />
2726
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="16.3.0" />
2827
<PackageReference Include="Microsoft.Azure.Management.Network" Version="10.1.0-preview" />

src/ResourceManager/Common/Commands.ResourceManager.Common/Common.ResourceManager.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<AssemblyName>Microsoft.Azure.Commands.ResourceManager.Common</AssemblyName>
8-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
98
<RootNamespace>Microsoft.Azure.Commands.ResourceManager.Common</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1110
</PropertyGroup>
@@ -22,7 +21,7 @@
2221
<DelaySign>false</DelaySign>
2322
</PropertyGroup>
2423

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
24+
<ItemGroup>
2625
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.2.12" />
2726
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.8" />
2827
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Common.ResourceManager.ScenarioTests.Netcore.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
7-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
87
<AssemblyName>Microsoft.Azure.Commands.ScenarioTest.Common</AssemblyName>
98
<RootNamespace>Microsoft.Azure.Commands.ScenarioTest</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ public class EnvironmentSetupHelper
6565
public EnvironmentSetupHelper()
6666
{
6767
TestExecutionHelpers.SetUpSessionAndProfile();
68-
var datastore = new MemoryDataStore();
68+
IDataStore datastore = new MemoryDataStore();
69+
if (AzureSession.Instance.DataStore != null && (AzureSession.Instance.DataStore is MemoryDataStore))
70+
{
71+
datastore = AzureSession.Instance.DataStore;
72+
}
73+
6974
AzureSession.Instance.DataStore = datastore;
7075
var rmprofile = new AzureRmProfile(Path.Combine(AzureSession.Instance.ProfileDirectory, AzureSession.Instance.ProfileFile));
7176
rmprofile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()));

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
7-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
87
<AssemblyName>Microsoft.Azure.Commands.Compute</AssemblyName>
98
<RootNamespace>Microsoft.Azure.Commands.Compute</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
@@ -27,7 +26,7 @@
2726
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
2827
</PropertyGroup>
2928

30-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
29+
<ItemGroup >
3130
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" />
3231
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
3332
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.5.0-preview" />

src/ResourceManager/KeyVault/Commands.KeyVault/Commands.KeyVault.Netcore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
7-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
87
<AssemblyName>Microsoft.Azure.Commands.KeyVault</AssemblyName>
98
<RootNamespace>Microsoft.Azure.Commands.KeyVault</RootNamespace>
109
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
@@ -28,7 +27,7 @@
2827
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
2928
</PropertyGroup>
3029

31-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
30+
<ItemGroup>
3231
<PackageReference Include="Microsoft.Azure.KeyVault" Version="2.3.2" />
3332
<PackageReference Include="Microsoft.Azure.KeyVault.WebKey" Version="2.0.7" />
3433
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.3.0-preview" />

0 commit comments

Comments
 (0)