From 901ad2d43b21eda3255db94f6a002e0ce5f8eec9 Mon Sep 17 00:00:00 2001 From: markcowl Date: Tue, 15 Dec 2015 11:01:35 -0800 Subject: [PATCH 01/12] Xunit test infra for CLU --- src/CLU/CLUCoreCLR.sln | 6 + .../EnvironmentTestCredentials.cs | 23 +++ .../ExampleTestHelper.cs | 143 ++++++++++++++ .../ITestContext.cs | 25 +++ ...crosoft.Azure.Commands.Examples.Test.xproj | 19 ++ .../ProcessHelper.cs | 184 ++++++++++++++++++ .../project.json | 64 ++++++ 7 files changed, 464 insertions(+) create mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs create mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs create mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs create mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj create mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs create mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json diff --git a/src/CLU/CLUCoreCLR.sln b/src/CLU/CLUCoreCLR.sln index 008b0b2b780e..f6aea473e716 100644 --- a/src/CLU/CLUCoreCLR.sln +++ b/src/CLU/CLUCoreCLR.sln @@ -37,6 +37,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Run", "Micros EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU", "Microsoft.CLU\Microsoft.CLU.xproj", "{D0A59671-088D-463B-B060-2ADAFFB9C3F6}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Examples.Test", "Microsoft.Azure.Commands.Examples.Test\Microsoft.Azure.Commands.Examples.Test.xproj", "{4093E659-34AD-4BD9-A5CA-E44337493D5E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -111,6 +113,10 @@ Global {D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.Build.0 = Release|Any CPU + {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs new file mode 100644 index 000000000000..805e973e761c --- /dev/null +++ b/src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs @@ -0,0 +1,23 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.Common.Authentication.Models; + +namespace Microsoft.Azure.Commands.Examples.Test +{ + public class EnvironmentTestContext : ITestContext + { + public AzureContext Context { get; } + } +} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs new file mode 100644 index 000000000000..e903aca6ba02 --- /dev/null +++ b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs @@ -0,0 +1,143 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Castle.DynamicProxy.Generators; +using Microsoft.Azure.Commands.Common.Authentication; +using Microsoft.Azure.Commands.Common.Authentication.Factories; +using Microsoft.Azure.Commands.Common.Authentication.Models; +using Microsoft.Azure.Management.Resources; +using Microsoft.Azure.Management.Resources.Models; +using Microsoft.Rest; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Xunit; + +namespace Microsoft.Azure.Commands.Examples.Test +{ + public class ExampleTestHelper + { + Random _generator; + string _resourceGroupName; + IClientFactory _clientFactory = new ClientFactory(); + ITestContext _context = new EnvironmentTestContext(); + ResourceManagementClient _client; + const string DefaultLocation = "West US"; + + public ExampleTestHelper() : this(new Random()) + { + } + + public ExampleTestHelper(int seed) : this(new Random(seed)) + { + } + + + public ExampleTestHelper(Random generator) + { + _generator = generator; + } + + public IClientFactory ClientFactory + { + get { return _clientFactory; } + set { _clientFactory = value; } + } + + public ITestContext TestContext + { + get { return _context; } + set { _context = value; } + } + + public void RunTest(string testPath, string deploymentTemplatePath) + { + if (!File.Exists(testPath)) + { + throw new InvalidOperationException($"Path to test script '{testPath}' does not exist."); + } + + if (!string.IsNullOrEmpty(deploymentTemplatePath)) + { + if (!File.Exists(deploymentTemplatePath)) + { + throw new InvalidOperationException($"Path to deployment template '{deploymentTemplatePath}' does not exist."); + } + } + try + { + DeployTemplate(deploymentTemplatePath, CreateRandomName()); + } + finally + { + Cleanup(); + } + } + + public void DeployTemplate(string deploymentTemplatePath, string resourceGroupName) + { + EnsureClient(); + var location = GetLocation(); + CreateResourceGroup(resourceGroupName, location); + var template = JObject.Parse(File.ReadAllText(deploymentTemplatePath)); + var deployment = _client.Deployments.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, "testDeployment", + new Deployment(new DeploymentProperties(template: template, mode: DeploymentMode.Complete))).GetAwaiter().GetResult(); + if (!deployment.Response.IsSuccessStatusCode) + { + throw new InvalidOperationException($"Deployment failed with response: {deployment.Response.AsFormattedString()}"); + } + } + + public string CreateRandomName() + { + return "clutst" + _generator.Next(10000, 99999); + } + + private void EnsureClient() + { + if (this._client == null) + { + var context = _context.Context; + var _client = _clientFactory.CreateArmClient(context, + AzureEnvironment.Endpoint.ResourceManager); + } + } + + + private string GetLocation() + { + return DefaultLocation; + } + + private void CreateResourceGroup(string resourceGroupName, string location) + { + var response = + _client.ResourceGroups.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, + new ResourceGroup(location: location)).GetAwaiter().GetResult(); + _resourceGroupName = resourceGroupName; + } + + public void Cleanup() + { + if (_client != null && !string.IsNullOrWhiteSpace(_resourceGroupName)) + _client.ResourceGroups.DeleteWithHttpMessagesAsync(_resourceGroupName).GetAwaiter().GetResult(); + _client = null; + _resourceGroupName = null; + } + } +} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs new file mode 100644 index 000000000000..c383c7e8ccfb --- /dev/null +++ b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs @@ -0,0 +1,25 @@ +using System; +using Microsoft.Azure.Commands.Common.Authentication.Models; +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Rest; + +namespace Microsoft.Azure.Commands.Examples.Test +{ + public interface ITestContext + { + AzureContext Context { get; } + } +} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj b/src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj new file mode 100644 index 000000000000..7dbe87bb0083 --- /dev/null +++ b/src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 4093e659-34ad-4bd9-a5ca-e44337493d5e + Microsoft.Azure.Commands.Examples.Test + ..\artifacts\obj\$(MSBuildProjectName) + ..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs new file mode 100644 index 000000000000..f514df2c0064 --- /dev/null +++ b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs @@ -0,0 +1,184 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Castle.DynamicProxy.Generators.Emitters; + +namespace Microsoft.Azure.Commands.Examples.Test +{ + public class ProcessHelper : IDisposable + { + /// + /// The process running the service. + /// + + string _shellProcessName = "bash.exe"; + + string _arguments; + string _directory; + Dictionary _environment = new Dictionary(); + Process _process; + + public IDictionary EnvironmentVariables + { + get { return _environment; } + } + + public string ShellProcessName + { + get { return _shellProcessName; } + set { _shellProcessName = value; } + } + + public ProcessHelper(string directory, params string[] arguments) + { + _directory = directory; + if (arguments != null && arguments.Length > 0) + { + _arguments = string.Join(" ", arguments); + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && _process != null && !_process.HasExited) + { + EndProcess(_process); + _process = null; + } + } + + + public static string GetPathToExecutable(string executableName) + { + var paths = Environment.GetEnvironmentVariable("PATH"); + foreach (var path in paths.Split(new[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries)) + { + var fullPath = Path.Combine(path, Path.GetFileName(executableName)); + if (File.Exists(fullPath)) + { + return fullPath; + } + + var ext = Path.GetExtension(executableName); + var exec = (ext == ".cmd" || ext == ".exe") ? Path.GetFileNameWithoutExtension(executableName) : executableName; + fullPath = Path.Combine(path, exec); + if (File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + public void StartAndWaitForExist() + { + StartAndWaitForExit(TimeSpan.FromMinutes(30)); + } + public int StartAndWaitForExit(TimeSpan timeout) + { + var shellPath = GetPathToExecutable(_shellProcessName); + if (shellPath == null) + { + throw new InvalidOperationException($"Could not find path to '{_shellProcessName}'"); + } + + _process = StartProcess(shellPath, _arguments, _directory); + if (_process.WaitForExit((int) timeout.TotalMilliseconds)) + { + return _process.ExitCode; + } + + try + { + EndProcess(_process); + } + finally + { + throw new TimeoutException($"Process using executable with path '{shellPath}' timed out"); + } + + } + + /// + /// Run the given command with arguments. Return the result in standard output. + /// + /// The path to the command to execute. + /// The arguments to pass to the command. + /// The working directory for the process being launched. + /// The process + private Process StartProcess( + string path, + string arguments, + string workingDirectory) + { + var process = new Process(); + var startInfo = process.StartInfo; + startInfo.CreateNoWindow = false; + startInfo.RedirectStandardOutput = true; + startInfo.RedirectStandardError = true; + startInfo.WorkingDirectory = workingDirectory; + startInfo.UseShellExecute = false; + startInfo.FileName = path; + startInfo.Arguments = arguments; + SetEnvironmentVariables(startInfo); + process.OutputDataReceived += ProcessOutput; + process.ErrorDataReceived += ProcessError; + process.Start(); + process.BeginOutputReadLine(); + return process; + } + + private void SetEnvironmentVariables(ProcessStartInfo startInfo) + { + foreach (var key in _environment.Keys) + { + startInfo.Environment[key] = _environment[key]; + } + } + + private void ProcessError(object sender, DataReceivedEventArgs e) + { + var formatted = $"ERROR: {e.Data}"; + Trace.WriteLine(formatted); + Debug.WriteLine(formatted); + } + + private void ProcessOutput(object sender, DataReceivedEventArgs e) + { + Trace.WriteLine(e.Data); + Debug.WriteLine(e.Data); + } + + private static void EndProcess(Process process) + { + process.Kill(); + process.WaitForExit(2000); + process.Dispose(); + } + } +} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json b/src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json new file mode 100644 index 000000000000..0b83615e7c8c --- /dev/null +++ b/src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json @@ -0,0 +1,64 @@ +{ + "version": "1.0.0-*", + "description": "Tests for Authentication Management Cmdlets", + "authors": [ "markcowl" ], + "tags": [ "" ], + "projectUrl": "", + "licenseUrl": "", + "frameworks": { + "dnxcore50": { + "dependencies": { + "Microsoft.NETCore": "5.0.1-beta-23516", + "Microsoft.NETCore.Platforms": "1.0.1-beta-23516", + "Microsoft.CSharp": "4.0.1-beta-23516" + } + } + }, + "dependencies": { + "System.Linq": "4.0.1-beta-23516", + "Microsoft.CLU": "1.0.0", + "Commands.Common": "", + "Commands.Common.Authentication": "", + "Commands.ResourceManager.Common": "", + "Commands.ScenarioTests.ResourceManager.Common": "", + "Microsoft.Azure.Commands.Profile": "", + "Microsoft.Azure.Management.Resources": "3.3.0-preview", + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha", + "Microsoft.Rest.ClientRuntime": "1.8.0", + "Microsoft.Rest.ClientRuntime.Azure": "2.5.1", + "Microsoft.Rest.ClientRuntime.Azure.Authentication": "1.2.1-preview", + "Newtonsoft.Json": "7.0.1", + "System.Collections": "4.0.11-beta-23516", + "System.Collections.Concurrent": "4.0.11-beta-23516", + "System.Diagnostics.Tools": "4.0.1-beta-23516", + "System.Diagnostics.TraceSource": "4.0.0-beta-23516", + "System.Diagnostics.Tracing": "4.0.21-beta-23516", + "System.IO": "4.0.11-beta-23516", + "System.IO.FileSystem": "4.0.1-beta-23516", + "System.Net.Http": "4.0.1-beta-23516", + "System.Net.WebHeaderCollection": "4.0.1-beta-23516", + "System.Reflection": "4.1.0-beta-23516", + "System.Reflection.Extensions": "4.0.1-beta-23516", + "System.Reflection.Primitives": "4.0.1-beta-23516", + "System.Reflection.TypeExtensions": "4.1.0-beta-23516", + "System.Runtime": "4.0.21-beta-23516", + "System.Runtime.Extensions": "4.0.11-beta-23516", + "System.Runtime.Serialization.Json": "4.0.1-beta-23516", + "System.Runtime.Serialization.Primitives": "4.1.0-beta-23516", + "System.Runtime.Serialization.Xml": "4.1.0-beta-23516", + "System.Security.Cryptography.Algorithms": "4.0.0-beta-23516", + "System.Security.Cryptography.X509Certificates": "4.0.0-beta-23516", + "System.Text.Encoding": "4.0.11-beta-23516", + "System.Text.Encoding.Extensions": "4.0.11-beta-23516", + "System.Threading": "4.0.11-beta-23516", + "System.Threading.Tasks": "4.0.11-beta-23516", + "System.Threading.Thread": "4.0.0-beta-23516", + "System.Xml.ReaderWriter": "4.0.11-beta-23516", + "xunit": "2.1.0", + "xunit.assert": "2.1.0", + "xunit.runner.dnx": "2.1.0-rc1-build204" + }, + "commands": { + "test": "xunit.runner.dnx" + } +} From 9f244ffa137f79920887464f6dbcff7c2089630e Mon Sep 17 00:00:00 2001 From: markcowl Date: Tue, 15 Dec 2015 11:07:51 -0800 Subject: [PATCH 02/12] dependency and rename fixes --- src/CLU/CLUCoreCLR.sln | 6 - src/CLU/Commands.Common/project.json | 4 +- .../project.json | 4 +- .../project.json | 4 +- .../EnvironmentTestCredentials.cs | 23 --- .../ExampleTestHelper.cs | 143 -------------- .../ITestContext.cs | 25 --- ...crosoft.Azure.Commands.Examples.Test.xproj | 19 -- .../ProcessHelper.cs | 184 ------------------ .../project.json | 64 ------ ...osoft.Azure.Commands.Profile.format.ps1xml | 22 ++- .../Content/rename.cfg | 3 +- 12 files changed, 20 insertions(+), 481 deletions(-) delete mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs delete mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs delete mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs delete mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj delete mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs delete mode 100644 src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json diff --git a/src/CLU/CLUCoreCLR.sln b/src/CLU/CLUCoreCLR.sln index f6aea473e716..008b0b2b780e 100644 --- a/src/CLU/CLUCoreCLR.sln +++ b/src/CLU/CLUCoreCLR.sln @@ -37,8 +37,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Run", "Micros EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU", "Microsoft.CLU\Microsoft.CLU.xproj", "{D0A59671-088D-463B-B060-2ADAFFB9C3F6}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Examples.Test", "Microsoft.Azure.Commands.Examples.Test\Microsoft.Azure.Commands.Examples.Test.xproj", "{4093E659-34AD-4BD9-A5CA-E44337493D5E}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,10 +111,6 @@ Global {D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.Build.0 = Release|Any CPU - {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4093E659-34AD-4BD9-A5CA-E44337493D5E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/CLU/Commands.Common/project.json b/src/CLU/Commands.Common/project.json index 6337846429f8..605781a27b0e 100644 --- a/src/CLU/Commands.Common/project.json +++ b/src/CLU/Commands.Common/project.json @@ -18,8 +18,8 @@ "System.Linq": "4.0.1-beta-23516", "Microsoft.CLU": "1.0.0", "Commands.Common.Authentication": "", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha", - "Microsoft.Rest.ClientRuntime": "1.5.0", + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha", + "Microsoft.Rest.ClientRuntime": "1.8.0", "Newtonsoft.Json": "7.0.1", "System.Collections": "4.0.11-beta-23516", "System.Collections.Concurrent": "4.0.11-beta-23516", diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/project.json b/src/CLU/Commands.ResourceManager.Cmdlets/project.json index 8c5b2e8cc677..a95ee33a145c 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/project.json +++ b/src/CLU/Commands.ResourceManager.Cmdlets/project.json @@ -20,8 +20,8 @@ "Commands.Common.Authentication": "", "Commands.Common": "", "Commands.ResourceManager.Common": "", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha", - "Microsoft.Rest.ClientRuntime": "1.5.0", + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha", + "Microsoft.Rest.ClientRuntime": "1.8.0", "Newtonsoft.Json": "7.0.1", "System.Collections": "4.0.11-beta-23516", "System.Collections.Concurrent": "4.0.11-beta-23516", diff --git a/src/CLU/Commands.ResourceManager.Common/project.json b/src/CLU/Commands.ResourceManager.Common/project.json index e09e492dc34e..43d7f9f3be96 100644 --- a/src/CLU/Commands.ResourceManager.Common/project.json +++ b/src/CLU/Commands.ResourceManager.Common/project.json @@ -19,8 +19,8 @@ "Microsoft.CLU": "1.0.0", "Commands.Common": "", "Commands.Common.Authentication": "", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha", - "Microsoft.Rest.ClientRuntime": "1.5.0", + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha", + "Microsoft.Rest.ClientRuntime": "1.8.0", "Newtonsoft.Json": "7.0.1", "System.Collections": "4.0.11-beta-23516", "System.Collections.Concurrent": "4.0.11-beta-23516", diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs deleted file mode 100644 index 805e973e761c..000000000000 --- a/src/CLU/Microsoft.Azure.Commands.Examples.Test/EnvironmentTestCredentials.cs +++ /dev/null @@ -1,23 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.Common.Authentication.Models; - -namespace Microsoft.Azure.Commands.Examples.Test -{ - public class EnvironmentTestContext : ITestContext - { - public AzureContext Context { get; } - } -} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs deleted file mode 100644 index e903aca6ba02..000000000000 --- a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ExampleTestHelper.cs +++ /dev/null @@ -1,143 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Castle.DynamicProxy.Generators; -using Microsoft.Azure.Commands.Common.Authentication; -using Microsoft.Azure.Commands.Common.Authentication.Factories; -using Microsoft.Azure.Commands.Common.Authentication.Models; -using Microsoft.Azure.Management.Resources; -using Microsoft.Azure.Management.Resources.Models; -using Microsoft.Rest; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Xunit; - -namespace Microsoft.Azure.Commands.Examples.Test -{ - public class ExampleTestHelper - { - Random _generator; - string _resourceGroupName; - IClientFactory _clientFactory = new ClientFactory(); - ITestContext _context = new EnvironmentTestContext(); - ResourceManagementClient _client; - const string DefaultLocation = "West US"; - - public ExampleTestHelper() : this(new Random()) - { - } - - public ExampleTestHelper(int seed) : this(new Random(seed)) - { - } - - - public ExampleTestHelper(Random generator) - { - _generator = generator; - } - - public IClientFactory ClientFactory - { - get { return _clientFactory; } - set { _clientFactory = value; } - } - - public ITestContext TestContext - { - get { return _context; } - set { _context = value; } - } - - public void RunTest(string testPath, string deploymentTemplatePath) - { - if (!File.Exists(testPath)) - { - throw new InvalidOperationException($"Path to test script '{testPath}' does not exist."); - } - - if (!string.IsNullOrEmpty(deploymentTemplatePath)) - { - if (!File.Exists(deploymentTemplatePath)) - { - throw new InvalidOperationException($"Path to deployment template '{deploymentTemplatePath}' does not exist."); - } - } - try - { - DeployTemplate(deploymentTemplatePath, CreateRandomName()); - } - finally - { - Cleanup(); - } - } - - public void DeployTemplate(string deploymentTemplatePath, string resourceGroupName) - { - EnsureClient(); - var location = GetLocation(); - CreateResourceGroup(resourceGroupName, location); - var template = JObject.Parse(File.ReadAllText(deploymentTemplatePath)); - var deployment = _client.Deployments.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, "testDeployment", - new Deployment(new DeploymentProperties(template: template, mode: DeploymentMode.Complete))).GetAwaiter().GetResult(); - if (!deployment.Response.IsSuccessStatusCode) - { - throw new InvalidOperationException($"Deployment failed with response: {deployment.Response.AsFormattedString()}"); - } - } - - public string CreateRandomName() - { - return "clutst" + _generator.Next(10000, 99999); - } - - private void EnsureClient() - { - if (this._client == null) - { - var context = _context.Context; - var _client = _clientFactory.CreateArmClient(context, - AzureEnvironment.Endpoint.ResourceManager); - } - } - - - private string GetLocation() - { - return DefaultLocation; - } - - private void CreateResourceGroup(string resourceGroupName, string location) - { - var response = - _client.ResourceGroups.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, - new ResourceGroup(location: location)).GetAwaiter().GetResult(); - _resourceGroupName = resourceGroupName; - } - - public void Cleanup() - { - if (_client != null && !string.IsNullOrWhiteSpace(_resourceGroupName)) - _client.ResourceGroups.DeleteWithHttpMessagesAsync(_resourceGroupName).GetAwaiter().GetResult(); - _client = null; - _resourceGroupName = null; - } - } -} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs deleted file mode 100644 index c383c7e8ccfb..000000000000 --- a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ITestContext.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Microsoft.Azure.Commands.Common.Authentication.Models; -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Rest; - -namespace Microsoft.Azure.Commands.Examples.Test -{ - public interface ITestContext - { - AzureContext Context { get; } - } -} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj b/src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj deleted file mode 100644 index 7dbe87bb0083..000000000000 --- a/src/CLU/Microsoft.Azure.Commands.Examples.Test/Microsoft.Azure.Commands.Examples.Test.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 4093e659-34ad-4bd9-a5ca-e44337493d5e - Microsoft.Azure.Commands.Examples.Test - ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs b/src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs deleted file mode 100644 index f514df2c0064..000000000000 --- a/src/CLU/Microsoft.Azure.Commands.Examples.Test/ProcessHelper.cs +++ /dev/null @@ -1,184 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Castle.DynamicProxy.Generators.Emitters; - -namespace Microsoft.Azure.Commands.Examples.Test -{ - public class ProcessHelper : IDisposable - { - /// - /// The process running the service. - /// - - string _shellProcessName = "bash.exe"; - - string _arguments; - string _directory; - Dictionary _environment = new Dictionary(); - Process _process; - - public IDictionary EnvironmentVariables - { - get { return _environment; } - } - - public string ShellProcessName - { - get { return _shellProcessName; } - set { _shellProcessName = value; } - } - - public ProcessHelper(string directory, params string[] arguments) - { - _directory = directory; - if (arguments != null && arguments.Length > 0) - { - _arguments = string.Join(" ", arguments); - } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing && _process != null && !_process.HasExited) - { - EndProcess(_process); - _process = null; - } - } - - - public static string GetPathToExecutable(string executableName) - { - var paths = Environment.GetEnvironmentVariable("PATH"); - foreach (var path in paths.Split(new[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries)) - { - var fullPath = Path.Combine(path, Path.GetFileName(executableName)); - if (File.Exists(fullPath)) - { - return fullPath; - } - - var ext = Path.GetExtension(executableName); - var exec = (ext == ".cmd" || ext == ".exe") ? Path.GetFileNameWithoutExtension(executableName) : executableName; - fullPath = Path.Combine(path, exec); - if (File.Exists(fullPath)) - { - return fullPath; - } - } - - return null; - } - - public void StartAndWaitForExist() - { - StartAndWaitForExit(TimeSpan.FromMinutes(30)); - } - public int StartAndWaitForExit(TimeSpan timeout) - { - var shellPath = GetPathToExecutable(_shellProcessName); - if (shellPath == null) - { - throw new InvalidOperationException($"Could not find path to '{_shellProcessName}'"); - } - - _process = StartProcess(shellPath, _arguments, _directory); - if (_process.WaitForExit((int) timeout.TotalMilliseconds)) - { - return _process.ExitCode; - } - - try - { - EndProcess(_process); - } - finally - { - throw new TimeoutException($"Process using executable with path '{shellPath}' timed out"); - } - - } - - /// - /// Run the given command with arguments. Return the result in standard output. - /// - /// The path to the command to execute. - /// The arguments to pass to the command. - /// The working directory for the process being launched. - /// The process - private Process StartProcess( - string path, - string arguments, - string workingDirectory) - { - var process = new Process(); - var startInfo = process.StartInfo; - startInfo.CreateNoWindow = false; - startInfo.RedirectStandardOutput = true; - startInfo.RedirectStandardError = true; - startInfo.WorkingDirectory = workingDirectory; - startInfo.UseShellExecute = false; - startInfo.FileName = path; - startInfo.Arguments = arguments; - SetEnvironmentVariables(startInfo); - process.OutputDataReceived += ProcessOutput; - process.ErrorDataReceived += ProcessError; - process.Start(); - process.BeginOutputReadLine(); - return process; - } - - private void SetEnvironmentVariables(ProcessStartInfo startInfo) - { - foreach (var key in _environment.Keys) - { - startInfo.Environment[key] = _environment[key]; - } - } - - private void ProcessError(object sender, DataReceivedEventArgs e) - { - var formatted = $"ERROR: {e.Data}"; - Trace.WriteLine(formatted); - Debug.WriteLine(formatted); - } - - private void ProcessOutput(object sender, DataReceivedEventArgs e) - { - Trace.WriteLine(e.Data); - Debug.WriteLine(e.Data); - } - - private static void EndProcess(Process process) - { - process.Kill(); - process.WaitForExit(2000); - process.Dispose(); - } - } -} diff --git a/src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json b/src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json deleted file mode 100644 index 0b83615e7c8c..000000000000 --- a/src/CLU/Microsoft.Azure.Commands.Examples.Test/project.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "Tests for Authentication Management Cmdlets", - "authors": [ "markcowl" ], - "tags": [ "" ], - "projectUrl": "", - "licenseUrl": "", - "frameworks": { - "dnxcore50": { - "dependencies": { - "Microsoft.NETCore": "5.0.1-beta-23516", - "Microsoft.NETCore.Platforms": "1.0.1-beta-23516", - "Microsoft.CSharp": "4.0.1-beta-23516" - } - } - }, - "dependencies": { - "System.Linq": "4.0.1-beta-23516", - "Microsoft.CLU": "1.0.0", - "Commands.Common": "", - "Commands.Common.Authentication": "", - "Commands.ResourceManager.Common": "", - "Commands.ScenarioTests.ResourceManager.Common": "", - "Microsoft.Azure.Commands.Profile": "", - "Microsoft.Azure.Management.Resources": "3.3.0-preview", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha", - "Microsoft.Rest.ClientRuntime": "1.8.0", - "Microsoft.Rest.ClientRuntime.Azure": "2.5.1", - "Microsoft.Rest.ClientRuntime.Azure.Authentication": "1.2.1-preview", - "Newtonsoft.Json": "7.0.1", - "System.Collections": "4.0.11-beta-23516", - "System.Collections.Concurrent": "4.0.11-beta-23516", - "System.Diagnostics.Tools": "4.0.1-beta-23516", - "System.Diagnostics.TraceSource": "4.0.0-beta-23516", - "System.Diagnostics.Tracing": "4.0.21-beta-23516", - "System.IO": "4.0.11-beta-23516", - "System.IO.FileSystem": "4.0.1-beta-23516", - "System.Net.Http": "4.0.1-beta-23516", - "System.Net.WebHeaderCollection": "4.0.1-beta-23516", - "System.Reflection": "4.1.0-beta-23516", - "System.Reflection.Extensions": "4.0.1-beta-23516", - "System.Reflection.Primitives": "4.0.1-beta-23516", - "System.Reflection.TypeExtensions": "4.1.0-beta-23516", - "System.Runtime": "4.0.21-beta-23516", - "System.Runtime.Extensions": "4.0.11-beta-23516", - "System.Runtime.Serialization.Json": "4.0.1-beta-23516", - "System.Runtime.Serialization.Primitives": "4.1.0-beta-23516", - "System.Runtime.Serialization.Xml": "4.1.0-beta-23516", - "System.Security.Cryptography.Algorithms": "4.0.0-beta-23516", - "System.Security.Cryptography.X509Certificates": "4.0.0-beta-23516", - "System.Text.Encoding": "4.0.11-beta-23516", - "System.Text.Encoding.Extensions": "4.0.11-beta-23516", - "System.Threading": "4.0.11-beta-23516", - "System.Threading.Tasks": "4.0.11-beta-23516", - "System.Threading.Thread": "4.0.0-beta-23516", - "System.Xml.ReaderWriter": "4.0.11-beta-23516", - "xunit": "2.1.0", - "xunit.assert": "2.1.0", - "xunit.runner.dnx": "2.1.0-rc1-build204" - }, - "commands": { - "test": "xunit.runner.dnx" - } -} diff --git a/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml b/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml index 8146c70da1f8..9398b286a02f 100644 --- a/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml +++ b/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml @@ -2,9 +2,9 @@ - Microsoft.Azure.Commands.Profile.Models.PSAzureProfile + Microsoft.Azure.Commands.Models.PSAzureProfile - Microsoft.Azure.Commands.Profile.Models.PSAzureProfile + Microsoft.Azure.Commands.Models.PSAzureProfile @@ -21,27 +21,29 @@ - Microsoft.Azure.Commands.Profile.Models.PSAzureContext + Microsoft.Azure.Commands.Models.PSAzureContext - Microsoft.Azure.Commands.Profile.Models.PSAzureContext + Microsoft.Azure.Commands.Models.PSAzureContext + Environment + Account - Tenant + Tenant - Subscription + Subscription @@ -49,9 +51,9 @@ - Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription + Microsoft.Azure.Commands.Models.PSAzureSubscription - Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription + Microsoft.Azure.Commands.Models.PSAzureSubscription @@ -75,9 +77,9 @@ - Microsoft.Azure.Commands.Profile.Models.PSAzureTenant + Microsoft.Azure.Commands.Models.PSAzureTenant - Microsoft.Azure.Commands.Profile.Models.PSAzureTenant + Microsoft.Azure.Commands.Models.PSAzureTenant diff --git a/src/CLU/Microsoft.Azure.Commands.Resources/Content/rename.cfg b/src/CLU/Microsoft.Azure.Commands.Resources/Content/rename.cfg index 765dd27a0fa3..6a037f1ed512 100644 --- a/src/CLU/Microsoft.Azure.Commands.Resources/Content/rename.cfg +++ b/src/CLU/Microsoft.Azure.Commands.Resources/Content/rename.cfg @@ -1 +1,2 @@ -new: create \ No newline at end of file +ResourceGroup: group +new: create \ No newline at end of file From 4d512290bad4bb971fd87cbf68db3b8da2076196 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Tue, 15 Dec 2015 11:21:42 -0800 Subject: [PATCH 03/12] [#109999746] Removed "AzureDirectoryName" from Authentication resources. --- .../Authentication/AdalTokenProvider.cs | 2 +- .../Authentication/ServicePrincipalTokenProvider.cs | 5 +---- .../Authentication/UserTokenProvider.cs | 2 +- .../AuthenticationFactory.cs | 5 ++--- .../Commands.Common.Authentication/ClientFactory.cs | 3 +-- .../Commands.Common.Authentication/JsonUtilities.cs | 2 +- .../Models/AzureEnvironment.Methods.cs | 2 +- .../Models/AzureSMProfile.cs | 2 +- .../Models/DiskDataStore.cs | 2 +- .../Properties/Resources.Designer.cs | 13 ++----------- .../Properties/Resources.resx | 3 --- src/CLU/Commands.Common.Authentication/Validate.cs | 2 +- 12 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs index d8641135ca63..b786a96e51bf 100644 --- a/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs +++ b/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs @@ -13,8 +13,8 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.Common.Authentication.Models; +using Microsoft.Azure.Commands.Common.Authentication.Properties; using System; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication { diff --git a/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs index edfdab5317ae..403da5738ca4 100644 --- a/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs +++ b/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs @@ -13,13 +13,10 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.Common.Authentication.Models; +using Microsoft.Azure.Commands.Common.Authentication.Properties; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.Rest; using System; -using System.Collections.Generic; -using System.Security; -using System.Security.Cryptography.X509Certificates; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication { diff --git a/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs index 3d8b94b02cf6..df96ae6be080 100644 --- a/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs +++ b/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs @@ -17,9 +17,9 @@ using Microsoft.Rest; using System; using System.Runtime.InteropServices; -using Commands.Common.Authentication.Properties; using Microsoft.Rest.Azure.Authentication; using System.Management.Automation; +using Microsoft.Azure.Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication { diff --git a/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs b/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs index 4d05653310bd..2b64a806abd9 100644 --- a/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs +++ b/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs @@ -1,4 +1,4 @@ -// ---------------------------------------------------------------------------------- +// ---------------------------------------------------------------------------------- // // Copyright Microsoft Corporation // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,11 +16,10 @@ using System; using System.Linq; using System.Management.Automation; -using System.Security; -using Commands.Common.Authentication.Properties; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.Rest; using Microsoft.Rest.Azure.Authentication; +using Microsoft.Azure.Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication.Factories { diff --git a/src/CLU/Commands.Common.Authentication/ClientFactory.cs b/src/CLU/Commands.Common.Authentication/ClientFactory.cs index 5d2b105534c3..069034a3394a 100644 --- a/src/CLU/Commands.Common.Authentication/ClientFactory.cs +++ b/src/CLU/Commands.Common.Authentication/ClientFactory.cs @@ -13,17 +13,16 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.Common.Authentication.Models; +using Microsoft.Azure.Commands.Common.Authentication.Properties; using Microsoft.Rest; using System; using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; using System.Management.Automation; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication.Factories { diff --git a/src/CLU/Commands.Common.Authentication/JsonUtilities.cs b/src/CLU/Commands.Common.Authentication/JsonUtilities.cs index 8804102bb551..2149e045b5a0 100644 --- a/src/CLU/Commands.Common.Authentication/JsonUtilities.cs +++ b/src/CLU/Commands.Common.Authentication/JsonUtilities.cs @@ -12,12 +12,12 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Common.Authentication.Properties; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication { diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs index 0f92cd1759b5..0901ffa1cfba 100644 --- a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs +++ b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs @@ -12,9 +12,9 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Common.Authentication.Properties; using System; using System.Collections.Generic; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication.Models { diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs b/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs index 45ad834fc49b..7d0346199ef0 100644 --- a/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs +++ b/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs @@ -12,12 +12,12 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Common.Authentication.Properties; using Microsoft.Rest; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication.Models { diff --git a/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs b/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs index af11eab542a5..4e6234544b9e 100644 --- a/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs +++ b/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs @@ -12,11 +12,11 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Common.Authentication.Properties; using System; using System.IO; using System.Security.Cryptography.X509Certificates; using System.Text; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication.Models { diff --git a/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs b/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs index 6ac14542c061..a1a8b9bcf634 100644 --- a/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs +++ b/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Commands.Common.Authentication.Properties { +namespace Microsoft.Azure.Commands.Common.Authentication.Properties { using System; using System.Reflection; @@ -38,7 +38,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Commands.Common.Authentication.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Azure.Commands.Common.Authentication.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; @@ -140,15 +140,6 @@ internal static string AuthenticatingForSingleTenant { } } - /// - /// Looks up a localized string similar to Windows Azure Powershell. - /// - internal static string AzureDirectoryName { - get { - return ResourceManager.GetString("AzureDirectoryName", resourceCulture); - } - } - /// /// Looks up a localized string similar to No certificate was found in the certificate store with thumbprint {0}. /// diff --git a/src/CLU/Commands.Common.Authentication/Properties/Resources.resx b/src/CLU/Commands.Common.Authentication/Properties/Resources.resx index 6d8140059cc5..1e1662b54e32 100644 --- a/src/CLU/Commands.Common.Authentication/Properties/Resources.resx +++ b/src/CLU/Commands.Common.Authentication/Properties/Resources.resx @@ -120,9 +120,6 @@ Account needs to be specified - - Windows Azure Powershell - No certificate was found in the certificate store with thumbprint {0} diff --git a/src/CLU/Commands.Common.Authentication/Validate.cs b/src/CLU/Commands.Common.Authentication/Validate.cs index e25efbaeb580..b24ecf284cc3 100644 --- a/src/CLU/Commands.Common.Authentication/Validate.cs +++ b/src/CLU/Commands.Common.Authentication/Validate.cs @@ -12,10 +12,10 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Common.Authentication.Properties; using System; using System.IO; using System.Linq; -using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication { From d9d36b43c644732ceecdf8cb2ca0b447ed1c38e5 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Tue, 15 Dec 2015 13:51:15 -0800 Subject: [PATCH 04/12] [#110124884] Investigate PSObject removal from resource cmdlets. --- .../Authentication/AdalTokenProvider.cs | 2 +- .../Authentication/ServicePrincipalTokenProvider.cs | 2 +- .../Authentication/UserTokenProvider.cs | 2 +- .../AuthenticationFactory.cs | 2 +- src/CLU/Commands.Common.Authentication/ClientFactory.cs | 2 +- src/CLU/Commands.Common.Authentication/JsonUtilities.cs | 2 +- .../Models/AzureEnvironment.Methods.cs | 2 +- .../Models/AzureSMProfile.cs | 2 +- .../Models/DiskDataStore.cs | 2 +- .../Properties/Resources.Designer.cs | 4 ++-- src/CLU/Commands.Common.Authentication/Validate.cs | 2 +- src/CLU/Commands.Common/AzurePSCmdlet.cs | 8 ++++---- src/CLU/Commands.Common/PowerShellUtilities.cs | 9 ++------- .../Extensions/JTokenExtensions.cs | 9 ++------- .../Extensions/PsObjectExtensions.cs | 4 +--- .../Extensions/ResourceExtensions.cs | 8 +------- .../Implementation/Resource/GetAzureResourceCmdlet.cs | 2 +- .../Tags/GetAzureTagCommand.cs | 1 - tools/CLU/SetupEnv.bat | 2 +- 19 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs index b786a96e51bf..d94cb1973b4b 100644 --- a/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs +++ b/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs @@ -12,8 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Commands.Common.Authentication.Properties; using Microsoft.Azure.Commands.Common.Authentication.Models; -using Microsoft.Azure.Commands.Common.Authentication.Properties; using System; namespace Microsoft.Azure.Commands.Common.Authentication diff --git a/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs index 403da5738ca4..92727df1fa05 100644 --- a/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs +++ b/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs @@ -12,8 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Commands.Common.Authentication.Properties; using Microsoft.Azure.Commands.Common.Authentication.Models; -using Microsoft.Azure.Commands.Common.Authentication.Properties; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.Rest; using System; diff --git a/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs index df96ae6be080..c410c5678ed5 100644 --- a/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs +++ b/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs @@ -19,7 +19,7 @@ using System.Runtime.InteropServices; using Microsoft.Rest.Azure.Authentication; using System.Management.Automation; -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication { diff --git a/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs b/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs index 2b64a806abd9..82582ce93143 100644 --- a/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs +++ b/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs @@ -19,7 +19,7 @@ using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.Rest; using Microsoft.Rest.Azure.Authentication; -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; namespace Microsoft.Azure.Commands.Common.Authentication.Factories { diff --git a/src/CLU/Commands.Common.Authentication/ClientFactory.cs b/src/CLU/Commands.Common.Authentication/ClientFactory.cs index 069034a3394a..3ef47e696424 100644 --- a/src/CLU/Commands.Common.Authentication/ClientFactory.cs +++ b/src/CLU/Commands.Common.Authentication/ClientFactory.cs @@ -12,8 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Commands.Common.Authentication.Properties; using Microsoft.Azure.Commands.Common.Authentication.Models; -using Microsoft.Azure.Commands.Common.Authentication.Properties; using Microsoft.Rest; using System; using System.Collections.Generic; diff --git a/src/CLU/Commands.Common.Authentication/JsonUtilities.cs b/src/CLU/Commands.Common.Authentication/JsonUtilities.cs index 2149e045b5a0..590de89d7bd5 100644 --- a/src/CLU/Commands.Common.Authentication/JsonUtilities.cs +++ b/src/CLU/Commands.Common.Authentication/JsonUtilities.cs @@ -12,7 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs index 0901ffa1cfba..6e2a413fbab6 100644 --- a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs +++ b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs @@ -12,7 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; using System; using System.Collections.Generic; diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs b/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs index 7d0346199ef0..6545dc95a074 100644 --- a/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs +++ b/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs @@ -12,7 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; using Microsoft.Rest; using Newtonsoft.Json; using System; diff --git a/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs b/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs index 4e6234544b9e..26bc7c5c23e8 100644 --- a/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs +++ b/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs @@ -12,7 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; using System; using System.IO; using System.Security.Cryptography.X509Certificates; diff --git a/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs b/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs index a1a8b9bcf634..d9a39bacf125 100644 --- a/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs +++ b/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.Azure.Commands.Common.Authentication.Properties { +namespace Commands.Common.Authentication.Properties { using System; using System.Reflection; @@ -38,7 +38,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Azure.Commands.Common.Authentication.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Commands.Common.Authentication.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/CLU/Commands.Common.Authentication/Validate.cs b/src/CLU/Commands.Common.Authentication/Validate.cs index b24ecf284cc3..497e02f4473d 100644 --- a/src/CLU/Commands.Common.Authentication/Validate.cs +++ b/src/CLU/Commands.Common.Authentication/Validate.cs @@ -12,7 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.Common.Authentication.Properties; +using Commands.Common.Authentication.Properties; using System; using System.IO; using System.Linq; diff --git a/src/CLU/Commands.Common/AzurePSCmdlet.cs b/src/CLU/Commands.Common/AzurePSCmdlet.cs index 48fca661c3bf..7b06f6d5055a 100644 --- a/src/CLU/Commands.Common/AzurePSCmdlet.cs +++ b/src/CLU/Commands.Common/AzurePSCmdlet.cs @@ -436,14 +436,14 @@ protected virtual void WriteExceptionError(Exception ex) WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null)); } - protected PSObject ConstructPSObject(string typeName, params object[] args) + protected PSObject ConstructPSObject(params object[] args) { - return PowerShellUtilities.ConstructPSObject(typeName, args); + return PowerShellUtilities.ConstructPSObject(args); } - protected void SafeWriteOutputPSObject(string typeName, params object[] args) + protected void SafeWriteOutputPSObject(params object[] args) { - PSObject customObject = this.ConstructPSObject(typeName, args); + PSObject customObject = this.ConstructPSObject(args); WriteObject(customObject); } diff --git a/src/CLU/Commands.Common/PowerShellUtilities.cs b/src/CLU/Commands.Common/PowerShellUtilities.cs index 70577363ca6d..b5e98952b3cc 100644 --- a/src/CLU/Commands.Common/PowerShellUtilities.cs +++ b/src/CLU/Commands.Common/PowerShellUtilities.cs @@ -50,17 +50,12 @@ private static void ChangeForTargetEnvironment(Func, IEnumer } } - public static PSObject ConstructPSObject(string typeName, params object[] args) + public static PSObject ConstructPSObject(params object[] args) { Debug.Assert(args.Length % 2 == 0, "The parameter args length must be even number"); PSObject outputObject = new PSObject(); - - if (!string.IsNullOrEmpty(typeName)) - { - outputObject.TypeNames.Add(typeName); - } - + for (int i = 0, j = 0; i < args.Length / 2; i++, j += 2) { outputObject.Properties.Add(new PSNoteProperty(args[j].ToString(), args[j + 1])); diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs index 566a7626ea4e..0a9b410790fd 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs @@ -48,7 +48,7 @@ internal static class JTokenExtensions /// /// The /// The type of the object. - internal static PSObject ToPsObject(this JToken jtoken, string objectType = null) + internal static PSObject ToPsObject(this JToken jtoken) { if (jtoken == null) { @@ -63,12 +63,7 @@ internal static PSObject ToPsObject(this JToken jtoken, string objectType = null var jobject = (JObject)jtoken; var psObject = new PSObject(); - - if (!string.IsNullOrWhiteSpace(objectType)) - { - psObject.TypeNames.Add(objectType); - } - + foreach (var property in jobject.Properties()) { psObject.Properties.Add(new PSNoteProperty( diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs index 2d4fd867ff83..1b5f3ee6b217 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs @@ -86,9 +86,7 @@ private static JToken ToJToken(object value) } else { - var properties = (valueAsPsObject.TypeNames.Any(typeName => typeName.EqualsInsensitively(Constants.MicrosoftAzureResource))) - ? valueAsPsObject.Properties.Where(property => !PsObjectExtensions.PropertiesToRemove.ContainsKey(property.Name)) - : valueAsPsObject.Properties.AsEnumerable(); + var properties = valueAsPsObject.Properties.AsEnumerable(); foreach (var member in properties) { diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs index e27dd8767048..8cd4d869994e 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs @@ -61,16 +61,10 @@ internal static PSObject ToPsObject(this Resource resource) { "Sku", resource.Sku == null ? null : resource.Sku.ToJToken().ToPsObject() }, }; - var resourceTypeName = resourceType == null && extensionResourceType == null - ? null - : (resourceType + extensionResourceType).Replace('/', '.'); - var psObject = PowerShellUtilities.ConstructPSObject( - resourceTypeName, objectDefinition.Where(kvp => kvp.Value != null).SelectManyArray(kvp => new[] { kvp.Key, kvp.Value })); - - psObject.TypeNames.Add(Constants.MicrosoftAzureResource); + return psObject; } diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs index 38de888a634f..dbdfeb6d31dd 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs @@ -33,7 +33,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase { /// - /// Contains the errors that encountered while satifying the request. + /// Contains the errors that encountered while satisfying the request. /// private readonly ConcurrentBag errors = new ConcurrentBag(); diff --git a/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs b/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs index 273bcbc34ee7..3f976d621cec 100644 --- a/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs +++ b/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs @@ -51,7 +51,6 @@ protected override void ProcessRecord() { List output = new List(); tags.ForEach(t => output.Add(base.ConstructPSObject( - null, "Name", t.Name, "Count", t.Count))); diff --git a/tools/CLU/SetupEnv.bat b/tools/CLU/SetupEnv.bat index 5170bdd598ba..2b7411f6881c 100644 --- a/tools/CLU/SetupEnv.bat +++ b/tools/CLU/SetupEnv.bat @@ -14,7 +14,7 @@ set DebugCLU= call %~dp0\BuildAndInstallClu.bat set Path=%Path%;%root%\drop\clurun\win7-x64 REM run 'azure help' to verify all are wired up -azure help +azure.bat help if ERRORLEVEL 1 ( echo Build and deploy clu package failed exit /B 1 From dc34da63bd2e33838612a87a49aa37cdec6bcffb Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Tue, 15 Dec 2015 16:00:18 -0800 Subject: [PATCH 05/12] Removed PSObject from Resource Lock cmdlets. --- src/CLU/Commands.Common/AzurePSCmdlet.cs | 8 +----- .../Entities/Resources/ResourceLock.cs | 27 +++++++++++++++++++ .../Lock/GetAzureResourceLockCmdlet.cs | 4 +-- .../Lock/NewAzureResourceLockCmdlet.cs | 5 ++-- .../Lock/RemoveAzureResourceLockCmdlet.cs | 2 +- .../Lock/ResourceLockManagementCmdletBase.cs | 10 +++---- .../Lock/SetAzureResourceLockCmdlet.cs | 5 +++- .../Resource/FindAzureResourceCmdlet.cs | 6 ++--- .../Resource/GetAzureResourceCmdlet.cs | 6 ++--- .../Resource/NewAzureResourceCmdlet.cs | 6 ++++- .../Resource/SetAzureResourceCmdlet.cs | 3 ++- .../ResourceManagerCmdletBase.cs | 2 +- .../ScenarioTests/ResourceLockTests.cs | 2 +- 13 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs diff --git a/src/CLU/Commands.Common/AzurePSCmdlet.cs b/src/CLU/Commands.Common/AzurePSCmdlet.cs index 7b06f6d5055a..a0d1b1ad30cb 100644 --- a/src/CLU/Commands.Common/AzurePSCmdlet.cs +++ b/src/CLU/Commands.Common/AzurePSCmdlet.cs @@ -440,13 +440,7 @@ protected PSObject ConstructPSObject(params object[] args) { return PowerShellUtilities.ConstructPSObject(args); } - - protected void SafeWriteOutputPSObject(params object[] args) - { - PSObject customObject = this.ConstructPSObject(args); - WriteObject(customObject); - } - + private void FlushDebugMessages(bool record = false) { if (record) diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs new file mode 100644 index 000000000000..ea5092778097 --- /dev/null +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs @@ -0,0 +1,27 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Newtonsoft.Json; + +namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources +{ + public class ResourceLock : Resource + { + /// + /// Gets or sets the lock id for the resource. + /// + [JsonProperty(Required = Required.Default)] + public string LockId { get; set; } + } +} diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs index 00cca469d5be..36e570f7d830 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs @@ -19,11 +19,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; using Newtonsoft.Json.Linq; - + using Entities.Resources; /// /// Gets the resource lock. /// - [Cmdlet(VerbsCommon.Get, "AzureRmResourceLock"), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Get, "AzureRmResourceLock"), OutputType(typeof(ResourceLock))] public class GetAzureResourceLockCmdlet : ResourceLockManagementCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs index d6f6b6feab59..ed63088cbdce 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs @@ -18,11 +18,12 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Locks; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; using Newtonsoft.Json.Linq; - + using Entities.Resources; /// /// The new azure resource lock cmdlet. /// - [Cmdlet(VerbsCommon.New, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.New, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock), + OutputType(typeof(ResourceLock))] public class NewAzureResourceLockCmdlet : ResourceLockManagementCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs index e46cb174da66..1a76f691a855 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs @@ -20,7 +20,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// The remove azure resource lock cmdlet. /// - [Cmdlet(VerbsCommon.Remove, "AzureRmResourceLock", SupportsShouldProcess = true), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Remove, "AzureRmResourceLock", SupportsShouldProcess = true), OutputType(typeof(bool))] public class RemoveAzureResourceLockCmdlet : ResourceLockManagementCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs index e6c87263fe7e..d34952515617 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs @@ -77,7 +77,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa [Parameter(ParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource name. e.g. to specify a database MyServer/MyDatabase.")] [Parameter(ParameterSetName = ResourceLockManagementCmdletBase.TenantResourceLevelLock, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource name. e.g. to specify a database MyServer/MyDatabase.")] [ValidateNotNullOrEmpty] - [Alias("name", "n")] public string ResourceName { get; set; } /// @@ -151,16 +150,17 @@ protected string GetResourceId(string lockName) /// Converts the resource object to output that can be piped to the lock cmdlets. /// /// The lock resource object. - protected PSObject[] GetOutputObjects(params JToken[] resources) + protected ResourceLock[] GetOutputObjects(params JToken[] resources) { return resources .CoalesceEnumerable() .Where(resource => resource != null) .SelectArray(resource => { - var psobject = resource.ToResource().ToPsObject(); - psobject.Properties.Add(new PSNoteProperty("LockId", psobject.Properties["ResourceId"].Value)); - return psobject; + var rc = resource.ToResource(); + var resourceLock = rc.Cast>(); + resourceLock.LockId = rc.Properties["ResourceId"].ToString(); + return resourceLock; }); } } diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs index edf3b3789b42..7404305f59f0 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs @@ -14,12 +14,15 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation { + using Entities.Resources; + using Newtonsoft.Json.Linq; using System.Management.Automation; /// /// The set resource lock cmdlet. /// - [Cmdlet(VerbsCommon.Set, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Set, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock), + OutputType(typeof(ResourceLock))] public class SetAzureResourceLockCmdlet : NewAzureResourceLockCmdlet { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs index 544c25315940..4a60f6497cd3 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs @@ -29,7 +29,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Cmdlet to get existing resources from ARM cache. /// - [Cmdlet(VerbsCommon.Find, "AzureRmResource", DefaultParameterSetName = FindAzureResourceCmdlet.ListResourcesParameterSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Find, "AzureRmResource", DefaultParameterSetName = FindAzureResourceCmdlet.ListResourcesParameterSet), OutputType(typeof(Resource))] public sealed class FindAzureResourceCmdlet : ResourceManagerCmdletBase { /// @@ -191,14 +191,14 @@ private void RunCmdlet() items = this.GetPopulatedResource(batch).Result; } - var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject()); + var powerShellObjects = items.SelectArray(genericResource => genericResource); this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true); } } else { - this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject()), enumerateCollection: true); + this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToResource()), enumerateCollection: true); } }); diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs index dbdfeb6d31dd..46e23dd1721b 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs @@ -29,7 +29,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Cmdlet to get existing resources. /// - [Cmdlet(VerbsCommon.Get, "AzureRmResource", DefaultParameterSetName = GetAzureResourceCmdlet.ParameterlessSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Get, "AzureRmResource", DefaultParameterSetName = GetAzureResourceCmdlet.ParameterlessSet), OutputType(typeof(Resource))] public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase { /// @@ -228,14 +228,14 @@ private void RunCmdlet() items = this.GetPopulatedResource(batch).Result; } - var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject()); + var powerShellObjects = items.SelectArray(genericResource => genericResource); this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true); } } else { - this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject()), enumerateCollection: true); + this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToResource()), enumerateCollection: true); } }); diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs index 22c469cc8731..670dce29e0e4 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs @@ -26,7 +26,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// A cmdlet that creates a new azure resource. /// - [Cmdlet(VerbsCommon.New, "AzureRmResource", SupportsShouldProcess = true, DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.New, + "AzureRmResource", + SupportsShouldProcess = true, + DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet), + OutputType(typeof(Resource))] public sealed class NewAzureResourceCmdlet : ResourceManipulationCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs index 4db23b50d874..7edcd7c7d87d 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs @@ -27,7 +27,8 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// A cmdlet that creates a new azure resource. /// - [Cmdlet(VerbsCommon.Set, "AzureRmResource", SupportsShouldProcess = true, DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Set, "AzureRmResource", SupportsShouldProcess = true, DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet), + OutputType(typeof(Resource))] public sealed class SetAzureResourceCmdlet : ResourceManipulationCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs index d8ecf9a2937f..56e282f03e24 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs @@ -301,7 +301,7 @@ protected void TryConvertToResourceAndWriteObject(string resultString) Resource resultResource; if (resultString.TryConvertTo>(out resultResource)) { - this.WriteObject(resultResource.ToPsObject()); + this.WriteObject(resultResource); } else { diff --git a/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs b/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs index e0a1ded9ad87..2bb2a1bda20a 100644 --- a/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs +++ b/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests { public class ResourceLockTests : RMTestBase { - [Fact(Skip = "TODO, [#108248038]: Enable scenario tests")] + [Fact] public void TestResourceLockCRUDTest() { ResourcesController.NewInstance.RunPsTest("Test-ResourceLockCRUD"); From 29d5dc0f65c4593e3ae41e00510c0805f315d2e5 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Tue, 15 Dec 2015 17:08:54 -0800 Subject: [PATCH 06/12] Removed PSObject from PolicyAssignment, PolicyDefinition and ResourceLock --- .../{Resources => Locks}/ResourceLock.cs | 5 +++ .../Policy/ResourcePolicyAssignment.cs | 33 +++++++++++++++++++ .../Policy/ResourcePolicyDefinition.cs | 33 +++++++++++++++++++ .../Entities/Resources/Resource.cs | 21 ++++++++++++ ...eResourceGroupDeploymentOperationCmdlet.cs | 4 +-- .../Lock/ResourceLockManagementCmdletBase.cs | 4 +-- .../Policy/GetAzurePolicyAssignment.cs | 4 +-- .../Policy/GetAzurePolicyDefinition.cs | 4 +-- .../Policy/NewAzurePolicyAssignment.cs | 12 +++---- .../Policy/NewAzurePolicyDefinition.cs | 2 +- .../Policy/PolicyAssignmentCmdletBase.cs | 11 ++++--- .../Policy/PolicyDefinitionCmdletBase.cs | 11 ++++--- .../Policy/SetAzurePolicyAssignment.cs | 2 +- .../Policy/SetAzurePolicyDefinition.cs | 2 +- 14 files changed, 119 insertions(+), 29 deletions(-) rename src/CLU/Commands.ResourceManager.Cmdlets/Entities/{Resources => Locks}/ResourceLock.cs (92%) create mode 100644 src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs create mode 100644 src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Locks/ResourceLock.cs similarity index 92% rename from src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs rename to src/CLU/Commands.ResourceManager.Cmdlets/Entities/Locks/ResourceLock.cs index ea5092778097..ff93b218479d 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/ResourceLock.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Locks/ResourceLock.cs @@ -18,6 +18,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources { public class ResourceLock : Resource { + public ResourceLock(Resource r) + : base(r) + { + } + /// /// Gets or sets the lock id for the resource. /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs new file mode 100644 index 000000000000..b5937d2fb57e --- /dev/null +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs @@ -0,0 +1,33 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources; +using Newtonsoft.Json; + +namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy +{ + public class ResourcePolicyAssignment : Resource + { + public ResourcePolicyAssignment(Resource r) + : base(r) + { + } + + /// + /// Gets or sets the policy assignment id for the resource. + /// + [JsonProperty(Required = Required.Default)] + public string PolicyAssignmentId { get; set; } + } +} diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs new file mode 100644 index 000000000000..6139213b4de9 --- /dev/null +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs @@ -0,0 +1,33 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources; +using Newtonsoft.Json; + +namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy +{ + public class ResourcePolicyDefinition : Resource + { + public ResourcePolicyDefinition(Resource r) + : base(r) + { + } + + /// + /// Gets or sets the policy definition id for the resource. + /// + [JsonProperty(Required = Required.Default)] + public string PolicyDefinitionId { get; set; } + } +} diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs index 777e0354038a..c2f1df956fd6 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs @@ -23,6 +23,27 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources /// public class Resource { + public Resource() + { + + } + + public Resource(Resource r) + { + this.ChangedTime = r.ChangedTime; + this.CreatedTime = r.CreatedTime; + this.ETag = r.ETag; + this.Id = r.Id; + this.Kind = r.Kind; + this.Location = r.Location; + this.Name = r.Name; + this.Plan = r.Plan; + this.Properties = r.Properties; + this.Sku = r.Sku; + this.Tags = r.Tags; + this.Type = r.Type; + } + /// /// Gets or sets the properties. /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs index 143661d453f5..548aa7426584 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs @@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Gets the deployment operation. /// - [Cmdlet(VerbsCommon.Get, "AzureRmResourceGroupDeploymentOperation"), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Get, "AzureRmResourceGroupDeploymentOperation"), OutputType(typeof(Resource))] public class GetAzureResourceGroupDeploymentOperationCmdlet : ResourceManagerCmdletBase { /// @@ -81,7 +81,7 @@ private void RunCmdlet() getFirstPage: () => this.GetResources(), getNextPage: nextLink => this.GetNextLink(nextLink), cancellationToken: this.CancellationToken, - action: resources => this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(resource => resource.ToPsObject()), enumerateCollection: true)); + action: resources => this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(resource => resource.ToResource()), enumerateCollection: true)); } /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs index d34952515617..b7ddbefab94d 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs @@ -158,8 +158,8 @@ protected ResourceLock[] GetOutputObjects(params JToken[] resources) .SelectArray(resource => { var rc = resource.ToResource(); - var resourceLock = rc.Cast>(); - resourceLock.LockId = rc.Properties["ResourceId"].ToString(); + var resourceLock = new ResourceLock(rc); + resourceLock.LockId = rc.Id; return resourceLock; }); } diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs index 4ec1add1e685..130a0947db06 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs @@ -19,11 +19,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; using Newtonsoft.Json.Linq; - + using Entities.Policy; /// /// Gets the policy assignment. /// - [Cmdlet(VerbsCommon.Get, "AzureRmPolicyAssignment", DefaultParameterSetName = GetAzurePolicyAssignmentCmdlet.ParameterlessSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Get, "AzureRmPolicyAssignment", DefaultParameterSetName = GetAzurePolicyAssignmentCmdlet.ParameterlessSet), OutputType(typeof(ResourcePolicyAssignment))] public class GetAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs index 02eb9fc6ad31..18b767997cbf 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs @@ -19,11 +19,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; using Newtonsoft.Json.Linq; - + using Entities.Policy; /// /// Gets the policy definition. /// - [Cmdlet(VerbsCommon.Get, "AzureRmPolicyDefinition", DefaultParameterSetName = GetAzurePolicyDefinitionCmdlet.ParameterlessSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Get, "AzureRmPolicyDefinition", DefaultParameterSetName = GetAzurePolicyDefinitionCmdlet.ParameterlessSet), OutputType(typeof(ResourcePolicyDefinition))] public class GetAzurePolicyDefinitionCmdlet : PolicyDefinitionCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs index 4cb71ebced19..cea7a2970081 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs @@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Creates a policy assignment. /// - [Cmdlet(VerbsCommon.New, "AzureRmPolicyAssignment"), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.New, "AzureRmPolicyAssignment"), OutputType(typeof(ResourcePolicyAssignment))] public class NewAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase { /// @@ -51,8 +51,8 @@ public class NewAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase /// /// Gets or sets the policy assignment policy definition parameter. /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The pollicy definition object.")] - public PSObject PolicyDefinition { get; set; } + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The policy definition id object.")] + public string PolicyDefinitionId { get; set; } /// /// Executes the cmdlet. @@ -60,10 +60,6 @@ public class NewAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase protected override void OnProcessRecord() { base.OnProcessRecord(); - if(this.PolicyDefinition.Properties["policyDefinitionId"] == null) - { - throw new PSInvalidOperationException("The supplied PolicyDefinition object is invalid."); - } string resourceId = GetResourceId(); var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result; @@ -111,7 +107,7 @@ private JToken GetResource() Properties = new PolicyAssignmentProperties { DisplayName = this.DisplayName ?? null, - PolicyDefinitionId = this.PolicyDefinition.Properties["policyDefinitionId"].Value.ToString(), + PolicyDefinitionId = PolicyDefinitionId, Scope = this.Scope } }; diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs index a02f8a67895c..ae2cecfe1317 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs @@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Creates the policy definition. /// - [Cmdlet(VerbsCommon.New, "AzureRmPolicyDefinition"), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.New, "AzureRmPolicyDefinition"), OutputType(typeof(ResourcePolicyDefinition))] public class NewAzurePolicyDefinitionCmdlet : PolicyDefinitionCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs index ba523ad3b9d4..94dbebe03861 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs @@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; using Newtonsoft.Json.Linq; - + using Entities.Policy; /// /// Base class for policy assignment cmdlets. /// @@ -42,16 +42,17 @@ protected Task> GetNextLink(string next /// Converts the resource object to policy definition object. /// /// The policy definition resource object. - protected PSObject[] GetOutputObjects(params JToken[] resources) + protected ResourcePolicyAssignment[] GetOutputObjects(params JToken[] resources) { return resources .CoalesceEnumerable() .Where(resource => resource != null) .SelectArray(resource => { - var psobject = resource.ToResource().ToPsObject(); - psobject.Properties.Add(new PSNoteProperty("PolicyAssignmentId", psobject.Properties["ResourceId"].Value)); - return psobject; + var rc = resource.ToResource(); + var res = new ResourcePolicyAssignment(rc); + res.PolicyAssignmentId = rc.Id; + return res; }); } } diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs index 799c7751ee73..dcab1b660fa2 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs @@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; using Newtonsoft.Json.Linq; - + using Entities.Policy; /// /// Base class for policy definition cmdlets. /// @@ -42,16 +42,17 @@ protected Task> GetNextLink(string next /// Converts the resource object to policy definition object. /// /// The policy definition resource object. - protected PSObject[] GetOutputObjects(params JToken[] resources) + protected ResourcePolicyDefinition[] GetOutputObjects(params JToken[] resources) { return resources .CoalesceEnumerable() .Where(resource => resource != null) .SelectArray(resource => { - var psobject = resource.ToResource().ToPsObject(); - psobject.Properties.Add(new PSNoteProperty("PolicyDefinitionId", psobject.Properties["ResourceId"].Value)); - return psobject; + var rc = resource.ToResource(); + var res = new ResourcePolicyDefinition(rc); + res.PolicyDefinitionId = rc.Id; + return res; }); } } diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs index 23d62a553140..2d18d8de2303 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs @@ -24,7 +24,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Sets the policy assignment. /// - [Cmdlet(VerbsCommon.Set, "AzureRmPolicyAssignment", DefaultParameterSetName = SetAzurePolicyAssignmentCmdlet.PolicyAssignmentNameParameterSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Set, "AzureRmPolicyAssignment", DefaultParameterSetName = SetAzurePolicyAssignmentCmdlet.PolicyAssignmentNameParameterSet), OutputType(typeof(ResourcePolicyAssignment))] public class SetAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase { /// diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs index 81ff53ea8c8c..333a6ef74aaf 100644 --- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs +++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs @@ -26,7 +26,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation /// /// Sets the policy definition. /// - [Cmdlet(VerbsCommon.Set, "AzureRmPolicyDefinition", DefaultParameterSetName = SetAzurePolicyDefinitionCmdlet.PolicyDefinitionNameParameterSet), OutputType(typeof(PSObject))] + [Cmdlet(VerbsCommon.Set, "AzureRmPolicyDefinition", DefaultParameterSetName = SetAzurePolicyDefinitionCmdlet.PolicyDefinitionNameParameterSet), OutputType(typeof(ResourcePolicyDefinition))] public class SetAzurePolicyDefinitionCmdlet : PolicyDefinitionCmdletBase { /// From fce73765108728e5b6360ee91e7145217935e00f Mon Sep 17 00:00:00 2001 From: markcowl Date: Tue, 15 Dec 2015 18:46:51 -0800 Subject: [PATCH 07/12] Updating output format for Profile cmdlets --- .../Models/AzureEnvironment.Methods.cs | 2 +- .../Commands.Common/Models/PSAzureContext.cs | 9 +++ .../Commands.Common/Models/PSAzureProfile.cs | 5 ++ ...osoft.Azure.Commands.Profile.format.ps1xml | 64 +++++++++++++++++-- src/CLU/Microsoft.CLU/Helpers/FormatReader.cs | 19 ++++-- 5 files changed, 90 insertions(+), 9 deletions(-) diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs index 0f92cd1759b5..7f3fe2d3f250 100644 --- a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs +++ b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs @@ -372,7 +372,7 @@ public static class AzureEnvironmentConstants public const string USGovernmentSqlDatabaseDnsSuffix = ".database.usgovcloudapi.net"; - public const string AzureActiveDirectoryEndpoint = "https://login.windows.net/"; + public const string AzureActiveDirectoryEndpoint = "https://login.microsoftonline.com/"; public const string ChinaActiveDirectoryEndpoint = "https://login.chinacloudapi.cn/"; diff --git a/src/CLU/Commands.Common/Models/PSAzureContext.cs b/src/CLU/Commands.Common/Models/PSAzureContext.cs index 263b16740c66..f84aeb5878d0 100644 --- a/src/CLU/Commands.Common/Models/PSAzureContext.cs +++ b/src/CLU/Commands.Common/Models/PSAzureContext.cs @@ -86,5 +86,14 @@ public static implicit operator AzureContext(PSAzureContext context) public PSAzureTenant Tenant { get; set; } public byte[] TokenCache { get; set; } + + public override string ToString() + { + var account = Account != null ? Account.Id : string.Empty; + var subscription = Subscription != null ? Subscription.SubscriptionId : string.Empty; + var tenant = Tenant != null ? Tenant.TenantId : string.Empty; + var environment = Environment != null ? Environment.Name : EnvironmentName.AzureCloud; + return $"{{Account: {account}, Subscription: {subscription}, Tenant: {tenant}, Environment: {environment}}}"; + } } } diff --git a/src/CLU/Commands.Common/Models/PSAzureProfile.cs b/src/CLU/Commands.Common/Models/PSAzureProfile.cs index f689c4b88c91..285dd052dfda 100644 --- a/src/CLU/Commands.Common/Models/PSAzureProfile.cs +++ b/src/CLU/Commands.Common/Models/PSAzureProfile.cs @@ -64,6 +64,11 @@ public IDictionary Environments get { return _env; } } + public string EnvironmentNames + { + get { return _env == null? null : $"{string.Join(", ", _env.Keys.ToArray())}"; } + } + /// /// The current credentials and metadata for connecting with the current Azure cloud instance. /// diff --git a/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml b/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml index 9398b286a02f..e745d0fcee98 100644 --- a/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml +++ b/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml @@ -1,7 +1,7 @@ - + Microsoft.Azure.Commands.Models.PSAzureProfile Microsoft.Azure.Commands.Models.PSAzureProfile @@ -12,14 +12,17 @@ - Context - + + + EnvironmentNames + + - + --> Microsoft.Azure.Commands.Models.PSAzureContext @@ -96,5 +99,58 @@ + + Microsoft.Azure.Commands.Models.PSAzureEnvironment + + Microsoft.Azure.Commands.Models.PSAzureEnvironment + + + + + + + Name + + + + ActiveDirectoryAuthority + + + + ResourceManagerUrl + + + + GraphUrl + + + + GalleryUrl + + + + AdTenant + + + + ActiveDirectoryServiceEndpointResourceId + + + + AzureKeyVaultServiceEndpointResourceId + + + + AzureKeyVaultDnsSuffix + + + + EnableAdfsAuthentication + + + + + + diff --git a/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs b/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs index 6c7d59e99030..efe91f469753 100644 --- a/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs +++ b/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs @@ -136,13 +136,13 @@ private static void GetTableColumnItems(TableDescriptor table, XElement tableCon } } - private static void GetListItems(ListDescriptor list, XElement tableControl) + private static void GetListItems(ListDescriptor list, XElement listControl) { - var tableHeaders = GetChildrenMatching(tableControl, "ListEntries").FirstOrDefault(); + var listEntries = GetChildrenMatching(listControl, "ListEntries").FirstOrDefault(); - if (tableHeaders != null) + if (listEntries != null) { - foreach (var entry in GetChildrenMatching(tableHeaders, "ListEntry")) + foreach (var entry in GetChildrenMatching(listEntries, "ListEntry")) { foreach (var items in GetChildrenMatching(entry, "ListItems")) { @@ -152,6 +152,7 @@ private static void GetListItems(ListDescriptor list, XElement tableControl) var label = GetChildrenMatching(item, "Label").FirstOrDefault(); var propertyName = GetChildrenMatching(item, "PropertyName").FirstOrDefault(); + var property = GetChildrenMatching(item, "Property").FirstOrDefault(); if (label != null && !string.IsNullOrEmpty(label.Value)) { @@ -160,6 +161,16 @@ private static void GetListItems(ListDescriptor list, XElement tableControl) if (propertyName != null && !string.IsNullOrEmpty(propertyName.Value)) { column.ItemName = propertyName.Value; + if (string.IsNullOrEmpty(column.Header)) + { + column.Header = propertyName.Value; + } + } + + if (property != null && !string.IsNullOrEmpty(property.Value) && + string.IsNullOrEmpty(column.ItemName)) + { + column.ItemName = property.Value; } if (!string.IsNullOrEmpty(column.ItemName) && !string.IsNullOrEmpty(column.Header)) From 4492a394ec39356f20bb1c8b7f646e703b491bd6 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Wed, 16 Dec 2015 10:55:48 -0800 Subject: [PATCH 08/12] Removed powershell test. --- .../Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs b/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs index 2bb2a1bda20a..e0a1ded9ad87 100644 --- a/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs +++ b/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceLockTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests { public class ResourceLockTests : RMTestBase { - [Fact] + [Fact(Skip = "TODO, [#108248038]: Enable scenario tests")] public void TestResourceLockCRUDTest() { ResourcesController.NewInstance.RunPsTest("Test-ResourceLockCRUD"); From 30ff134051378f35d56e7333c824f32160cc626a Mon Sep 17 00:00:00 2001 From: yugangw-msft Date: Tue, 15 Dec 2015 19:14:53 -0800 Subject: [PATCH 09/12] use recommenedd coreconsole from https://github.com/dotnet/cli --- tools/CLU/BuildAndInstallClu.bat | 14 +++++++++++++- tools/CLU/BuildDrop.ps1 | 4 ++-- tools/CLU/BuildPackage.ps1 | 14 +++++++------- tools/CLU/SetupEnv.bat | 2 +- tools/CLU/osx.10.10-x64/coreconsole | Bin 0 -> 22172 bytes tools/CLU/ubuntu.14.04-x64/coreconsole | Bin 0 -> 24794 bytes 6 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 tools/CLU/osx.10.10-x64/coreconsole create mode 100644 tools/CLU/ubuntu.14.04-x64/coreconsole diff --git a/tools/CLU/BuildAndInstallClu.bat b/tools/CLU/BuildAndInstallClu.bat index 72ac4aef44e3..22b9a6a5178a 100644 --- a/tools/CLU/BuildAndInstallClu.bat +++ b/tools/CLU/BuildAndInstallClu.bat @@ -28,9 +28,21 @@ REM note, for known nuget bugs, skip --install by copying over cmdlet packages. xcopy %root%\drop\clurun\win7-x64\pkgs %root%\drop\clurun\osx.10.10-x64\pkgs /S /Q /I /Y copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\osx.10.10-x64 copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\osx.10.10-x64 + +REM: copy over the pre-cooked azure.sh and ensure correct line endings copy /Y %~dp0\azure.sh %root%\drop\clurun\osx.10.10-x64 +set azuresh=%root%\drop\clurun\osx.10.10-x64\azure.sh +echo Get-ChildItem %azuresh% ^| ForEach-Object { > %temp%\fixLineEndings.ps1 +echo $contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n" >> %temp%\fixLineEndings.ps1 +echo [IO.File]::WriteAllText($_, $contents) >> %temp%\fixLineEndings.ps1 +echo } >> %temp%\fixLineEndings.ps1 +@powershell -file %temp%\fixLineEndings.ps1 xcopy %root%\drop\clurun\win7-x64\pkgs %root%\drop\clurun\ubuntu.14.04-x64\pkgs /S /Q /I /Y copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\ubuntu.14.04-x64 copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\ubuntu.14.04-x64 -copy /Y %~dp0\azure.sh %root%\drop\clurun\ubuntu.14.04-x64 \ No newline at end of file +copy /Y %azuresh% %root%\drop\clurun\ubuntu.14.04-x64 + +REM, windows version also needs it for bash based testing +copy /Y %azuresh% %root%\drop\clurun\win7-x64 + diff --git a/tools/CLU/BuildDrop.ps1 b/tools/CLU/BuildDrop.ps1 index 7e0dfc822340..bf48a62c39d8 100644 --- a/tools/CLU/BuildDrop.ps1 +++ b/tools/CLU/BuildDrop.ps1 @@ -50,8 +50,8 @@ if (!($excludeCluRun)) if (!($runtime.StartsWith("win"))) { - # Fix current x-plat dotnet publish by correctly renaming ConsoleHost to clurun - Move-Item -Path "$cluRunOutput\coreconsole" -Destination "$cluRunOutput\clurun" -Force + # use released coreconsole file from https://github.com/dotnet/cli + Copy-Item -Path "$workspaceDirectory\tools\CLU\$runtime\coreconsole" -Destination "$cluRunOutput\clurun" -Force # Remove all extra exes that end up in the output directory... Get-ChildItem -Path "$cluRunOutput" -Filter "*.exe" | Remove-Item diff --git a/tools/CLU/BuildPackage.ps1 b/tools/CLU/BuildPackage.ps1 index 6beefbc67529..d9a60cfcd634 100644 --- a/tools/CLU/BuildPackage.ps1 +++ b/tools/CLU/BuildPackage.ps1 @@ -2,16 +2,16 @@ if (!(Test-Path $cmdletsDir)) { - throw "cmdletsDir: '$cmdletsDir' must be an existing directory containing cmdlet code" + throw "cmdletsDir: '$cmdletsDir' must be an existing directory containing cmdlet code" } if (!(Test-Path $outputDir)) { - throw "outputDir: '$outputDir' must be an existing directory" + throw "outputDir: '$outputDir' must be an existing directory" } if ([string]::IsNullOrWhiteSpace($env:WORKSPACE) -or !(Test-Path $env:WORKSPACE)) { - throw "env:WORKSPACE: '$env:WORKSPACE' must be an existing directory" + throw "env:WORKSPACE: '$env:WORKSPACE' must be an existing directory" } $packageSource = $packageSource.TrimEnd('\\') @@ -34,19 +34,19 @@ $contentFileText = "" $contentFiles | %{ $contentFileText += (" `r`n")} if ($packageId -ne "Microsoft.CLU.Commands") { - $contentFileText += " `r`n" + $contentFileText += " `r`n" } if ($renameFileExists) { - $contentFileText += " `r`n" + $contentFileText += " `r`n" } $contentFileText += " `r`n" $sourceFileText = "" $refFiles | %{$sourceFileText += (" `r`n")} $outputContent = $fileContent -replace "%PackageVersion%", $packageVersion $outputContent = $outputContent -replace "%ReferenceFiles%", $refFileText - $outputContent = $outputContent -replace "%SourceFiles%", $sourceFileText - $outputContent = $outputContent -replace "%ContentFiles%", $contentFileText +$outputContent = $outputContent -replace "%SourceFiles%", $sourceFileText +$outputContent = $outputContent -replace "%ContentFiles%", $contentFileText Set-Content -Value $outputContent -Path $nuspecOutput Write-Host "Creating nuget package..." diff --git a/tools/CLU/SetupEnv.bat b/tools/CLU/SetupEnv.bat index 5170bdd598ba..2b7411f6881c 100644 --- a/tools/CLU/SetupEnv.bat +++ b/tools/CLU/SetupEnv.bat @@ -14,7 +14,7 @@ set DebugCLU= call %~dp0\BuildAndInstallClu.bat set Path=%Path%;%root%\drop\clurun\win7-x64 REM run 'azure help' to verify all are wired up -azure help +azure.bat help if ERRORLEVEL 1 ( echo Build and deploy clu package failed exit /B 1 diff --git a/tools/CLU/osx.10.10-x64/coreconsole b/tools/CLU/osx.10.10-x64/coreconsole new file mode 100644 index 0000000000000000000000000000000000000000..f9058ac8ec0e716fc3c743cab0ad4d6897d9edc1 GIT binary patch literal 22172 zcmeHPeRx#Gxt~q=2oc=iCu)_|f`T6*0fNM@W+5BS$|i&)AO-QTBpb52*~Hzm5LE76 zCF_&pc5B*Ot@Wdgy=@=r^?IWfN^PN0DGAoLfmTbkt*F(WbgiYeH&R>4{r%>g-E1~e zYoR{(kDMnn@5ju%^UgaTXXc%=`N?~~KR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{OTxu;^AReIj&We%>K5eVs+~u81`M-wo4wmqhw)i{_mY z>6PeZyA2mXcu3zUX>{rglWqkKK9l4VHEFcMe14ckpM%~<=5)F*i+&=DKAJ@@oj9`m z7qjR?S#(j}$ovsWN7MCh$)ek{^51XL>GnOEMSnkwelCmtSr+}PEc(qX`t2GIF z7b0Mdl#9h|KwL-3|Fy!!g`b=iBJfj?A_PwKxd`(R<|C9KVAu+NsDxk8$p7`iUnHE3 za1H|RCV8pI?@Fd4I1m;f;3+#F5vGj%Uq%1lbaV(DI;^)WHga0X=W}zv`%i6wxhtNJ z_j%Y|yFle0dA@35uHq7I62tiH1^?U1e{;mgP0j-KW2$_vs&a3x`fiSR1Exkb)oi8J zVl~*(;8U^b_qnS#x?HtO)S9Jrnaa(*+%ygH1iZm|d@<9g`9fBU+$7K79Na?kzyjM#t&6P$8i3i^{D2Fc1Fe_v@8ePY@&PNs{{k-Hn>&g#Zxm<#C{D>J&Rn)|^~bRnbrsLkTD`6|%@+*wvlUic zJa^u?croEj&Ot&Kt>EQ&V zYcuWBR2xlaX3C2>%6*ygTaI#AlJNnaO0ctClp}qUbSl#8NJwuap>#uz@+x!dD8&B( Ddq+-w literal 0 HcmV?d00001 diff --git a/tools/CLU/ubuntu.14.04-x64/coreconsole b/tools/CLU/ubuntu.14.04-x64/coreconsole new file mode 100644 index 0000000000000000000000000000000000000000..a502adaab0f95f0397ff47277769ca4eaf0157fa GIT binary patch literal 24794 zcmeHveSB2ang2~DK!}hD2pV3L5eFKu2}!^hQ0h#Qfjc^ZG%tWJcr!^R$*jrDbmk5O zd?A>`G94mpfBjY4y1QxXR<_&i(ta#Ot09Ph+IB^)%GTXV74;5Li!Y_IR`dHl=bkgU zGs#tIKl{(`vj^^+^L)?qJm>x8o}ByaaCz2bW@JdhWlCR?h-%DtFi8KEr1DBea;#jM zDmkPD(tK$$kV$wPEQWkNB>WMsTKL(V&jLRSPkE*elxI3vK=|`@7%AvZ-lp(mY+!u0`J(4@ga;|!;iUw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%eF|{2u|Q@sd8zXJRAF z%9XahUoLQwLGG6`9Q}WegCXr4UvI+SWP;ymf`8Kl{~2)VKk4?-7GR%F^E`bAPEOdT zvom~xeQ9%8ji^!F@PfH4<+{pR#pAB4htaVy(`1U;slfhI09MC@!7&2_gGfQ8ts@Bg zUrGz?4@DGjv4sV=%ztaT!Ucikd?qX0pe4q**!+fwdl( z^)d3S7>8U1+e7DR2g+5lTn%|$U8*lY$IlVzd`p2VbFh2m)61xbSqT(nO|7%qrMT8r zk)1f!emuO^v%bRVQP!_nQ|GEz>YWuH7jdxjZ`dL0=unb|*8s!(TvAC(B&f9GJ`giR zM+e2piYN0|27uY8la#6();X))l~RgfEZC7N^Nv|Zb2yk?ByRSIoBjGLjePOs$V6SL zfweT{eW8KR2gR^-xSVAjvfh+aDDd7Dl96!V6uCe=_AFeH~&QnHRHW}7tIi0S>z z)LvnF*3Z*e8@FJWmLc76T^jg#EUf*lX5ECPy|Jt;C+mA;lWzto#JV=DMRVib!P0KIbj@ccaO{n-ZY zXkZ$xRHkM`H?WviZnBA|oAykNU`9Vvp)~80DU;Bcy-yS4m#JCN4RWTMm`vpmb|O== z0Q-r!GngKUKwY;~q&T{kS5CShtNP&Z?l#?37UPGH_MH6`74Wty;=y+IfO t<($cWJ~r=mrpKk2;e;GFBFNfBte<3jaJ Date: Wed, 16 Dec 2015 11:11:42 -0800 Subject: [PATCH 10/12] remove unused azure file, rathe the nix version azure.sh is fine to reuse --- tools/CLU/BuildAndInstallClu.bat | 2 +- tools/CLU/BuildDrop.ps1 | 8 ++++++++ tools/CLU/azure | 4 ---- 3 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 tools/CLU/azure diff --git a/tools/CLU/BuildAndInstallClu.bat b/tools/CLU/BuildAndInstallClu.bat index afa97672e2e9..b173cdf374f9 100644 --- a/tools/CLU/BuildAndInstallClu.bat +++ b/tools/CLU/BuildAndInstallClu.bat @@ -45,4 +45,4 @@ copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\ubuntu.14.04-x6 copy /Y %azuresh% %root%\drop\clurun\ubuntu.14.04-x64 REM, windows version also needs it for bash based testing -copy /Y %azuresh% %root%\drop\clurun\win7-x64 +copy /Y %azuresh% %root%\drop\clurun\win7-x64\azure diff --git a/tools/CLU/BuildDrop.ps1 b/tools/CLU/BuildDrop.ps1 index bf48a62c39d8..325cc5450624 100644 --- a/tools/CLU/BuildDrop.ps1 +++ b/tools/CLU/BuildDrop.ps1 @@ -17,7 +17,15 @@ if (!($dropLocation)) if (!(Test-Path -Path $dropLocation -PathType Container)) { mkdir "$dropLocation" +} + +if (!(Test-Path -Path "$dropLocation\CommandRepo" -PathType Container)) +{ mkdir "$dropLocation\CommandRepo" +} + +if (!(Test-Path -Path "$dropLocation\clurun" -PathType Container)) +{ mkdir "$dropLocation\clurun" } diff --git a/tools/CLU/azure b/tools/CLU/azure deleted file mode 100644 index 9b47ed34a551..000000000000 --- a/tools/CLU/azure +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -BASEDIR=$(dirname $0) - -clurun.exe -s azure -r $BASEDIR/azure.lx $* \ No newline at end of file From f39bc0531d1f90f6587e2055dc07e2df1d05989e Mon Sep 17 00:00:00 2001 From: yugangw-msft Date: Wed, 16 Dec 2015 12:16:55 -0800 Subject: [PATCH 11/12] remove no longer used consolehost package --- src/CLU/Microsoft.CLU.Run/project.json | 1 - src/CLU/clurun/project.json | 1 - 2 files changed, 2 deletions(-) diff --git a/src/CLU/Microsoft.CLU.Run/project.json b/src/CLU/Microsoft.CLU.Run/project.json index e505e09d2a3c..7816d770b9db 100644 --- a/src/CLU/Microsoft.CLU.Run/project.json +++ b/src/CLU/Microsoft.CLU.Run/project.json @@ -9,7 +9,6 @@ "Microsoft.NETCore": "5.0.1-beta-23516", "Microsoft.NETCore.Runtime": "1.0.1-beta-23516", "Microsoft.NETCore.Platforms": "1.0.1-beta-23516", - "Microsoft.NETCore.ConsoleHost": "1.0.0-beta-23516", "Microsoft.NETCore.Runtime.CoreCLR": "1.0.1-beta-23516", "System.Console": "4.0.0-beta-23516", "System.Diagnostics.Process": "4.1.0-beta-23516", diff --git a/src/CLU/clurun/project.json b/src/CLU/clurun/project.json index 795e22f30df1..2794647e986e 100644 --- a/src/CLU/clurun/project.json +++ b/src/CLU/clurun/project.json @@ -7,7 +7,6 @@ "Microsoft.NETCore": "5.0.1-beta-23516", "Microsoft.NETCore.Runtime": "1.0.1-beta-23516", "Microsoft.NETCore.Platforms": "1.0.1-beta-23516", - "Microsoft.NETCore.ConsoleHost": "1.0.0-beta-23516", "Microsoft.NETCore.Runtime.CoreCLR": "1.0.1-beta-23516", "System.Console": "4.0.0-beta-23516", "System.Diagnostics.Process": "4.1.0-beta-23516", From 053deb6394daed5b108b8a9b04e5a14257722a1e Mon Sep 17 00:00:00 2001 From: yugangw-msft Date: Wed, 16 Dec 2015 14:34:59 -0800 Subject: [PATCH 12/12] replace build with dnu restore to improve build perf --- tools/CLU/BuildAndInstallClu.bat | 11 +++++++++++ tools/CLU/SetupEnv.bat | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/CLU/BuildAndInstallClu.bat b/tools/CLU/BuildAndInstallClu.bat index b173cdf374f9..59b09899b0ee 100644 --- a/tools/CLU/BuildAndInstallClu.bat +++ b/tools/CLU/BuildAndInstallClu.bat @@ -6,6 +6,17 @@ if ERRORLEVEL 1 ( echo Please install 'dotnet', say from 'https://azureclu.blob.core.windows.net/tools/dotnet-win-x64.latest.zip', unzip, then add its bin folder to the PATH exit /B 1 ) + +pushd +cd %root%\src\CLU +call dnu.cmd restore +if ERRORLEVEL 1 ( + echo "dnu.cmd restore" failed under folder of "%root%\src\CLU" + popd + exit /B 1 +) +popd + @powershell -file %~dp0\BuildDrop.ps1 REM cook a msclu.cfg with a correct local repro path. diff --git a/tools/CLU/SetupEnv.bat b/tools/CLU/SetupEnv.bat index 2b7411f6881c..af64b5c0ac04 100644 --- a/tools/CLU/SetupEnv.bat +++ b/tools/CLU/SetupEnv.bat @@ -1,13 +1,6 @@ echo off setlocal set root=%~dp0..\.. -echo Build all clu source projects -"%ProgramFiles(x86)%\MSBuild\14.0\Bin\msbuild" %root%\build.proj /t:build >NUL - -if ERRORLEVEL 1 ( - echo Build source project failed. To repro, run: msbuild build.proj /t:build - exit /B 1 -) REM build cmdlets packages set DebugCLU=